diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-08-25 20:07:05 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-08-25 20:32:34 +0200 |
| commit | 932d0f7b8a69bdcac5d945de600ce6be807aeff7 (patch) | |
| tree | b28def99ad24db522ee2bf51df9b9cf52d611b11 /kconfiglib.py | |
| parent | 20de53b6a29fcfd2d91e815c5698b9b806a908f4 (diff) | |
Add a Kconfig.env_vars attribute that lists env. variables
Kconfig.env_vars is a set() with the names of all environment variables
referenced in the configuration.
Can be used e.g. for custom incremental build implementations, though
sync_deps() already indirectly catches any relevant changes to
environment variables.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 5fdd9b7..38bdff2 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -479,6 +479,24 @@ class Kconfig(object): already indirectly catches any file modifications that change the configuration output. + env_vars: + A set() with the names of all environment variables referenced in the + Kconfig files. + + Only environment variables referenced with the preprocessor $(FOO) syntax + will be registered. The older $FOO syntax is only supported for backwards + compatibility. + + Also note that $(FOO) won't be registered unless the environment variable + $FOO is actually set. If it isn't, $(FOO) is an expansion of an unset + preprocessor variable (which gives the empty string). + + Another gotcha is that environment variables referenced in the values of + recursively expanded preprocessor variables (those defined with =) will + only be registered if the variable is actually used (expanded) somewhere. + + The note from the 'kconfig_filenames' documentation applies here too. + n/m/y: The predefined constant symbols n/m/y. Also available in const_syms. @@ -583,6 +601,7 @@ class Kconfig(object): "const_syms", "defconfig_list", "defined_syms", + "env_vars", "kconfig_filenames", "m", "mainmenu_text", @@ -773,6 +792,7 @@ class Kconfig(object): # Not used internally. Provided as a convenience. self.kconfig_filenames = [filename] + self.env_vars = set() # These implement a single line of "unget" for the parser self._saved_line = None @@ -2180,6 +2200,7 @@ class Kconfig(object): # Environment variables are tried last if fn in os.environ: + self.env_vars.add(fn) return os.environ[fn] return "" |
