diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-16 15:10:31 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-16 15:37:37 +0200 |
commit | 54bb2a33b3e36123f8f411f77ec8e76f5b021e3d (patch) | |
tree | f1ccc4416475df33a9e494cf8e27d5843bbc6a3f /CC/foreign/cmake/EXPRESSIONS | |
parent | ebf3cf04bc80ae7bf083220e63e739bf32151c95 (diff) | |
download | rules-cc-54bb2a33b3e36123f8f411f77ec8e76f5b021e3d.tar.gz |
rules: Propagate PATH list from defaults
... instead of creating an ENV from it and propagating this.
The idea is to keep PATH entries separate and only join them
with ":" when we need it. In this way, we can accumulate
PATHs from multiple defaults later, and perform a
deduplication ("nub_left") to shorten the final string
length.
Diffstat (limited to 'CC/foreign/cmake/EXPRESSIONS')
-rw-r--r-- | CC/foreign/cmake/EXPRESSIONS | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS index 2266f61..ac7039c 100644 --- a/CC/foreign/cmake/EXPRESSIONS +++ b/CC/foreign/cmake/EXPRESSIONS @@ -27,6 +27,7 @@ ] , "imports": { "artifacts": ["", "field_artifacts"] + , "nub_left": ["", "nub_left"] , "flags-cc": ["CC", "flags-cc"] , "flags-cxx": ["CC", "flags-cxx"] , "compiler-cc": ["CC", "compiler-cc"] @@ -34,6 +35,7 @@ , "default-LDFLAGS": ["CC", "default-LDFLAGS"] , "default-AR": ["CC", "default-AR"] , "default-ENV": ["CC", "default-ENV"] + , "default-PATH": ["CC", "default-PATH"] , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"] , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"] , "expand_exec_tool": ["./", "..", "expand_exec_tool"] @@ -136,14 +138,25 @@ } } ] + , [ "PATH" + , { "type": "join" + , "separator": ":" + , "$1": + { "type": "let*" + , "bindings": + [["list", {"type": "CALL_EXPRESSION", "name": "default-PATH"}]] + , "body": {"type": "CALL_EXPRESSION", "name": "nub_left"} + } + } + ] , [ "ENV" , { "type": "map_union" , "$1": - [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} - , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}} - , { "type": "env" + [ { "type": "env" , "vars": ["CC", "CXX", "CXXFLAGS", "CFLAGS", "LDFLAGS", "AR"] } + , {"type": "CALL_EXPRESSION", "name": "default-ENV"} + , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}} ] } ] @@ -190,7 +203,17 @@ , "mkdir scratch" , "readonly ROOT=\"$(pwd)\"" , "export TMPDIR=\"$(pwd)/scratch\"" + , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" + , { "type": "join" + , "$1": + [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " + , { "type": "join_cmd" + , "$1": [{"type": "var", "name": "PATH"}] + } + , ")\":$PATH" + ] + } ] , { "type": "if" , "cond": {"type": "var", "name": "pre_cmds"} |