Do delayed argument setting properly this time.

pull/407/head
Jussi Pakkanen 9 years ago
parent 6a90d5d587
commit d88223bd61
  1. 15
      mesonbuild/environment.py
  2. 2
      mesonbuild/interpreter.py
  3. 7
      mesonbuild/mesonmain.py

@ -58,7 +58,7 @@ class Environment():
log_dir = 'meson-logs'
coredata_file = os.path.join(private_dir, 'coredata.dat')
version_regex = '\d+(\.\d+)+(-[a-zA-Z0-9]+)?'
def __init__(self, source_dir, build_dir, main_script_file, options):
def __init__(self, source_dir, build_dir, main_script_file, options, original_cmd_line_args):
assert(os.path.isabs(main_script_file))
assert(not os.path.islink(main_script_file))
self.source_dir = source_dir
@ -80,6 +80,7 @@ class Environment():
else:
self.cross_info = None
self.cmd_line_options = options
self.original_cmd_line_args = original_cmd_line_args
# List of potential compilers.
if mesonlib.is_windows():
@ -153,6 +154,18 @@ class Environment():
def is_library(self, fname):
return is_library(fname)
def had_argument_for(self, option):
trial1 = '--' + option
trial2 = '-D' + option
previous_is_plaind = False
for i in self.original_cmd_line_args:
if i.startswith(trial1) or i.startswith(trial2):
return True
if previous_is_plaind and i.startswith(option):
return True
previous_is_plaind = i == '-D'
return False
def merge_options(self, options):
for (name, value) in options.items():
if name not in self.coredata.user_options:

@ -1331,7 +1331,7 @@ class Interpreter():
key, value = option.split('=', 1)
builtin_options = self.coredata.builtin_options
if key in builtin_options:
if not hasattr(self.environment.cmd_line_options, value):
if not self.environment.had_argument_for(key):
self.coredata.set_builtin_option(key, value)
# If this was set on the command line, do not override.
else:

@ -79,7 +79,7 @@ parser.add_argument('directories', nargs='*')
class MesonApp():
def __init__(self, dir1, dir2, script_file, handshake, options):
def __init__(self, dir1, dir2, script_file, handshake, options, original_cmd_line_args):
(self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake)
if not os.path.isabs(options.prefix):
raise RuntimeError('--prefix value \'{0}\' must be an absolute path: '.format(options.prefix))
@ -92,6 +92,7 @@ class MesonApp():
options.prefix = options.prefix[:-1]
self.meson_script_file = script_file
self.options = options
self.original_cmd_line_args = original_cmd_line_args
def has_build_file(self, dirname):
fname = os.path.join(dirname, environment.build_filename)
@ -130,7 +131,7 @@ itself as required.'''
return (src_dir, build_dir)
def generate(self):
env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, self.options)
env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, self.options, self.original_cmd_line_args)
mlog.initialize(env.get_log_dir())
mlog.debug('Build started at', datetime.datetime.now().isoformat())
mlog.debug('Python binary:', sys.executable)
@ -246,7 +247,7 @@ def run(mainfile, args):
else:
mainfile = resolved
try:
app = MesonApp(dir1, dir2, mainfile, handshake, options)
app = MesonApp(dir1, dir2, mainfile, handshake, options, sys.argv)
except Exception as e:
# Log directory does not exist, so just print
# to stdout.

Loading…
Cancel
Save