From fd653d070d7d498ca8bb8a2430ed128d6239601d Mon Sep 17 00:00:00 2001 From: Gabríel Arthúr Pétursson Date: Sat, 8 Jul 2017 02:53:26 +0000 Subject: Make base options accessible via get_option() --- docs/markdown/Release-notes-for-0.42.0.md | 7 +++++++ mesonbuild/interpreter.py | 4 ++++ test cases/common/47 options/meson.build | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/docs/markdown/Release-notes-for-0.42.0.md b/docs/markdown/Release-notes-for-0.42.0.md index fe4af7516..a19db4981 100644 --- a/docs/markdown/Release-notes-for-0.42.0.md +++ b/docs/markdown/Release-notes-for-0.42.0.md @@ -37,6 +37,13 @@ pkg.generate(libraries : libs, extra_cflags : '-Dfoo' ) ``` +## Base options accessible via get_option() + +Base options are now accessible via the get_option() function. +```meson +uses_lto = get_option('b_lto') +``` + ## Allow crate type configuration for Rust compiler Rust targets now take an optional `rust_crate_type` keyword, allowing diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 58a145a87..8885e2b41 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1654,6 +1654,10 @@ class Interpreter(InterpreterBase): if len(args) != 1: raise InterpreterException('Argument required for get_option.') optname = args[0] + try: + return compilers.base_options[optname].value + except KeyError: + pass try: return self.environment.get_coredata().get_builtin_option(optname) except RuntimeError: diff --git a/test cases/common/47 options/meson.build b/test cases/common/47 options/meson.build index 796c27f65..4058748f0 100644 --- a/test cases/common/47 options/meson.build +++ b/test cases/common/47 options/meson.build @@ -12,6 +12,10 @@ if get_option('combo_opt') != 'combo' error('Incorrect value to combo option.') endif +if get_option('b_lto') != false + error('Incorrect value in base option.') +endif + if get_option('includedir') != 'include' error('Incorrect value in builtin option.') endif -- cgit v1.2.3