diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-22 21:07:03 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-22 21:28:34 +0200 |
commit | d88223bd615ebce49cc662a3b48461de9c4780bc (patch) | |
tree | a1d0014977f5efac17e896b71f1c9e1865dc19c0 | |
parent | 6a90d5d58781734149c637eb46dda5d90ddc03f7 (diff) | |
download | meson-d88223bd615ebce49cc662a3b48461de9c4780bc.zip meson-d88223bd615ebce49cc662a3b48461de9c4780bc.tar.gz meson-d88223bd615ebce49cc662a3b48461de9c4780bc.tar.bz2 |
Do delayed argument setting properly this time.
-rw-r--r-- | mesonbuild/environment.py | 15 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 7 |
3 files changed, 19 insertions, 5 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index c43c5e1..369ca20 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.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: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 4d41f1a..b64eb7f 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -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: diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 774502b..0317651 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -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. |