From 7ae91a697efef932da8cc4808552dd646a3bb702 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Fri, 2 Feb 2024 12:44:41 +0000 Subject: [PATCH] config: Allow btvars to be used as rtvar default values This allows a single parameter to be specified that can be used at both build-time and run-time. A btvar is defined and set as normal. And a corresponding rtvar is defined with its default value set to the btvar macro. The user can still override the rtvar at runtime if they want. Example: buildex: btvars: MYPROP: type: string value: null build: mycomponent: params: myprop: ${btvar:MYPROP} run: rtvars: MYPROP: type: string value: ${btvar:MYPROP} params: -C myprop: ${rtvar:MYPROP} Signed-off-by: Ryan Roberts --- documentation/userguide/configmodel.rst | 2 +- shrinkwrap/utils/config.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/userguide/configmodel.rst b/documentation/userguide/configmodel.rst index 019a888..b50e4b1 100644 --- a/documentation/userguide/configmodel.rst +++ b/documentation/userguide/configmodel.rst @@ -129,7 +129,7 @@ macro scope ``${param:builddir}`` build..{params, prebuild, build, postbuild, clean, artifacts} Directory in which the component should be built, if the component's build system supports separation of source and build trees. ``${param:configdir}`` build..{params, prebuild, build, postbuild, clean, artifacts} Directory containing the config store. This MUST only be used for resolving files that already exist in the store. ``${param:jobs}`` build..{params, prebuild, build, postbuild, clean, artifacts} Maximum number of low level parallel jobs specified on the command line. To be passed to (e.g.) make as ``-j${param:jobs}``. -``${btvar:}`` build..{params, prebuild, build, postbuild, clean, artifacts} Build-time variables. The variable names, along with default values are declared in buildex.btvars, and the user may override the value on the command line. +``${btvar:}`` build..{params, prebuild, build, postbuild, clean, artifacts}, run.rtvars Build-time variables. The variable names, along with default values are declared in buildex.btvars, and the user may override the value on the command line. ``${param:join_equal}`` build..{prebuild, build, postbuild, clean} String containing all of the component's parameters (from its params dictionary), concatenated as ``key=value`` pairs. ``${param:join_space}`` build..{prebuild, build, postbuild, clean} String containing all of the component's parameters (from its params dictionary), concatenated as ``key value`` pairs. ``${artifact:}`` build..{params, prebuild, build, postbuild, clean, artifacts}, build.btvars Build path of an artifact declared by another component. Usage of these macros determine the component build dependency graph. diff --git a/shrinkwrap/utils/config.py b/shrinkwrap/utils/config.py index 0de5ff3..d55086c 100644 --- a/shrinkwrap/utils/config.py +++ b/shrinkwrap/utils/config.py @@ -653,6 +653,8 @@ def resolver(config, rtvars={}, clivars={}): }, 'artifact': {k: v['dst'] for k, v in config['artifacts'].items()}, + 'btvar': {k: v['value'] + for k, v in config['buildex']['btvars'].items()}, } for k in run['rtvars']: v = run['rtvars'][k] -- GitLab