Comments (9)
I'll try to implement this in colcon first and see how it goes.
from ament_package.
When prepending values to an env var we aim to not have a trailing separator. The rational is that in the past there were cases where consumers of the env vars didn't support that case.
A sourced script can perform the correct prepending. But the command generated for a dsv type like prepend-non-duplicate
isn't aware of the shell logic and instead of resulting in a line like:
`FOO=new_value:$FOO`
it will (since the env var was not set before) generate a line like:
`FOO=new_value`
which will overwrite the change of the sourced script.
from ament_package.
Just throwing out an idea, what if we always prepend and then do a post-processing step to check that all env vars that were set do not have a trailing :
? And if they do, just unset them.
from ament_package.
Should that post processing happen in the shell or in Python? The former would need to be implemented in all primary shells (sh
, bat
, ps1
atm). The later would require the overhead of another Python invocation.
How does the post-processing determine which env vars to check? Preferably without needing to discover all .dsv
file again due to the necessary runtime.
Should the post-processing distinguish which trailing separators are actually coming from the "always prepending" or blindly remove them (potentially altering values unintentionally)?
from ament_package.
Should that post processing happen in the shell or in Python?
I guess the former seems like the way to go performance-wise.
How does the post-processing determine which env vars to check? Preferably without needing to discover all .dsv file again due to the necessary runtime.
We could store this information in a temporary environment variable (which is just a list of all variables prepended to via dsv commands). Note, this could be unset at the end of the post-processing script to avoid environment pollution.
Should the post-processing distinguish which trailing separators are actually coming from the "always prepending" or blindly remove them (potentially altering values unintentionally)?
I'm not sure, but maybe it's safest to just remove the trailing separator if and only it is the only character (ie. if the contents of the variable are longer than one character, do nothing).
It seems like an odd case to want a standalone separator, but I don't know.
from ament_package.
maybe it's safest to just remove the trailing separator if and only it is the only character
That might still break (poorly written) code which isn't capable of handling a trailing separator.
from ament_package.
We know what the first prepended value should be if nothing else was prepended before the first .dsv file was processed. A best effort approach could be to compare the suffix with what we might expect to be there, and if they're equal, remove the trailing separator.
from ament_package.
That sounds like a promising approach 👍
from ament_package.
I took a slightly different approach in colcon/colcon-core#254,
Instead of setting an environment variable to track changes in the shell scripts, I've done this tracking in Python and appended commands for cleanup.
from ament_package.
Related Issues (20)
- Eloquent patch release HOT 3
- generate_disutils_setup Equivalent HOT 1
- Issue while building ROS2 package HOT 1
- what error HOT 1
- Repository description seems inaccurate HOT 2
- `.dsv` files are not processed unless there is `.sh` file with the same base name HOT 3
- Several lines from _local_setup_util_sh.py contain this: E501 line too long HOT 2
- Error reporting for invalid package.xml is unhelpful
- ament build fails HOT 2
- use PATH to find for python in Windows HOT 3
- Not enforcing ROS name convention when building NON-ROS packages HOT 7
- Setup file (at least for zsh) fails when no ament packages were in workspace
- New test failure in ament_package HOT 2
- Support powershell HOT 1
- add a way to skip building packages conditionally HOT 7
- prefix level never got the AMENT_PYTHON_EXECUTABLE fixes HOT 5
- LD_LIBRARY_PATH support for packages using gnuinstalldirs HOT 4
- I can't build ros2 with the latest code of master branch HOT 2
- local_setup.bat fails if PYTHON_EXECUTABLE contains parentheses 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 ament_package.