Comments (11)
Manipulating the environment of a step from the pathFmt plugin is risky. Normally the environment is a central part in the Variant-/Build-Id calculation. Do you change the environment from the state tracker or from one of the *NameFormatter hooks?
from bob.
from the NameFormatter.
Why I'm doing this:
Normally the CMAKE_BUILD_TYPE comes from the root recipe and is passed to downstream recipes. But in case I want to build certain modules with another buildtype I need to modify the recipe to set this new BUILD_TYPE. This is passed to it's dependencies which is also not desired.
Actual solution is to parse another environment variable, lets call it BUILD_TYPE_OVERWRITE in the nameFormatter and modify the existing BUILD_TYPE. I also add the new buildtype to the name of dist/build directory.
Since BUILD_TYPE_OVERWRITE is taken into account for build-ID calculation it should be save?
Another possible solution is to parse the BUILD_TYPE_OVERWRITE in a class to setup the Cmake variable and to parse it again in the NameFormatter to get the directoryName. But this doubles the code. ( Not really, because it'll need a bash and a python implementation...)
from bob.
This sounds like it just works only because the build type is appended to the directory. BUILD_TYPE_OVERWRITE would only have an influence if this variable is actually used in a step, e.g. by buildVars
.
Currently the design of Bob assumes that the Steps, once they have been generated, are constant. The path name calculation runs afterwards and could therefore contradict this assumption. That's also why there are public "set" functions on a Step at all.
It seems to me that you just need a way to set the environment for the recipe alone without propagating that to the downstream recipes. Would something like a privateEnvironment
keyword fit your use case? Basically this keyword would allow you to set environment variables right after the dependencies have been traversed but before the steps are processed.
from bob.
privateEnvironment
sounds useful to me to reduce the number of environment variables in the downstream recipies, but I'm not sure if it fits to this specific problem. Normally I want to use the Buildtype from the upstream recipe - so I can't set BUILD_TYPE
as a privateEnvironment
.
Nevertheless privateEnvironment
should be added to the TODO List. Variables like PKG_VERSION
can be private.
from bob.
What if you could set the privateEnvironment the following way?
privateEnvironment:
BUILD_TYPE: "${BUILD_TYPE_OVERWRITE:-${BUILD_TYPE}}"
That would set the BUILD_TYPE to BUILD_TYPE_OVERWRITE if set. Otherwise BUILD_TYPE would be kept as is...
What I don't understand yet is how you set BUILD_TYPE_OVERWRITE?
from bob.
BUILD_TYPE_OVERWRITE is defined as: "buildtype_a:module1,module2#buildtype_b:module3,module3" and it's just a variable passed to bob by -DBUILD_TYPE_OVERWRITE
privateEnvironment:
BUILD_TYPE: "${ $(parse $BUILD_TYPE_OVERWRITE):-${BUILD_TYPE}}"
maybe something like this can do the trick?
from bob.
That's exactly what I had in mind but what would take some time to implement. In the end a plugin could provide custom functions ("parse" in this case) that could be provided by a plugin.
from bob.
I have hacked something to allow advanced string processing: https://github.com/jkloetzke/bob/tree/string-processing
It's far from finished but I would like to have some feedback if this is heading in the right direction. The idea is that there are string processing functions called in the following way: $(function,arg1,arg2,...)
. Such function can be defined by a plugin. I can think of a number of built-in functions too but this is not implemented yet. There is an example test case in test/blackbox/string-plugin
that should show the principle operation.
The privateEnvironment
is still missing...
from bob.
privateEnvironment
isn't that important since I can use something like:
environment:
BUILD_TYPE: "$(override, BUILD_TYPE_OVERRIDE, ${BUILD_TYPE_DEFAULT})"`
from bob.
Perfect. $
had to be escaped by $$
whereas now it is done by a backslash. I hope that is not a problem.
At the same time I would also like to use the same functions for the if
clauses. That would easily enable to test for an enabled sandbox or available tools. Something like that:
depends:
-
name: foobar-toolchain
if: "$(not,$(is-tool-defined,toolchain))"
-
name: host-toolchain
if: "$(is-sandbox-enabled)"
from bob.
In order to use the new string substitutions you have to add 'bobMinimumVersion: "0.3"' to config.yaml. Note that this also changes the behavior of the 'if' keyword in the way described above.
from bob.
Related Issues (20)
- Internal exception while trying to build Jenkins pipeline HOT 3
- [Errno 28] No space left on device HOT 2
- "Error loading audit" not visible if verbosity is to low HOT 1
- wrong windows/MSYS whitelisted environment variable names
- cutted fingerprint print HOT 1
- Error while trying to mount directory during the checkout step HOT 1
- ${BOB_TOOL_PATHS[target-toolchain]} in environment variables HOT 2
- Bob deleted src directory after recovery attempt HOT 9
- Tool environment not used to evaluate depends conditions HOT 3
- scm import not working while building in out-of-source-tree HOT 1
- Trying to build a non-existend package should be an error HOT 4
- Always use python as extractor on native Windows HOT 5
- empty 'set' in scmOverrides not handled HOT 1
- Exception in common IDE generator
- Bob 0.22.0 misses sandbox HOT 7
- Azure Archive is broken HOT 7
- checkoutUpdateIf: run checkout script if recipe changed? HOT 1
- bob rebuilds everytime if environment changed by bob -c HOT 3
- python3.11 pip install failing HOT 2
- latest sphinx version breaks pip install HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bob.