1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

SCons: Properly handle overriding default values to bool options

The `dev=yes` and `production=yes` options work as aliases to set a number of
options, while still aiming to allow overriding specific options if the user
wishes so. (E.g. `production=yes use_lto=no` should work to enable production
defaults *but* disable LTO.)

That wasn't working as `ARGUMENTS.get()` returns a string and not a boolean as
expected by `BoolVariable`, and this wasn't flagged as a bug... So added a
helper method using SCons' `BoolVariable._text2bool` to do the conversion
manually.
This commit is contained in:
Rémi Verschelde
2021-02-24 09:56:40 +01:00
parent 87deef7d5d
commit 92d59d0879
3 changed files with 24 additions and 9 deletions

View File

@@ -6,7 +6,9 @@ from collections import OrderedDict
from compat import iteritems, isbasestring, open_utf8, decode_utf8, qualname
from SCons import Node
from SCons.Script import ARGUMENTS
from SCons.Script import Glob
from SCons.Variables.BoolVariable import _text2bool
def add_source_files(self, sources, files, warn_duplicates=True):
@@ -134,6 +136,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