diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-24 11:14:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 11:14:37 +0100 |
commit | 573121ca7f591c9cabded548ffece1b2d34eb20a (patch) | |
tree | 984646b1d0b3e826e877855d3f4afda91ddf51e5 /methods.py | |
parent | 2bdbb0508b73df9bff49da944d0a7054f2703a67 (diff) | |
parent | b97ef35585733474faf1b2de2f3b38c7eed26123 (diff) |
Merge pull request #46366 from akien-mga/scons-fix-cmdline-bool
SCons: Properly handle overriding default values to bool options
Diffstat (limited to 'methods.py')
-rw-r--r-- | methods.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/methods.py b/methods.py index 45cfe00959..9b29eadc16 100644 --- a/methods.py +++ b/methods.py @@ -6,9 +6,11 @@ from collections import OrderedDict # We need to define our own `Action` method to control the verbosity of output # and whenever we need to run those commands in a subprocess on some platforms. -from SCons.Script import Action from SCons import Node +from SCons.Script import Action +from SCons.Script import ARGUMENTS from SCons.Script import Glob +from SCons.Variables.BoolVariable import _text2bool from platform_methods import run_in_subprocess @@ -145,6 +147,17 @@ def parse_cg_file(fname, uniforms, sizes, conditionals): fs.close() +def get_cmdline_bool(option, default): + """We use `ARGUMENTS.get()` to check if options were manually overridden on the command line, + and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings. + """ + cmdline_val = ARGUMENTS.get(option) + if cmdline_val is not None: + return _text2bool(cmdline_val) + else: + return default + + def detect_modules(search_path, recursive=False): """Detects and collects a list of C++ modules at specified path |