add conditional environment variables

Until now all environment variables in the kas config's
env section require a default value.
In some cases we want to rely on the weak assignment
of bitbake instead of relying on the default value of the
variable in the kas config.

This means if we assign the 'None' value or nothing to the variable
in the kas config then it is only added to BB_ENV_EXTRAWHITE or
BB_ENV_PASSTHROUGH_ADDITIONS without setting it as environment
variable.

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
[Jan: fixed overlong line]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Benedikt Niedermayr 2022-11-10 13:46:45 +01:00 committed by Jan Kiszka
parent 102c4667d1
commit c38517df83
5 changed files with 22 additions and 5 deletions

View File

@ -121,3 +121,12 @@ Added
- For repositories, ``url`` and ``path`` can now be overridden with a
null-value to switch between version-controlled repositories and unversioned
local folders.
Version 13
----------
Added
~~~~~
- Variables used in the ``env`` section can now be assigned 'None' as value. In
this case the variables are only exported to the bb env whitelist.

View File

@ -354,9 +354,14 @@ Configuration reference
should be specified via the environment variable.
* ``env``: dict [optional]
Contains environment variable names with the default values. These
variables are made available to bitbake via ``BB_ENV_EXTRAWHITE`` and can
be overwritten by the variables of the environment in which kas is started.
Contains environment variable names with either default values or None.
These variables are made available to bitbake via ``BB_ENV_EXTRAWHITE``
and can be overwritten by the variables of the environment in which
kas is started.
Either a string or nothing (None) can be assigned as value.
The former one serves as a default value whereas the latter one will lead
to add the variable only to ``BB_ENV_EXTRAWHITE`` and not to the
environment where kas is started.
* ``task``: string [optional]
Contains the task to build by bitbake. Can be overwritten by the

View File

@ -28,5 +28,5 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017-2020'
__version__ = '3.1'
# Please update docs/format-changelog.rst when changing the file version.
__file_version__ = 12
__file_version__ = 13
__compatible_file_version__ = 1

View File

@ -275,6 +275,9 @@ def get_build_environ(build_system):
if env_var in os.environ:
env[env_var] = os.environ[env_var]
# filter out 'None' values
env = {k: v for (k, v) in env.items() if v is not None}
return env

View File

@ -94,7 +94,7 @@
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
"type": ["string", "null"]
}
},
"target": {