From 2fcd9d35c5de0e09cfb571d2bc93fa8961d5903a Mon Sep 17 00:00:00 2001 From: Jukka Laurila Date: Wed, 7 Mar 2018 21:37:56 +0100 Subject: Add test for bug https://github.com/mesonbuild/meson/issues/3185 --- test cases/common/181 initial c_args/meson.build | 7 +++++++ test cases/common/181 initial c_args/test_args.txt | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 test cases/common/181 initial c_args/meson.build create mode 100644 test cases/common/181 initial c_args/test_args.txt diff --git a/test cases/common/181 initial c_args/meson.build b/test cases/common/181 initial c_args/meson.build new file mode 100644 index 000000000..70a6e7a4a --- /dev/null +++ b/test cases/common/181 initial c_args/meson.build @@ -0,0 +1,7 @@ +project('options', 'c') + +# Test passing c_args and c_link_args options from the command line. +assert(get_option('c_args') == ['-march=native', '-funroll-loops'], + 'Incorrect value for c_args option.') +assert(get_option('c_link_args') == ['-random_linker_option'], + 'Incorrect value for c_link_args option.') diff --git a/test cases/common/181 initial c_args/test_args.txt b/test cases/common/181 initial c_args/test_args.txt new file mode 100644 index 000000000..9a6da068a --- /dev/null +++ b/test cases/common/181 initial c_args/test_args.txt @@ -0,0 +1,4 @@ +# This file is not read by meson itself, but by the test framework. +# It is not possible to pass arguments to meson from a file. +['-Dc_args=-march=native', '-Dc_args=-funroll-loops', + '-Dc_link_args=-random_linker_option'] -- cgit v1.2.3 From 8789278e5e700203a3b5fcf2c89fa5482e6ec5ee Mon Sep 17 00:00:00 2001 From: Jukka Laurila Date: Fri, 9 Mar 2018 00:43:24 +0100 Subject: Fixed bug 3185. --- mesonbuild/interpreter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f9f25e48a..90000d54e 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2096,6 +2096,19 @@ to directly access options of other subprojects.''') else: version_string = ' (%s %s)' % (comp.id, comp.version) mlog.log('Native %s compiler: ' % comp.get_display_language(), mlog.bold(' '.join(comp.get_exelist())), version_string, sep='') + + # If _args/_link_args settings are given on the + # command line, use them. + for optspec in self.build.environment.cmd_line_options.projectoptions: + (optname, optvalue) = optspec.split('=', maxsplit=1) + if optname.endswith('_link_args'): + lang = optname[:-10] + self.coredata.external_link_args.setdefault(lang, []).append(optvalue) + elif optname.endswith('_args'): + lang = optname[:-5] + self.coredata.external_args.setdefault(lang, []).append(optvalue) + # Otherwise, look for definitions from environment + # variables such as CFLAGS. if not comp.get_language() in self.coredata.external_args: (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp) self.coredata.external_preprocess_args[comp.get_language()] = preproc_args -- cgit v1.2.3