Merge branch 'next' into kitchen-sink

This commit is contained in:
Craig Earls 2013-01-30 15:50:54 -07:00
commit b334be6d38

55
acprep
View file

@ -101,13 +101,6 @@ class CommandLineApp(object):
log_handler = None log_handler = None
boost_major = "1_50" boost_major = "1_50"
options = {
'debug': False,
'verbose': False,
'logfile': False,
'loglevel': False
}
def __init__(self): def __init__(self):
"Initialize CommandLineApp." "Initialize CommandLineApp."
# Create the logger # Create the logger
@ -137,7 +130,8 @@ class CommandLineApp(object):
op.add_option('', '--loglevel', metavar='LEVEL', op.add_option('', '--loglevel', metavar='LEVEL',
type='string', action='store', dest='loglevel', type='string', action='store', dest='loglevel',
default=False, help='set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL') default=False, help='set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL')
return
self.options = op.get_default_values()
def main(self, *args): def main(self, *args):
"""Main body of your application. """Main body of your application.
@ -167,7 +161,7 @@ class CommandLineApp(object):
Process options and execute callback functions as needed. This method Process options and execute callback functions as needed. This method
should not need to be overridden, if the main() method is defined.""" should not need to be overridden, if the main() method is defined."""
# Process the options supported and given # Process the options supported and given
self.options, main_args = self.option_parser.parse_args() self.options, main_args = self.option_parser.parse_args(values=self.options)
if self.options.logfile: if self.options.logfile:
fh = logging.handlers.RotatingFileHandler(self.options.logfile, fh = logging.handlers.RotatingFileHandler(self.options.logfile,
@ -238,9 +232,7 @@ class PrepareBuild(CommandLineApp):
self.current_ver = None self.current_ver = None
#self.current_flavor = 'default' #self.current_flavor = 'default'
self.current_flavor = 'debug' self.current_flavor = 'debug'
self.prefix_dir = None
self.products_dir = None self.products_dir = None
self.build_dir = self.source_dir
self.configure_args = [] self.configure_args = []
self.CXXFLAGS = [] self.CXXFLAGS = []
self.LDFLAGS = [] self.LDFLAGS = []
@ -264,7 +256,7 @@ class PrepareBuild(CommandLineApp):
products = self.default_products_directory() products = self.default_products_directory()
if (exists(products) and isdir(products)) or \ if (exists(products) and isdir(products)) or \
(exists('build') and isdir('build')): (exists('build') and isdir('build')):
self.build_dir = None self.options.build_dir = None
def __init__(self): def __init__(self):
CommandLineApp.__init__(self) CommandLineApp.__init__(self)
@ -272,8 +264,6 @@ class PrepareBuild(CommandLineApp):
self.source_dir = os.getcwd() self.source_dir = os.getcwd()
self.initialize()
op = self.option_parser op = self.option_parser
op.add_option('', '--help', action="callback", op.add_option('', '--help', action="callback",
@ -311,21 +301,25 @@ class PrepareBuild(CommandLineApp):
help='Enable use of Doxygen to build ref manual ("make docs")') help='Enable use of Doxygen to build ref manual ("make docs")')
op.add_option('', '--python', action='store_true', dest='python', op.add_option('', '--python', action='store_true', dest='python',
default=False, default=False,
help='Enable Python support (if disabled in acprep)') help='Enable Python support')
op.add_option('', '--no-python', action='store_true', dest='no_python', op.add_option('', '--no-python', action='store_false', dest='python',
default=False, help='Disable python support (default)')
help='Do not enable Python support by default')
op.add_option('', '--prefix', metavar='DIR', action="store", op.add_option('', '--prefix', metavar='DIR', action="store",
dest="prefix_dir", help='Use custom installation prefix') dest="prefix_dir", help='Use custom installation prefix')
op.add_option('', '--products', metavar='DIR', action="store", op.add_option('', '--products', metavar='DIR', action="store",
dest="option_products", dest="option_products",
help='Collect all build products in this directory') help='Collect all build products in this directory')
op.add_option('', '--output', metavar='DIR', action="store", op.add_option('', '--output', metavar='DIR', action="store",
default=self.source_dir,
dest="build_dir", help='Build in the specified directory') dest="build_dir", help='Build in the specified directory')
op.add_option('', '--local', action="callback", op.add_option('', '--local', action="callback",
callback=self.option_local, callback=self.option_local,
help='Build directly within the source tree (default)') help='Build directly within the source tree (default)')
self.options = op.get_default_values()
self.initialize()
def main(self, *args): def main(self, *args):
if args and args[0] in ['default', 'debug', 'opt', 'gcov', 'gprof']: if args and args[0] in ['default', 'debug', 'opt', 'gcov', 'gprof']:
self.current_flavor = args[0] self.current_flavor = args[0]
@ -689,8 +683,6 @@ class PrepareBuild(CommandLineApp):
self.configure_args.append('-DUSE_DOXYGEN=1') self.configure_args.append('-DUSE_DOXYGEN=1')
if self.options.python: if self.options.python:
self.configure_args.append('-DUSE_PYTHON=1') self.configure_args.append('-DUSE_PYTHON=1')
if self.options.no_python:
self.configure_args.remove('-DUSE_PYTHON=1')
if self.options.use_ninja: if self.options.use_ninja:
self.configure_args.append('-GNinja') self.configure_args.append('-GNinja')
@ -740,7 +732,7 @@ class PrepareBuild(CommandLineApp):
def option_local(self, option=None, opt_str=None, value=None, parser=None): def option_local(self, option=None, opt_str=None, value=None, parser=None):
self.log.debug('Saw option --local') self.log.debug('Saw option --local')
self.build_dir = self.source_dir self.options.build_dir = self.source_dir
def option_help(self, option=None, opt_str=None, value=None, parser=None): def option_help(self, option=None, opt_str=None, value=None, parser=None):
self.phase_help() self.phase_help()
@ -841,7 +833,7 @@ class PrepareBuild(CommandLineApp):
try: try:
os.chdir(build_dir) os.chdir(build_dir)
need_to_config = not isfile('Makefile') need_to_config = not isfile('rules.ninja' if self.options.use_ninja else 'Makefile')
if need_to_config: if need_to_config:
self.log.debug('Source => ' + self.source_dir) self.log.debug('Source => ' + self.source_dir)
self.log.debug('Build => ' + build_dir) self.log.debug('Build => ' + build_dir)
@ -880,7 +872,7 @@ class PrepareBuild(CommandLineApp):
make_args = [] make_args = []
for arg in args: for arg in args:
if arg.startswith('--'): if arg.startswith('--') or arg.startswith('-D'):
config_args.append(arg) config_args.append(arg)
else: else:
make_args.append(arg) make_args.append(arg)
@ -946,9 +938,9 @@ class PrepareBuild(CommandLineApp):
def configure_flavor(self, flavor, reset=True): def configure_flavor(self, flavor, reset=True):
self.initialize() # reset everything self.initialize() # reset everything
self.build_dir = None # use the build/ tree
self.current_flavor = flavor self.current_flavor = flavor
self.prefix_dir = None self.options.build_dir = None # use the build/ tree
self.options.prefix_dir = None
if reset and exists(self.build_directory()) and \ if reset and exists(self.build_directory()) and \
isdir(self.build_directory()): isdir(self.build_directory()):
@ -1073,12 +1065,17 @@ typical user:
submodule Updates Git submodules (better to use 'pull') submodule Updates Git submodules (better to use 'pull')
version Output current HEAD version to version.m4 version Output current HEAD version to version.m4
NOTE: If you wish to pass options to configure or make, add "--" followed by NOTE: If you wish to pass options to CMake or make, add "--" followed by
your options. Here are some real-world examples: your options. Those starting with "-D" or "--" will be passed on to CMake,
positional arguments and other options will be passed to make.
For the 'config' and 'configure' phase everything will be passed to CMake.
Here are some real-world examples:
./acprep ./acprep
./acprep opt -- make -j3 ./acprep --python
./acprep --enable-doxygen""" ./acprep opt make
./acprep make doc -- -DBUILD_WEB_DOCS=1"""
sys.exit(0) sys.exit(0)
PrepareBuild().run() PrepareBuild().run()