From 71ad4fb71187efe5cbb5b33fe51dd3231a860f74 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Mon, 18 Mar 2024 14:40:12 +0000 Subject: [PATCH] config: Use ${btvar:XXX} in more config sections Allow btvars to be additionally resolved in build..{sourcedir, builddir, repo, toolchain} sections. People have use cases for sourcedir and repo (both remote and revision). I'm adding builddir and toolchain speculatively. Note that the implementation actually allows most of the macros to be resolved in these sections, but I'm only documenting the above because other macros might not make sense in these sections. Signed-off-by: Ryan Roberts --- documentation/userguide/configmodel.rst | 28 ++++++++++++------------- shrinkwrap/utils/config.py | 12 +++++++++++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/documentation/userguide/configmodel.rst b/documentation/userguide/configmodel.rst index c22a521..588a62c 100644 --- a/documentation/userguide/configmodel.rst +++ b/documentation/userguide/configmodel.rst @@ -122,20 +122,20 @@ output to get a better feel for how they work. See Defined Macros -------------- -======================= =============================================================================== ==== -macro scope description -======================= =============================================================================== ==== -``${param:sourcedir}`` build..{params, prebuild, build, postbuild, artifacts} Directory in which the component's source code is located. -``${param:builddir}`` build..{params, prebuild, build, postbuild, 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, 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, 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, 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} String containing all of the component's parameters (from its params dictionary), concatenated as ``key=value`` pairs. -``${param:join_space}`` build..{prebuild, build, postbuild} String containing all of the component's parameters (from its params dictionary), concatenated as ``key value`` pairs. -``${artifact:}`` build..{params, prebuild, build, postbuild, artifacts}, build.btvars Build path of an artifact declared by another component. Usage of these macros determine the component build dependency graph. -``${artifact:}`` run.rtvars Package path of an artifact. -``${rtvar:}`` run.params Run-time variables. The variable names, along with default values are declared in run.rtvars, and the user may override the value on the command line. -======================= =============================================================================== ==== +======================= ===================================================================================================================== ==== +macro scope description +======================= ===================================================================================================================== ==== +``${param:sourcedir}`` build..{params, prebuild, build, postbuild, artifacts} Directory in which the component's source code is located. +``${param:builddir}`` build..{params, prebuild, build, postbuild, 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, 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, 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..{sourcedir, builddir, repo, toolchain, params, prebuild, build, postbuild, 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} String containing all of the component's parameters (from its params dictionary), concatenated as ``key=value`` pairs. +``${param:join_space}`` build..{prebuild, build, postbuild} String containing all of the component's parameters (from its params dictionary), concatenated as ``key value`` pairs. +``${artifact:}`` build..{params, prebuild, build, postbuild, artifacts}, build.btvars Build path of an artifact declared by another component. Usage of these macros determine the component build dependency graph. +``${artifact:}`` run.rtvars Package path of an artifact. +``${rtvar:}`` run.params Run-time variables. The variable names, along with default values are declared in run.rtvars, and the user may override the value on the command line. +======================= ===================================================================================================================== ==== ****** Schema diff --git a/shrinkwrap/utils/config.py b/shrinkwrap/utils/config.py index 8c7d95a..fbf6731 100644 --- a/shrinkwrap/utils/config.py +++ b/shrinkwrap/utils/config.py @@ -526,6 +526,9 @@ def resolveb(config, btvars={}, clivars={}): def _substitute_macros(config, lut, final): for desc in config['build'].values(): + desc['sourcedir'] = _string_substitute(desc['sourcedir'], lut, final) + desc['builddir'] = _string_substitute(desc['builddir'], lut, final) + lut['param']['sourcedir'] = desc['sourcedir'] lut['param']['builddir'] = desc['builddir'] @@ -536,6 +539,15 @@ def resolveb(config, btvars={}, clivars={}): lut['param']['join_equal'] = _mk_params(desc['params'], '=') lut['param']['join_space'] = _mk_params(desc['params'], ' ') + for r in desc['repo'].values(): + if r['remote']: + r['remote'] = _string_substitute(r['remote'], lut, final) + if r['revision']: + r['revision'] = _string_substitute(r['revision'], lut, final) + + if desc['toolchain']: + desc['toolchain'] = _string_substitute(desc['toolchain'], lut, final) + for i, s in enumerate(desc['prebuild']): desc['prebuild'][i] = _string_substitute(s, lut, final) for i, s in enumerate(desc['build']): -- GitLab