summaryrefslogtreecommitdiff
path: root/acprep
diff options
context:
space:
mode:
authorJohann Klähn <kljohann@gmail.com>2013-01-30 01:04:29 +0100
committerJohann Klähn <kljohann@gmail.com>2013-01-30 23:07:17 +0100
commit5ee03de0ad8c2df38bc10acf67f02cf862c6c83c (patch)
tree648c067750d7c409406745a9186ca19a1f226b78 /acprep
parent45ebed0fd55fd45802ae16706a59ff5fe9f29582 (diff)
downloadfork-ledger-5ee03de0ad8c2df38bc10acf67f02cf862c6c83c.tar.gz
fork-ledger-5ee03de0ad8c2df38bc10acf67f02cf862c6c83c.tar.bz2
fork-ledger-5ee03de0ad8c2df38bc10acf67f02cf862c6c83c.zip
fix option handling in acprep
Both the `--local` option and the default to build local if no build directory exists did not work, because `build_directory()` uses `self.options.build_dir`, but the default and the `--local` option used `self.build_dir`. I changed the code to always use `self.options` for options/flags. Now `self.options` is set to the default values of OptParser and is updated when `parse_args` is called in `run`. After this commit ledger will be built in: * The directory specified using `--output=` * Else in a subdirectory of `./build` or `~/Products` if one of those directories exist and `--local` is not used. * Else inside the source tree (default).
Diffstat (limited to 'acprep')
-rwxr-xr-xacprep33
1 files changed, 14 insertions, 19 deletions
diff --git a/acprep b/acprep
index 26f8d8b2..6330a7f8 100755
--- a/acprep
+++ b/acprep
@@ -101,13 +101,6 @@ class CommandLineApp(object):
log_handler = None
boost_major = "1_50"
- options = {
- 'debug': False,
- 'verbose': False,
- 'logfile': False,
- 'loglevel': False
- }
-
def __init__(self):
"Initialize CommandLineApp."
# Create the logger
@@ -137,7 +130,8 @@ class CommandLineApp(object):
op.add_option('', '--loglevel', metavar='LEVEL',
type='string', action='store', dest='loglevel',
default=False, help='set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL')
- return
+
+ self.options = op.get_default_values()
def main(self, *args):
"""Main body of your application.
@@ -167,7 +161,7 @@ class CommandLineApp(object):
Process options and execute callback functions as needed. This method
should not need to be overridden, if the main() method is defined."""
# 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:
fh = logging.handlers.RotatingFileHandler(self.options.logfile,
@@ -238,9 +232,7 @@ class PrepareBuild(CommandLineApp):
self.current_ver = None
#self.current_flavor = 'default'
self.current_flavor = 'debug'
- self.prefix_dir = None
self.products_dir = None
- self.build_dir = self.source_dir
self.configure_args = []
self.CXXFLAGS = []
self.LDFLAGS = []
@@ -264,7 +256,7 @@ class PrepareBuild(CommandLineApp):
products = self.default_products_directory()
if (exists(products) and isdir(products)) or \
(exists('build') and isdir('build')):
- self.build_dir = None
+ self.options.build_dir = None
def __init__(self):
CommandLineApp.__init__(self)
@@ -272,8 +264,6 @@ class PrepareBuild(CommandLineApp):
self.source_dir = os.getcwd()
- self.initialize()
-
op = self.option_parser
op.add_option('', '--help', action="callback",
@@ -321,11 +311,16 @@ class PrepareBuild(CommandLineApp):
dest="option_products",
help='Collect all build products in this directory')
op.add_option('', '--output', metavar='DIR', action="store",
+ default=self.source_dir,
dest="build_dir", help='Build in the specified directory')
op.add_option('', '--local', action="callback",
callback=self.option_local,
help='Build directly within the source tree (default)')
+ self.options = op.get_default_values()
+
+ self.initialize()
+
def main(self, *args):
if args and args[0] in ['default', 'debug', 'opt', 'gcov', 'gprof']:
self.current_flavor = args[0]
@@ -740,7 +735,7 @@ class PrepareBuild(CommandLineApp):
def option_local(self, option=None, opt_str=None, value=None, parser=None):
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):
self.phase_help()
@@ -841,7 +836,7 @@ class PrepareBuild(CommandLineApp):
try:
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:
self.log.debug('Source => ' + self.source_dir)
self.log.debug('Build => ' + build_dir)
@@ -945,10 +940,10 @@ class PrepareBuild(CommandLineApp):
#########################################################################
def configure_flavor(self, flavor, reset=True):
- self.initialize() # reset everything
- self.build_dir = None # use the build/ tree
+ self.initialize() # reset everything
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 \
isdir(self.build_directory()):