blob: ba2e9aa4007ea50bcc82d7fcb52baf087ff7ecc7 [file] [log] [blame]
Devin Jeanpierre59e4d352017-07-21 03:44:36 -07001# Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors
Sam Clegg63860612015-04-09 18:01:33 -07002# Distributed under MIT license, or public domain if desired and
3# recognized in your jurisdiction.
4# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +00006"""Tag the sandbox for release, make source and doc tarballs.
7
8Requires Python 2.6
9
10Example of invocation (use to test the script):
Baptiste Lepilleure1b26452010-03-13 10:59:50 +000011python makerelease.py --platform=msvc6,msvc71,msvc80,msvc90,mingw -ublep 0.6.0 0.7.0-dev
Baptiste Lepilleurcd6cb5d2010-03-13 07:59:07 +000012
13When testing this script:
Baptiste Lepilleurbafb43c2011-05-01 20:36:55 +000014python makerelease.py --force --retag --platform=msvc6,msvc71,msvc80,mingw -ublep test-0.6.0 test-0.6.1-dev
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000015
16Example of invocation when doing a release:
17python makerelease.py 0.5.0 0.6.0-dev
Christopher Dunnb7894972014-09-10 18:01:10 -070018
19Note: This was for Subversion. Now that we are in GitHub, we do not
20need to build versioned tarballs anymore, so makerelease.py is defunct.
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000021"""
Sam Clegg63860612015-04-09 18:01:33 -070022
Christopher Dunnbd1e8952014-11-19 23:30:47 -060023from __future__ import print_function
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000024import os.path
25import subprocess
26import sys
27import doxybuild
28import subprocess
29import xml.etree.ElementTree as ElementTree
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +000030import shutil
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000031import urllib2
32import tempfile
33import os
34import time
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +000035from devtools import antglob, fixeol, tarball
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000036import amalgamate
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000037
38SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
39SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000040SCONS_LOCAL_URL = 'http://sourceforge.net/projects/scons/files/scons-local/1.2.0/scons-local-1.2.0.tar.gz/download'
41SOURCEFORGE_PROJECT = 'jsoncpp'
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000042
Christopher Dunn494950a2015-01-24 15:29:52 -060043def set_version(version):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000044 with open('version','wb') as f:
Christopher Dunn494950a2015-01-24 15:29:52 -060045 f.write(version.strip())
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000046
Christopher Dunn494950a2015-01-24 15:29:52 -060047def rmdir_if_exist(dir_path):
48 if os.path.isdir(dir_path):
49 shutil.rmtree(dir_path)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000050
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000051class SVNError(Exception):
52 pass
53
Christopher Dunn494950a2015-01-24 15:29:52 -060054def svn_command(command, *args):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000055 cmd = ['svn', '--non-interactive', command] + list(args)
Christopher Dunn494950a2015-01-24 15:29:52 -060056 print('Running:', ' '.join(cmd))
57 process = subprocess.Popen(cmd,
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000058 stdout=subprocess.PIPE,
Christopher Dunn494950a2015-01-24 15:29:52 -060059 stderr=subprocess.STDOUT)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000060 stdout = process.communicate()[0]
61 if process.returncode:
Christopher Dunn494950a2015-01-24 15:29:52 -060062 error = SVNError('SVN command failed:\n' + stdout)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000063 error.returncode = process.returncode
64 raise error
65 return stdout
66
67def check_no_pending_commit():
68 """Checks that there is no pending commit in the sandbox."""
Christopher Dunn494950a2015-01-24 15:29:52 -060069 stdout = svn_command('status', '--xml')
70 etree = ElementTree.fromstring(stdout)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000071 msg = []
Christopher Dunn494950a2015-01-24 15:29:52 -060072 for entry in etree.getiterator('entry'):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000073 path = entry.get('path')
74 status = entry.find('wc-status').get('item')
Baptiste Lepilleure6a77412010-03-11 21:02:26 +000075 if status != 'unversioned' and path != 'version':
Christopher Dunn494950a2015-01-24 15:29:52 -060076 msg.append('File "%s" has pending change (status="%s")' % (path, status))
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000077 if msg:
Christopher Dunn494950a2015-01-24 15:29:52 -060078 msg.insert(0, 'Pending change to commit found in sandbox. Commit them first!')
79 return '\n'.join(msg)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000080
Christopher Dunn494950a2015-01-24 15:29:52 -060081def svn_join_url(base_url, suffix):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000082 if not base_url.endswith('/'):
83 base_url += '/'
84 if suffix.startswith('/'):
85 suffix = suffix[1:]
86 return base_url + suffix
87
Christopher Dunn494950a2015-01-24 15:29:52 -060088def svn_check_if_tag_exist(tag_url):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000089 """Checks if a tag exist.
90 Returns: True if the tag exist, False otherwise.
91 """
92 try:
Christopher Dunn494950a2015-01-24 15:29:52 -060093 list_stdout = svn_command('list', tag_url)
Christopher Dunn9aa61442014-11-19 23:10:02 -060094 except SVNError as e:
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000095 if e.returncode != 1 or not str(e).find('tag_url'):
96 raise e
97 # otherwise ignore error, meaning tag does not exist
98 return False
99 return True
100
Christopher Dunn494950a2015-01-24 15:29:52 -0600101def svn_commit(message):
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000102 """Commit the sandbox, providing the specified comment.
103 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600104 svn_command('ci', '-m', message)
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000105
Christopher Dunn494950a2015-01-24 15:29:52 -0600106def svn_tag_sandbox(tag_url, message):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000107 """Makes a tag based on the sandbox revisions.
108 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600109 svn_command('copy', '-m', message, '.', tag_url)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000110
Christopher Dunn494950a2015-01-24 15:29:52 -0600111def svn_remove_tag(tag_url, message):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000112 """Removes an existing tag.
113 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600114 svn_command('delete', '-m', message, tag_url)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000115
Christopher Dunn494950a2015-01-24 15:29:52 -0600116def svn_export(tag_url, export_dir):
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +0000117 """Exports the tag_url revision to export_dir.
118 Target directory, including its parent is created if it does not exist.
119 If the directory export_dir exist, it is deleted before export proceed.
120 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600121 rmdir_if_exist(export_dir)
122 svn_command('export', tag_url, export_dir)
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +0000123
Christopher Dunn494950a2015-01-24 15:29:52 -0600124def fix_sources_eol(dist_dir):
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000125 """Set file EOL for tarball distribution.
126 """
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600127 print('Preparing exported source file EOL for distribution...')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000128 prune_dirs = antglob.prune_dirs + 'scons-local* ./build* ./libs ./dist'
Christopher Dunn494950a2015-01-24 15:29:52 -0600129 win_sources = antglob.glob(dist_dir,
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000130 includes = '**/*.sln **/*.vcproj',
Christopher Dunn494950a2015-01-24 15:29:52 -0600131 prune_dirs = prune_dirs)
132 unix_sources = antglob.glob(dist_dir,
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000133 includes = '''**/*.h **/*.cpp **/*.inl **/*.txt **/*.dox **/*.py **/*.html **/*.in
134 sconscript *.json *.expected AUTHORS LICENSE''',
135 excludes = antglob.default_excludes + 'scons.py sconsign.py scons-*',
Christopher Dunn494950a2015-01-24 15:29:52 -0600136 prune_dirs = prune_dirs)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000137 for path in win_sources:
Christopher Dunn494950a2015-01-24 15:29:52 -0600138 fixeol.fix_source_eol(path, is_dry_run = False, verbose = True, eol = '\r\n')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000139 for path in unix_sources:
Christopher Dunn494950a2015-01-24 15:29:52 -0600140 fixeol.fix_source_eol(path, is_dry_run = False, verbose = True, eol = '\n')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000141
Christopher Dunn494950a2015-01-24 15:29:52 -0600142def download(url, target_path):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000143 """Download file represented by url to target_path.
144 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600145 f = urllib2.urlopen(url)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000146 try:
147 data = f.read()
148 finally:
149 f.close()
Christopher Dunn494950a2015-01-24 15:29:52 -0600150 fout = open(target_path, 'wb')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000151 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600152 fout.write(data)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000153 finally:
154 fout.close()
155
Christopher Dunn494950a2015-01-24 15:29:52 -0600156def check_compile(distcheck_top_dir, platform):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000157 cmd = [sys.executable, 'scons.py', 'platform=%s' % platform, 'check']
Christopher Dunn494950a2015-01-24 15:29:52 -0600158 print('Running:', ' '.join(cmd))
159 log_path = os.path.join(distcheck_top_dir, 'build-%s.log' % platform)
160 flog = open(log_path, 'wb')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000161 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600162 process = subprocess.Popen(cmd,
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000163 stdout=flog,
164 stderr=subprocess.STDOUT,
Christopher Dunn494950a2015-01-24 15:29:52 -0600165 cwd=distcheck_top_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000166 stdout = process.communicate()[0]
167 status = (process.returncode == 0)
168 finally:
169 flog.close()
170 return (status, log_path)
171
Christopher Dunn494950a2015-01-24 15:29:52 -0600172def write_tempfile(content, **kwargs):
173 fd, path = tempfile.mkstemp(**kwargs)
174 f = os.fdopen(fd, 'wt')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000175 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600176 f.write(content)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000177 finally:
178 f.close()
179 return path
180
181class SFTPError(Exception):
182 pass
183
Christopher Dunn494950a2015-01-24 15:29:52 -0600184def run_sftp_batch(userhost, sftp, batch, retry=0):
185 path = write_tempfile(batch, suffix='.sftp', text=True)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000186 # psftp -agent -C blep,jsoncpp@web.sourceforge.net -batch -b batch.sftp -bc
187 cmd = [sftp, '-agent', '-C', '-batch', '-b', path, '-bc', userhost]
188 error = None
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600189 for retry_index in range(0, max(1,retry)):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000190 heading = retry_index == 0 and 'Running:' or 'Retrying:'
Christopher Dunn494950a2015-01-24 15:29:52 -0600191 print(heading, ' '.join(cmd))
192 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000193 stdout = process.communicate()[0]
194 if process.returncode != 0:
Christopher Dunn494950a2015-01-24 15:29:52 -0600195 error = SFTPError('SFTP batch failed:\n' + stdout)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000196 else:
197 break
198 if error:
199 raise error
200 return stdout
201
Christopher Dunn494950a2015-01-24 15:29:52 -0600202def sourceforge_web_synchro(sourceforge_project, doc_dir,
203 user=None, sftp='sftp'):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000204 """Notes: does not synchronize sub-directory of doc-dir.
205 """
206 userhost = '%s,%s@web.sourceforge.net' % (user, sourceforge_project)
Christopher Dunn494950a2015-01-24 15:29:52 -0600207 stdout = run_sftp_batch(userhost, sftp, """
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000208cd htdocs
209dir
210exit
Christopher Dunn494950a2015-01-24 15:29:52 -0600211""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000212 existing_paths = set()
213 collect = 0
214 for line in stdout.split('\n'):
215 line = line.strip()
216 if not collect and line.endswith('> dir'):
217 collect = True
218 elif collect and line.endswith('> exit'):
219 break
220 elif collect == 1:
221 collect = 2
222 elif collect == 2:
223 path = line.strip().split()[-1:]
224 if path and path[0] not in ('.', '..'):
Christopher Dunn494950a2015-01-24 15:29:52 -0600225 existing_paths.add(path[0])
226 upload_paths = set([os.path.basename(p) for p in antglob.glob(doc_dir)])
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000227 paths_to_remove = existing_paths - upload_paths
228 if paths_to_remove:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600229 print('Removing the following file from web:')
Christopher Dunn494950a2015-01-24 15:29:52 -0600230 print('\n'.join(paths_to_remove))
231 stdout = run_sftp_batch(userhost, sftp, """cd htdocs
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000232rm %s
Christopher Dunn494950a2015-01-24 15:29:52 -0600233exit""" % ' '.join(paths_to_remove))
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600234 print('Uploading %d files:' % len(upload_paths))
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000235 batch_size = 10
236 upload_paths = list(upload_paths)
237 start_time = time.time()
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600238 for index in range(0,len(upload_paths),batch_size):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000239 paths = upload_paths[index:index+batch_size]
240 file_per_sec = (time.time() - start_time) / (index+1)
241 remaining_files = len(upload_paths) - index
242 remaining_sec = file_per_sec * remaining_files
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600243 print('%d/%d, ETA=%.1fs' % (index+1, len(upload_paths), remaining_sec))
Christopher Dunn494950a2015-01-24 15:29:52 -0600244 run_sftp_batch(userhost, sftp, """cd htdocs
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000245lcd %s
246mput %s
Christopher Dunn494950a2015-01-24 15:29:52 -0600247exit""" % (doc_dir, ' '.join(paths)), retry=3)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000248
Christopher Dunn494950a2015-01-24 15:29:52 -0600249def sourceforge_release_tarball(sourceforge_project, paths, user=None, sftp='sftp'):
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000250 userhost = '%s,%s@frs.sourceforge.net' % (user, sourceforge_project)
Christopher Dunn494950a2015-01-24 15:29:52 -0600251 run_sftp_batch(userhost, sftp, """
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000252mput %s
253exit
Christopher Dunn494950a2015-01-24 15:29:52 -0600254""" % (' '.join(paths),))
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000255
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000256
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000257def main():
258 usage = """%prog release_version next_dev_version
259Update 'version' file to release_version and commit.
260Generates the document tarball.
261Tags the sandbox revision with release_version.
262Update 'version' file to next_dev_version and commit.
263
264Performs an svn export of tag release version, and build a source tarball.
265
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000266Must be started in the project top directory.
267
268Warning: --force should only be used when developping/testing the release script.
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000269"""
270 from optparse import OptionParser
271 parser = OptionParser(usage=usage)
272 parser.allow_interspersed_args = False
273 parser.add_option('--dot', dest="dot_path", action='store', default=doxybuild.find_program('dot'),
274 help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
275 parser.add_option('--doxygen', dest="doxygen_path", action='store', default=doxybuild.find_program('doxygen'),
276 help="""Path to Doxygen tool. [Default: %default]""")
277 parser.add_option('--force', dest="ignore_pending_commit", action='store_true', default=False,
278 help="""Ignore pending commit. [Default: %default]""")
279 parser.add_option('--retag', dest="retag_release", action='store_true', default=False,
280 help="""Overwrite release existing tag if it exist. [Default: %default]""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000281 parser.add_option('-p', '--platforms', dest="platforms", action='store', default='',
282 help="""Comma separated list of platform passed to scons for build check.""")
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000283 parser.add_option('--no-test', dest="no_test", action='store_true', default=False,
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000284 help="""Skips build check.""")
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000285 parser.add_option('--no-web', dest="no_web", action='store_true', default=False,
286 help="""Do not update web site.""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000287 parser.add_option('-u', '--upload-user', dest="user", action='store',
288 help="""Sourceforge user for SFTP documentation upload.""")
289 parser.add_option('--sftp', dest='sftp', action='store', default=doxybuild.find_program('psftp', 'sftp'),
290 help="""Path of the SFTP compatible binary used to upload the documentation.""")
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000291 parser.enable_interspersed_args()
292 options, args = parser.parse_args()
293
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000294 if len(args) != 2:
Christopher Dunn494950a2015-01-24 15:29:52 -0600295 parser.error('release_version missing on command-line.')
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000296 release_version = args[0]
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000297 next_version = args[1]
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000298
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000299 if not options.platforms and not options.no_test:
Christopher Dunn494950a2015-01-24 15:29:52 -0600300 parser.error('You must specify either --platform or --no-test option.')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000301
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000302 if options.ignore_pending_commit:
303 msg = ''
304 else:
305 msg = check_no_pending_commit()
306 if not msg:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600307 print('Setting version to', release_version)
Christopher Dunn494950a2015-01-24 15:29:52 -0600308 set_version(release_version)
309 svn_commit('Release ' + release_version)
310 tag_url = svn_join_url(SVN_TAG_ROOT, release_version)
311 if svn_check_if_tag_exist(tag_url):
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000312 if options.retag_release:
Christopher Dunn494950a2015-01-24 15:29:52 -0600313 svn_remove_tag(tag_url, 'Overwriting previous tag')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000314 else:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600315 print('Aborting, tag %s already exist. Use --retag to overwrite it!' % tag_url)
Christopher Dunn494950a2015-01-24 15:29:52 -0600316 sys.exit(1)
317 svn_tag_sandbox(tag_url, 'Release ' + release_version)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000318
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600319 print('Generated doxygen document...')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000320## doc_dirname = r'jsoncpp-api-html-0.5.0'
321## doc_tarball_path = r'e:\prg\vc\Lib\jsoncpp-trunk\dist\jsoncpp-api-html-0.5.0.tar.gz'
Christopher Dunn494950a2015-01-24 15:29:52 -0600322 doc_tarball_path, doc_dirname = doxybuild.build_doc(options, make_release=True)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000323 doc_distcheck_dir = 'dist/doccheck'
Christopher Dunn494950a2015-01-24 15:29:52 -0600324 tarball.decompress(doc_tarball_path, doc_distcheck_dir)
325 doc_distcheck_top_dir = os.path.join(doc_distcheck_dir, doc_dirname)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000326
327 export_dir = 'dist/export'
Christopher Dunn494950a2015-01-24 15:29:52 -0600328 svn_export(tag_url, export_dir)
329 fix_sources_eol(export_dir)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000330
331 source_dir = 'jsoncpp-src-' + release_version
332 source_tarball_path = 'dist/%s.tar.gz' % source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600333 print('Generating source tarball to', source_tarball_path)
Christopher Dunn494950a2015-01-24 15:29:52 -0600334 tarball.make_tarball(source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir)
Baptiste Lepilleur35bdc072010-02-24 08:05:41 +0000335
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000336 amalgamation_tarball_path = 'dist/%s-amalgamation.tar.gz' % source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600337 print('Generating amalgamation source tarball to', amalgamation_tarball_path)
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000338 amalgamation_dir = 'dist/amalgamation'
Christopher Dunn494950a2015-01-24 15:29:52 -0600339 amalgamate.amalgamate_source(export_dir, '%s/jsoncpp.cpp' % amalgamation_dir, 'json/json.h')
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000340 amalgamation_source_dir = 'jsoncpp-src-amalgamation' + release_version
Christopher Dunn494950a2015-01-24 15:29:52 -0600341 tarball.make_tarball(amalgamation_tarball_path, [amalgamation_dir],
342 amalgamation_dir, prefix_dir=amalgamation_source_dir)
Baptiste Lepilleurbafb43c2011-05-01 20:36:55 +0000343
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000344 # Decompress source tarball, download and install scons-local
Baptiste Lepilleur35bdc072010-02-24 08:05:41 +0000345 distcheck_dir = 'dist/distcheck'
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000346 distcheck_top_dir = distcheck_dir + '/' + source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600347 print('Decompressing source tarball to', distcheck_dir)
Christopher Dunn494950a2015-01-24 15:29:52 -0600348 rmdir_if_exist(distcheck_dir)
349 tarball.decompress(source_tarball_path, distcheck_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000350 scons_local_path = 'dist/scons-local.tar.gz'
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600351 print('Downloading scons-local to', scons_local_path)
Christopher Dunn494950a2015-01-24 15:29:52 -0600352 download(SCONS_LOCAL_URL, scons_local_path)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600353 print('Decompressing scons-local to', distcheck_top_dir)
Christopher Dunn494950a2015-01-24 15:29:52 -0600354 tarball.decompress(scons_local_path, distcheck_top_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000355
356 # Run compilation
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600357 print('Compiling decompressed tarball')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000358 all_build_status = True
359 for platform in options.platforms.split(','):
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600360 print('Testing platform:', platform)
Christopher Dunn494950a2015-01-24 15:29:52 -0600361 build_status, log_path = check_compile(distcheck_top_dir, platform)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600362 print('see build log:', log_path)
363 print(build_status and '=> ok' or '=> FAILED')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000364 all_build_status = all_build_status and build_status
365 if not build_status:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600366 print('Testing failed on at least one platform, aborting...')
Christopher Dunn494950a2015-01-24 15:29:52 -0600367 svn_remove_tag(tag_url, 'Removing tag due to failed testing')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000368 sys.exit(1)
369 if options.user:
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000370 if not options.no_web:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600371 print('Uploading documentation using user', options.user)
Christopher Dunn494950a2015-01-24 15:29:52 -0600372 sourceforge_web_synchro(SOURCEFORGE_PROJECT, doc_distcheck_top_dir, user=options.user, sftp=options.sftp)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600373 print('Completed documentation upload')
374 print('Uploading source and documentation tarballs for release using user', options.user)
Christopher Dunn494950a2015-01-24 15:29:52 -0600375 sourceforge_release_tarball(SOURCEFORGE_PROJECT,
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000376 [source_tarball_path, doc_tarball_path],
Christopher Dunn494950a2015-01-24 15:29:52 -0600377 user=options.user, sftp=options.sftp)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600378 print('Source and doc release tarballs uploaded')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000379 else:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600380 print('No upload user specified. Web site and download tarbal were not uploaded.')
381 print('Tarball can be found at:', doc_tarball_path)
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000382
383 # Set next version number and commit
Christopher Dunn494950a2015-01-24 15:29:52 -0600384 set_version(next_version)
385 svn_commit('Released ' + release_version)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000386 else:
Christopher Dunn494950a2015-01-24 15:29:52 -0600387 sys.stderr.write(msg + '\n')
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000388
389if __name__ == '__main__':
390 main()