blob: b7235db6cde45cc6d5dc0f0810c96216aca4f29d [file] [log] [blame]
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +00001"""Tag the sandbox for release, make source and doc tarballs.
2
3Requires Python 2.6
4
5Example of invocation (use to test the script):
Baptiste Lepilleure1b26452010-03-13 10:59:50 +00006python makerelease.py --platform=msvc6,msvc71,msvc80,msvc90,mingw -ublep 0.6.0 0.7.0-dev
Baptiste Lepilleurcd6cb5d2010-03-13 07:59:07 +00007
8When testing this script:
Baptiste Lepilleurbafb43c2011-05-01 20:36:55 +00009python 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 +000010
11Example of invocation when doing a release:
12python makerelease.py 0.5.0 0.6.0-dev
Christopher Dunnb7894972014-09-10 18:01:10 -070013
14Note: This was for Subversion. Now that we are in GitHub, we do not
15need to build versioned tarballs anymore, so makerelease.py is defunct.
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000016"""
Christopher Dunnbd1e8952014-11-19 23:30:47 -060017from __future__ import print_function
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000018import os.path
19import subprocess
20import sys
21import doxybuild
22import subprocess
23import xml.etree.ElementTree as ElementTree
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +000024import shutil
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000025import urllib2
26import tempfile
27import os
28import time
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +000029from devtools import antglob, fixeol, tarball
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000030import amalgamate
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000031
32SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
33SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000034SCONS_LOCAL_URL = 'http://sourceforge.net/projects/scons/files/scons-local/1.2.0/scons-local-1.2.0.tar.gz/download'
35SOURCEFORGE_PROJECT = 'jsoncpp'
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000036
Christopher Dunn494950a2015-01-24 15:29:52 -060037def set_version(version):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000038 with open('version','wb') as f:
Christopher Dunn494950a2015-01-24 15:29:52 -060039 f.write(version.strip())
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000040
Christopher Dunn494950a2015-01-24 15:29:52 -060041def rmdir_if_exist(dir_path):
42 if os.path.isdir(dir_path):
43 shutil.rmtree(dir_path)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +000044
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000045class SVNError(Exception):
46 pass
47
Christopher Dunn494950a2015-01-24 15:29:52 -060048def svn_command(command, *args):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000049 cmd = ['svn', '--non-interactive', command] + list(args)
Christopher Dunn494950a2015-01-24 15:29:52 -060050 print('Running:', ' '.join(cmd))
51 process = subprocess.Popen(cmd,
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000052 stdout=subprocess.PIPE,
Christopher Dunn494950a2015-01-24 15:29:52 -060053 stderr=subprocess.STDOUT)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000054 stdout = process.communicate()[0]
55 if process.returncode:
Christopher Dunn494950a2015-01-24 15:29:52 -060056 error = SVNError('SVN command failed:\n' + stdout)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000057 error.returncode = process.returncode
58 raise error
59 return stdout
60
61def check_no_pending_commit():
62 """Checks that there is no pending commit in the sandbox."""
Christopher Dunn494950a2015-01-24 15:29:52 -060063 stdout = svn_command('status', '--xml')
64 etree = ElementTree.fromstring(stdout)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000065 msg = []
Christopher Dunn494950a2015-01-24 15:29:52 -060066 for entry in etree.getiterator('entry'):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000067 path = entry.get('path')
68 status = entry.find('wc-status').get('item')
Baptiste Lepilleure6a77412010-03-11 21:02:26 +000069 if status != 'unversioned' and path != 'version':
Christopher Dunn494950a2015-01-24 15:29:52 -060070 msg.append('File "%s" has pending change (status="%s")' % (path, status))
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000071 if msg:
Christopher Dunn494950a2015-01-24 15:29:52 -060072 msg.insert(0, 'Pending change to commit found in sandbox. Commit them first!')
73 return '\n'.join(msg)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000074
Christopher Dunn494950a2015-01-24 15:29:52 -060075def svn_join_url(base_url, suffix):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000076 if not base_url.endswith('/'):
77 base_url += '/'
78 if suffix.startswith('/'):
79 suffix = suffix[1:]
80 return base_url + suffix
81
Christopher Dunn494950a2015-01-24 15:29:52 -060082def svn_check_if_tag_exist(tag_url):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000083 """Checks if a tag exist.
84 Returns: True if the tag exist, False otherwise.
85 """
86 try:
Christopher Dunn494950a2015-01-24 15:29:52 -060087 list_stdout = svn_command('list', tag_url)
Christopher Dunn9aa61442014-11-19 23:10:02 -060088 except SVNError as e:
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +000089 if e.returncode != 1 or not str(e).find('tag_url'):
90 raise e
91 # otherwise ignore error, meaning tag does not exist
92 return False
93 return True
94
Christopher Dunn494950a2015-01-24 15:29:52 -060095def svn_commit(message):
Baptiste Lepilleure6a77412010-03-11 21:02:26 +000096 """Commit the sandbox, providing the specified comment.
97 """
Christopher Dunn494950a2015-01-24 15:29:52 -060098 svn_command('ci', '-m', message)
Baptiste Lepilleure6a77412010-03-11 21:02:26 +000099
Christopher Dunn494950a2015-01-24 15:29:52 -0600100def svn_tag_sandbox(tag_url, message):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000101 """Makes a tag based on the sandbox revisions.
102 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600103 svn_command('copy', '-m', message, '.', tag_url)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000104
Christopher Dunn494950a2015-01-24 15:29:52 -0600105def svn_remove_tag(tag_url, message):
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000106 """Removes an existing tag.
107 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600108 svn_command('delete', '-m', message, tag_url)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000109
Christopher Dunn494950a2015-01-24 15:29:52 -0600110def svn_export(tag_url, export_dir):
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +0000111 """Exports the tag_url revision to export_dir.
112 Target directory, including its parent is created if it does not exist.
113 If the directory export_dir exist, it is deleted before export proceed.
114 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600115 rmdir_if_exist(export_dir)
116 svn_command('export', tag_url, export_dir)
Baptiste Lepilleur7c171ee2010-02-23 08:44:52 +0000117
Christopher Dunn494950a2015-01-24 15:29:52 -0600118def fix_sources_eol(dist_dir):
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000119 """Set file EOL for tarball distribution.
120 """
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600121 print('Preparing exported source file EOL for distribution...')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000122 prune_dirs = antglob.prune_dirs + 'scons-local* ./build* ./libs ./dist'
Christopher Dunn494950a2015-01-24 15:29:52 -0600123 win_sources = antglob.glob(dist_dir,
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000124 includes = '**/*.sln **/*.vcproj',
Christopher Dunn494950a2015-01-24 15:29:52 -0600125 prune_dirs = prune_dirs)
126 unix_sources = antglob.glob(dist_dir,
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000127 includes = '''**/*.h **/*.cpp **/*.inl **/*.txt **/*.dox **/*.py **/*.html **/*.in
128 sconscript *.json *.expected AUTHORS LICENSE''',
129 excludes = antglob.default_excludes + 'scons.py sconsign.py scons-*',
Christopher Dunn494950a2015-01-24 15:29:52 -0600130 prune_dirs = prune_dirs)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000131 for path in win_sources:
Christopher Dunn494950a2015-01-24 15:29:52 -0600132 fixeol.fix_source_eol(path, is_dry_run = False, verbose = True, eol = '\r\n')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000133 for path in unix_sources:
Christopher Dunn494950a2015-01-24 15:29:52 -0600134 fixeol.fix_source_eol(path, is_dry_run = False, verbose = True, eol = '\n')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000135
Christopher Dunn494950a2015-01-24 15:29:52 -0600136def download(url, target_path):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000137 """Download file represented by url to target_path.
138 """
Christopher Dunn494950a2015-01-24 15:29:52 -0600139 f = urllib2.urlopen(url)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000140 try:
141 data = f.read()
142 finally:
143 f.close()
Christopher Dunn494950a2015-01-24 15:29:52 -0600144 fout = open(target_path, 'wb')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000145 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600146 fout.write(data)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000147 finally:
148 fout.close()
149
Christopher Dunn494950a2015-01-24 15:29:52 -0600150def check_compile(distcheck_top_dir, platform):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000151 cmd = [sys.executable, 'scons.py', 'platform=%s' % platform, 'check']
Christopher Dunn494950a2015-01-24 15:29:52 -0600152 print('Running:', ' '.join(cmd))
153 log_path = os.path.join(distcheck_top_dir, 'build-%s.log' % platform)
154 flog = open(log_path, 'wb')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000155 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600156 process = subprocess.Popen(cmd,
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000157 stdout=flog,
158 stderr=subprocess.STDOUT,
Christopher Dunn494950a2015-01-24 15:29:52 -0600159 cwd=distcheck_top_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000160 stdout = process.communicate()[0]
161 status = (process.returncode == 0)
162 finally:
163 flog.close()
164 return (status, log_path)
165
Christopher Dunn494950a2015-01-24 15:29:52 -0600166def write_tempfile(content, **kwargs):
167 fd, path = tempfile.mkstemp(**kwargs)
168 f = os.fdopen(fd, 'wt')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000169 try:
Christopher Dunn494950a2015-01-24 15:29:52 -0600170 f.write(content)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000171 finally:
172 f.close()
173 return path
174
175class SFTPError(Exception):
176 pass
177
Christopher Dunn494950a2015-01-24 15:29:52 -0600178def run_sftp_batch(userhost, sftp, batch, retry=0):
179 path = write_tempfile(batch, suffix='.sftp', text=True)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000180 # psftp -agent -C blep,jsoncpp@web.sourceforge.net -batch -b batch.sftp -bc
181 cmd = [sftp, '-agent', '-C', '-batch', '-b', path, '-bc', userhost]
182 error = None
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600183 for retry_index in range(0, max(1,retry)):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000184 heading = retry_index == 0 and 'Running:' or 'Retrying:'
Christopher Dunn494950a2015-01-24 15:29:52 -0600185 print(heading, ' '.join(cmd))
186 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000187 stdout = process.communicate()[0]
188 if process.returncode != 0:
Christopher Dunn494950a2015-01-24 15:29:52 -0600189 error = SFTPError('SFTP batch failed:\n' + stdout)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000190 else:
191 break
192 if error:
193 raise error
194 return stdout
195
Christopher Dunn494950a2015-01-24 15:29:52 -0600196def sourceforge_web_synchro(sourceforge_project, doc_dir,
197 user=None, sftp='sftp'):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000198 """Notes: does not synchronize sub-directory of doc-dir.
199 """
200 userhost = '%s,%s@web.sourceforge.net' % (user, sourceforge_project)
Christopher Dunn494950a2015-01-24 15:29:52 -0600201 stdout = run_sftp_batch(userhost, sftp, """
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000202cd htdocs
203dir
204exit
Christopher Dunn494950a2015-01-24 15:29:52 -0600205""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000206 existing_paths = set()
207 collect = 0
208 for line in stdout.split('\n'):
209 line = line.strip()
210 if not collect and line.endswith('> dir'):
211 collect = True
212 elif collect and line.endswith('> exit'):
213 break
214 elif collect == 1:
215 collect = 2
216 elif collect == 2:
217 path = line.strip().split()[-1:]
218 if path and path[0] not in ('.', '..'):
Christopher Dunn494950a2015-01-24 15:29:52 -0600219 existing_paths.add(path[0])
220 upload_paths = set([os.path.basename(p) for p in antglob.glob(doc_dir)])
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000221 paths_to_remove = existing_paths - upload_paths
222 if paths_to_remove:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600223 print('Removing the following file from web:')
Christopher Dunn494950a2015-01-24 15:29:52 -0600224 print('\n'.join(paths_to_remove))
225 stdout = run_sftp_batch(userhost, sftp, """cd htdocs
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000226rm %s
Christopher Dunn494950a2015-01-24 15:29:52 -0600227exit""" % ' '.join(paths_to_remove))
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600228 print('Uploading %d files:' % len(upload_paths))
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000229 batch_size = 10
230 upload_paths = list(upload_paths)
231 start_time = time.time()
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600232 for index in range(0,len(upload_paths),batch_size):
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000233 paths = upload_paths[index:index+batch_size]
234 file_per_sec = (time.time() - start_time) / (index+1)
235 remaining_files = len(upload_paths) - index
236 remaining_sec = file_per_sec * remaining_files
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600237 print('%d/%d, ETA=%.1fs' % (index+1, len(upload_paths), remaining_sec))
Christopher Dunn494950a2015-01-24 15:29:52 -0600238 run_sftp_batch(userhost, sftp, """cd htdocs
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000239lcd %s
240mput %s
Christopher Dunn494950a2015-01-24 15:29:52 -0600241exit""" % (doc_dir, ' '.join(paths)), retry=3)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000242
Christopher Dunn494950a2015-01-24 15:29:52 -0600243def sourceforge_release_tarball(sourceforge_project, paths, user=None, sftp='sftp'):
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000244 userhost = '%s,%s@frs.sourceforge.net' % (user, sourceforge_project)
Christopher Dunn494950a2015-01-24 15:29:52 -0600245 run_sftp_batch(userhost, sftp, """
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000246mput %s
247exit
Christopher Dunn494950a2015-01-24 15:29:52 -0600248""" % (' '.join(paths),))
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000249
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000250
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000251def main():
252 usage = """%prog release_version next_dev_version
253Update 'version' file to release_version and commit.
254Generates the document tarball.
255Tags the sandbox revision with release_version.
256Update 'version' file to next_dev_version and commit.
257
258Performs an svn export of tag release version, and build a source tarball.
259
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000260Must be started in the project top directory.
261
262Warning: --force should only be used when developping/testing the release script.
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000263"""
264 from optparse import OptionParser
265 parser = OptionParser(usage=usage)
266 parser.allow_interspersed_args = False
267 parser.add_option('--dot', dest="dot_path", action='store', default=doxybuild.find_program('dot'),
268 help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
269 parser.add_option('--doxygen', dest="doxygen_path", action='store', default=doxybuild.find_program('doxygen'),
270 help="""Path to Doxygen tool. [Default: %default]""")
271 parser.add_option('--force', dest="ignore_pending_commit", action='store_true', default=False,
272 help="""Ignore pending commit. [Default: %default]""")
273 parser.add_option('--retag', dest="retag_release", action='store_true', default=False,
274 help="""Overwrite release existing tag if it exist. [Default: %default]""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000275 parser.add_option('-p', '--platforms', dest="platforms", action='store', default='',
276 help="""Comma separated list of platform passed to scons for build check.""")
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000277 parser.add_option('--no-test', dest="no_test", action='store_true', default=False,
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000278 help="""Skips build check.""")
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000279 parser.add_option('--no-web', dest="no_web", action='store_true', default=False,
280 help="""Do not update web site.""")
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000281 parser.add_option('-u', '--upload-user', dest="user", action='store',
282 help="""Sourceforge user for SFTP documentation upload.""")
283 parser.add_option('--sftp', dest='sftp', action='store', default=doxybuild.find_program('psftp', 'sftp'),
284 help="""Path of the SFTP compatible binary used to upload the documentation.""")
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000285 parser.enable_interspersed_args()
286 options, args = parser.parse_args()
287
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000288 if len(args) != 2:
Christopher Dunn494950a2015-01-24 15:29:52 -0600289 parser.error('release_version missing on command-line.')
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000290 release_version = args[0]
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000291 next_version = args[1]
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000292
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000293 if not options.platforms and not options.no_test:
Christopher Dunn494950a2015-01-24 15:29:52 -0600294 parser.error('You must specify either --platform or --no-test option.')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000295
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000296 if options.ignore_pending_commit:
297 msg = ''
298 else:
299 msg = check_no_pending_commit()
300 if not msg:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600301 print('Setting version to', release_version)
Christopher Dunn494950a2015-01-24 15:29:52 -0600302 set_version(release_version)
303 svn_commit('Release ' + release_version)
304 tag_url = svn_join_url(SVN_TAG_ROOT, release_version)
305 if svn_check_if_tag_exist(tag_url):
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000306 if options.retag_release:
Christopher Dunn494950a2015-01-24 15:29:52 -0600307 svn_remove_tag(tag_url, 'Overwriting previous tag')
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000308 else:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600309 print('Aborting, tag %s already exist. Use --retag to overwrite it!' % tag_url)
Christopher Dunn494950a2015-01-24 15:29:52 -0600310 sys.exit(1)
311 svn_tag_sandbox(tag_url, 'Release ' + release_version)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000312
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600313 print('Generated doxygen document...')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000314## doc_dirname = r'jsoncpp-api-html-0.5.0'
315## 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 -0600316 doc_tarball_path, doc_dirname = doxybuild.build_doc(options, make_release=True)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000317 doc_distcheck_dir = 'dist/doccheck'
Christopher Dunn494950a2015-01-24 15:29:52 -0600318 tarball.decompress(doc_tarball_path, doc_distcheck_dir)
319 doc_distcheck_top_dir = os.path.join(doc_distcheck_dir, doc_dirname)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000320
321 export_dir = 'dist/export'
Christopher Dunn494950a2015-01-24 15:29:52 -0600322 svn_export(tag_url, export_dir)
323 fix_sources_eol(export_dir)
Baptiste Lepilleure94d2f42010-02-23 21:00:30 +0000324
325 source_dir = 'jsoncpp-src-' + release_version
326 source_tarball_path = 'dist/%s.tar.gz' % source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600327 print('Generating source tarball to', source_tarball_path)
Christopher Dunn494950a2015-01-24 15:29:52 -0600328 tarball.make_tarball(source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir)
Baptiste Lepilleur35bdc072010-02-24 08:05:41 +0000329
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000330 amalgamation_tarball_path = 'dist/%s-amalgamation.tar.gz' % source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600331 print('Generating amalgamation source tarball to', amalgamation_tarball_path)
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000332 amalgamation_dir = 'dist/amalgamation'
Christopher Dunn494950a2015-01-24 15:29:52 -0600333 amalgamate.amalgamate_source(export_dir, '%s/jsoncpp.cpp' % amalgamation_dir, 'json/json.h')
Baptiste Lepilleureadc4782011-05-02 21:09:30 +0000334 amalgamation_source_dir = 'jsoncpp-src-amalgamation' + release_version
Christopher Dunn494950a2015-01-24 15:29:52 -0600335 tarball.make_tarball(amalgamation_tarball_path, [amalgamation_dir],
336 amalgamation_dir, prefix_dir=amalgamation_source_dir)
Baptiste Lepilleurbafb43c2011-05-01 20:36:55 +0000337
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000338 # Decompress source tarball, download and install scons-local
Baptiste Lepilleur35bdc072010-02-24 08:05:41 +0000339 distcheck_dir = 'dist/distcheck'
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000340 distcheck_top_dir = distcheck_dir + '/' + source_dir
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600341 print('Decompressing source tarball to', distcheck_dir)
Christopher Dunn494950a2015-01-24 15:29:52 -0600342 rmdir_if_exist(distcheck_dir)
343 tarball.decompress(source_tarball_path, distcheck_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000344 scons_local_path = 'dist/scons-local.tar.gz'
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600345 print('Downloading scons-local to', scons_local_path)
Christopher Dunn494950a2015-01-24 15:29:52 -0600346 download(SCONS_LOCAL_URL, scons_local_path)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600347 print('Decompressing scons-local to', distcheck_top_dir)
Christopher Dunn494950a2015-01-24 15:29:52 -0600348 tarball.decompress(scons_local_path, distcheck_top_dir)
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000349
350 # Run compilation
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600351 print('Compiling decompressed tarball')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000352 all_build_status = True
353 for platform in options.platforms.split(','):
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600354 print('Testing platform:', platform)
Christopher Dunn494950a2015-01-24 15:29:52 -0600355 build_status, log_path = check_compile(distcheck_top_dir, platform)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600356 print('see build log:', log_path)
357 print(build_status and '=> ok' or '=> FAILED')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000358 all_build_status = all_build_status and build_status
359 if not build_status:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600360 print('Testing failed on at least one platform, aborting...')
Christopher Dunn494950a2015-01-24 15:29:52 -0600361 svn_remove_tag(tag_url, 'Removing tag due to failed testing')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000362 sys.exit(1)
363 if options.user:
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000364 if not options.no_web:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600365 print('Uploading documentation using user', options.user)
Christopher Dunn494950a2015-01-24 15:29:52 -0600366 sourceforge_web_synchro(SOURCEFORGE_PROJECT, doc_distcheck_top_dir, user=options.user, sftp=options.sftp)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600367 print('Completed documentation upload')
368 print('Uploading source and documentation tarballs for release using user', options.user)
Christopher Dunn494950a2015-01-24 15:29:52 -0600369 sourceforge_release_tarball(SOURCEFORGE_PROJECT,
Baptiste Lepilleurd89d7962010-02-25 08:30:09 +0000370 [source_tarball_path, doc_tarball_path],
Christopher Dunn494950a2015-01-24 15:29:52 -0600371 user=options.user, sftp=options.sftp)
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600372 print('Source and doc release tarballs uploaded')
Baptiste Lepilleur64ba0622010-02-24 23:08:47 +0000373 else:
Christopher Dunnbd1e8952014-11-19 23:30:47 -0600374 print('No upload user specified. Web site and download tarbal were not uploaded.')
375 print('Tarball can be found at:', doc_tarball_path)
Baptiste Lepilleure6a77412010-03-11 21:02:26 +0000376
377 # Set next version number and commit
Christopher Dunn494950a2015-01-24 15:29:52 -0600378 set_version(next_version)
379 svn_commit('Released ' + release_version)
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000380 else:
Christopher Dunn494950a2015-01-24 15:29:52 -0600381 sys.stderr.write(msg + '\n')
Baptiste Lepilleur1f4847c2010-02-23 07:57:38 +0000382
383if __name__ == '__main__':
384 main()