mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 10:03:51 +01:00
- added (incomplete) script makerelease.py to handle svn tagging and tar balls generation
This commit is contained in:
parent
35503e5917
commit
1f4847cbd9
86
doxybuild.py
86
doxybuild.py
@ -89,14 +89,14 @@ def do_subst_in_file(targetfile, sourcefile, dict):
|
|||||||
print "Can't write target file %s"%targetfile
|
print "Can't write target file %s"%targetfile
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def run_doxygen(doxygen_path, config_file, working_dir):
|
def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
|
||||||
config_file = os.path.abspath( config_file )
|
config_file = os.path.abspath( config_file )
|
||||||
doxygen_path = doxygen_path
|
doxygen_path = doxygen_path
|
||||||
old_cwd = os.getcwd()
|
old_cwd = os.getcwd()
|
||||||
try:
|
try:
|
||||||
os.chdir( working_dir )
|
os.chdir( working_dir )
|
||||||
cmd = [doxygen_path, config_file]
|
cmd = [doxygen_path, config_file]
|
||||||
print ' '.join( cmd )
|
print 'Running:', ' '.join( cmd )
|
||||||
try:
|
try:
|
||||||
import subprocess
|
import subprocess
|
||||||
except:
|
except:
|
||||||
@ -104,40 +104,27 @@ def run_doxygen(doxygen_path, config_file, working_dir):
|
|||||||
print 'Documentation generation failed'
|
print 'Documentation generation failed'
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
if is_silent:
|
||||||
subprocess.check_call( cmd )
|
process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
|
||||||
except subprocess.CalledProcessError:
|
else:
|
||||||
|
process = subprocess.Popen( cmd )
|
||||||
|
stdout, _ = process.communicate()
|
||||||
|
if process.returncode:
|
||||||
|
print 'Documentation generation failed:'
|
||||||
|
print stdout
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
finally:
|
finally:
|
||||||
os.chdir( old_cwd )
|
os.chdir( old_cwd )
|
||||||
|
|
||||||
def main():
|
def build_doc( options, make_release=False ):
|
||||||
usage = """%prog
|
if make_release:
|
||||||
Generates doxygen documentation in build/doxygen.
|
options.make_tarball = True
|
||||||
Optionaly makes a tarball of the documentation to dist/.
|
options.with_dot = True
|
||||||
|
options.with_html_help = True
|
||||||
Must be started in the project top directory.
|
options.with_uml_look = True
|
||||||
"""
|
options.open = False
|
||||||
from optparse import OptionParser
|
options.silent = True
|
||||||
parser = OptionParser(usage=usage)
|
|
||||||
parser.allow_interspersed_args = False
|
|
||||||
parser.add_option('--with-dot', dest="with_dot", action='store_true', default=False,
|
|
||||||
help="""Enable usage of DOT to generate collaboration diagram""")
|
|
||||||
parser.add_option('--dot', dest="dot_path", action='store', default=find_program('dot'),
|
|
||||||
help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
|
|
||||||
parser.add_option('--doxygen', dest="doxygen_path", action='store', default=find_program('doxygen'),
|
|
||||||
help="""Path to Doxygen tool. [Default: %default]""")
|
|
||||||
parser.add_option('--with-html-help', dest="with_html_help", action='store_true', default=False,
|
|
||||||
help="""Enable generation of Microsoft HTML HELP""")
|
|
||||||
parser.add_option('--no-uml-look', dest="with_uml_look", action='store_false', default=True,
|
|
||||||
help="""Generates DOT graph without UML look [Default: False]""")
|
|
||||||
parser.add_option('--open', dest="open", action='store_true', default=False,
|
|
||||||
help="""Open the HTML index in the web browser after generation""")
|
|
||||||
parser.add_option('--tarball', dest="make_tarball", action='store_true', default=False,
|
|
||||||
help="""Generates a tarball of the documentation in dist/ directory""")
|
|
||||||
parser.enable_interspersed_args()
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
version = open('version','rt').read().strip()
|
version = open('version','rt').read().strip()
|
||||||
output_dir = '../build/doxygen' # relative to doc/doxyfile location.
|
output_dir = '../build/doxygen' # relative to doc/doxyfile location.
|
||||||
@ -167,10 +154,9 @@ def main():
|
|||||||
os.makedirs( full_output_dir )
|
os.makedirs( full_output_dir )
|
||||||
|
|
||||||
do_subst_in_file( 'doc/doxyfile', 'doc/doxyfile.in', subst_keys )
|
do_subst_in_file( 'doc/doxyfile', 'doc/doxyfile.in', subst_keys )
|
||||||
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc' )
|
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent )
|
||||||
print open(os.path.join('doc', warning_log_path), 'rb').read()
|
if not options.silent:
|
||||||
if not ok:
|
print open(os.path.join('doc', warning_log_path), 'rb').read()
|
||||||
print 'Doxygen generation failed'
|
|
||||||
index_path = os.path.abspath(os.path.join(subst_keys['%HTML_OUTPUT%'], 'index.html'))
|
index_path = os.path.abspath(os.path.join(subst_keys['%HTML_OUTPUT%'], 'index.html'))
|
||||||
print 'Generated documentation can be found in:'
|
print 'Generated documentation can be found in:'
|
||||||
print index_path
|
print index_path
|
||||||
@ -187,5 +173,35 @@ def main():
|
|||||||
tarball_basedir = os.path.join( full_output_dir, html_output_dirname )
|
tarball_basedir = os.path.join( full_output_dir, html_output_dirname )
|
||||||
make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
|
make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname )
|
||||||
|
|
||||||
|
def main():
|
||||||
|
usage = """%prog
|
||||||
|
Generates doxygen documentation in build/doxygen.
|
||||||
|
Optionaly makes a tarball of the documentation to dist/.
|
||||||
|
|
||||||
|
Must be started in the project top directory.
|
||||||
|
"""
|
||||||
|
from optparse import OptionParser
|
||||||
|
parser = OptionParser(usage=usage)
|
||||||
|
parser.allow_interspersed_args = False
|
||||||
|
parser.add_option('--with-dot', dest="with_dot", action='store_true', default=False,
|
||||||
|
help="""Enable usage of DOT to generate collaboration diagram""")
|
||||||
|
parser.add_option('--dot', dest="dot_path", action='store', default=find_program('dot'),
|
||||||
|
help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
|
||||||
|
parser.add_option('--doxygen', dest="doxygen_path", action='store', default=find_program('doxygen'),
|
||||||
|
help="""Path to Doxygen tool. [Default: %default]""")
|
||||||
|
parser.add_option('--with-html-help', dest="with_html_help", action='store_true', default=False,
|
||||||
|
help="""Enable generation of Microsoft HTML HELP""")
|
||||||
|
parser.add_option('--no-uml-look', dest="with_uml_look", action='store_false', default=True,
|
||||||
|
help="""Generates DOT graph without UML look [Default: False]""")
|
||||||
|
parser.add_option('--open', dest="open", action='store_true', default=False,
|
||||||
|
help="""Open the HTML index in the web browser after generation""")
|
||||||
|
parser.add_option('--tarball', dest="make_tarball", action='store_true', default=False,
|
||||||
|
help="""Generates a tarball of the documentation in dist/ directory""")
|
||||||
|
parser.add_option('-s', '--silent', dest="silent", action='store_true', default=False,
|
||||||
|
help="""Hides doxygen output""")
|
||||||
|
parser.enable_interspersed_args()
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
build_doc( options )
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
141
makerelease.py
Normal file
141
makerelease.py
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
"""Tag the sandbox for release, make source and doc tarballs.
|
||||||
|
|
||||||
|
Requires Python 2.6
|
||||||
|
|
||||||
|
Example of invocation (use to test the script):
|
||||||
|
python makerelease.py --force --retag 0.5.0 0.6.0-dev
|
||||||
|
|
||||||
|
Example of invocation when doing a release:
|
||||||
|
python makerelease.py 0.5.0 0.6.0-dev
|
||||||
|
"""
|
||||||
|
import os.path
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import doxybuild
|
||||||
|
import subprocess
|
||||||
|
import xml.etree.ElementTree as ElementTree
|
||||||
|
|
||||||
|
SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
|
||||||
|
SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
|
||||||
|
|
||||||
|
def set_version( version ):
|
||||||
|
with open('version','wb') as f:
|
||||||
|
f.write( version.strip() )
|
||||||
|
|
||||||
|
class SVNError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def svn_command( command, *args ):
|
||||||
|
cmd = ['svn', '--non-interactive', command] + list(args)
|
||||||
|
print 'Running:', ' '.join( cmd )
|
||||||
|
process = subprocess.Popen( cmd,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT )
|
||||||
|
stdout = process.communicate()[0]
|
||||||
|
if process.returncode:
|
||||||
|
error = SVNError( 'SVN command failed:\n' + stdout )
|
||||||
|
error.returncode = process.returncode
|
||||||
|
raise error
|
||||||
|
return stdout
|
||||||
|
|
||||||
|
def check_no_pending_commit():
|
||||||
|
"""Checks that there is no pending commit in the sandbox."""
|
||||||
|
stdout = svn_command( 'status', '--xml' )
|
||||||
|
etree = ElementTree.fromstring( stdout )
|
||||||
|
msg = []
|
||||||
|
for entry in etree.getiterator( 'entry' ):
|
||||||
|
path = entry.get('path')
|
||||||
|
status = entry.find('wc-status').get('item')
|
||||||
|
if status != 'unversioned':
|
||||||
|
msg.append( 'File "%s" has pending change (status="%s")' % (path, status) )
|
||||||
|
if msg:
|
||||||
|
msg.insert(0, 'Pending change to commit found in sandbox. Commit them first!' )
|
||||||
|
return '\n'.join( msg )
|
||||||
|
|
||||||
|
def svn_join_url( base_url, suffix ):
|
||||||
|
if not base_url.endswith('/'):
|
||||||
|
base_url += '/'
|
||||||
|
if suffix.startswith('/'):
|
||||||
|
suffix = suffix[1:]
|
||||||
|
return base_url + suffix
|
||||||
|
|
||||||
|
def svn_check_if_tag_exist( tag_url ):
|
||||||
|
"""Checks if a tag exist.
|
||||||
|
Returns: True if the tag exist, False otherwise.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
list_stdout = svn_command( 'list', tag_url )
|
||||||
|
except SVNError, e:
|
||||||
|
if e.returncode != 1 or not str(e).find('tag_url'):
|
||||||
|
raise e
|
||||||
|
# otherwise ignore error, meaning tag does not exist
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def svn_tag_sandbox( tag_url, message ):
|
||||||
|
"""Makes a tag based on the sandbox revisions.
|
||||||
|
"""
|
||||||
|
svn_command( 'copy', '-m', message, '.', tag_url )
|
||||||
|
|
||||||
|
def svn_remove_tag( tag_url, message ):
|
||||||
|
"""Removes an existing tag.
|
||||||
|
"""
|
||||||
|
svn_command( 'delete', '-m', message, tag_url )
|
||||||
|
|
||||||
|
def main():
|
||||||
|
usage = """%prog release_version next_dev_version
|
||||||
|
Update 'version' file to release_version and commit.
|
||||||
|
Generates the document tarball.
|
||||||
|
Tags the sandbox revision with release_version.
|
||||||
|
Update 'version' file to next_dev_version and commit.
|
||||||
|
|
||||||
|
Performs an svn export of tag release version, and build a source tarball.
|
||||||
|
|
||||||
|
Must be started in the project top directory.
|
||||||
|
"""
|
||||||
|
from optparse import OptionParser
|
||||||
|
parser = OptionParser(usage=usage)
|
||||||
|
parser.allow_interspersed_args = False
|
||||||
|
parser.add_option('--dot', dest="dot_path", action='store', default=doxybuild.find_program('dot'),
|
||||||
|
help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
|
||||||
|
parser.add_option('--doxygen', dest="doxygen_path", action='store', default=doxybuild.find_program('doxygen'),
|
||||||
|
help="""Path to Doxygen tool. [Default: %default]""")
|
||||||
|
parser.add_option('--force', dest="ignore_pending_commit", action='store_true', default=False,
|
||||||
|
help="""Ignore pending commit. [Default: %default]""")
|
||||||
|
parser.add_option('--retag', dest="retag_release", action='store_true', default=False,
|
||||||
|
help="""Overwrite release existing tag if it exist. [Default: %default]""")
|
||||||
|
parser.enable_interspersed_args()
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) < 1:
|
||||||
|
parser.error( 'release_version missing on command-line.' )
|
||||||
|
release_version = args[0]
|
||||||
|
|
||||||
|
if options.ignore_pending_commit:
|
||||||
|
msg = ''
|
||||||
|
else:
|
||||||
|
msg = check_no_pending_commit()
|
||||||
|
if not msg:
|
||||||
|
print 'Setting version to', release_version
|
||||||
|
set_version( release_version )
|
||||||
|
tag_url = svn_join_url( SVN_TAG_ROOT, release_version )
|
||||||
|
if svn_check_if_tag_exist( tag_url ):
|
||||||
|
if options.retag_release:
|
||||||
|
svn_remove_tag( tag_url, 'Overwriting previous tag' )
|
||||||
|
else:
|
||||||
|
print 'Aborting, tag %s already exist. Use --retag to overwrite it!' % tag_url
|
||||||
|
sys.exit( 1 )
|
||||||
|
svn_tag_sandbox( tag_url, 'Release ' + release_version )
|
||||||
|
print 'Generated doxygen document...'
|
||||||
|
doxybuild.build_doc( options, make_release=True )
|
||||||
|
#@todo:
|
||||||
|
# svn export
|
||||||
|
# source tarball
|
||||||
|
# decompress source tarball
|
||||||
|
# ?compile & run & check
|
||||||
|
# ?upload documentation
|
||||||
|
else:
|
||||||
|
sys.stderr.write( msg + '\n' )
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user