diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-11 13:11:49 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-11 13:19:51 +0200 |
commit | 32c961b53e1cbb3b57ca39174986b5d1f26b307a (patch) | |
tree | 86b5c5c2051244f1595f07d0c5273a730612fa84 /rules | |
parent | cd7fc8c3fcb04a164ed5d53b76523e6217212114 (diff) | |
download | rules-cc-32c961b53e1cbb3b57ca39174986b5d1f26b307a.tar.gz |
foreign rules: fix computation of absolute paths
When setting CC, etc, in foreign rules, it is often useful to have it
set as absolute path. This originally was achieved using realpath(1).
This, however, implies that symbolic links are followed as well,
which confuses some compilers if they are not called with correct
argv[0]. Therefore, 4e86f756bddca8db402502be47c0825e1e2aeb0d tries
to replace this by concatenation with $(pwd), which, however, is
only correct for tools brought locally by the toolchain. Hence fix
the test by not evaluating it in the shell at all and rather using
the knowledge about toolchain versus system tools that the rules
have anyway.
Diffstat (limited to 'rules')
-rw-r--r-- | rules/CC/foreign/cmake/EXPRESSIONS | 59 | ||||
-rw-r--r-- | rules/CC/foreign/make/EXPRESSIONS | 40 | ||||
-rw-r--r-- | rules/CC/foreign/shell/EXPRESSIONS | 50 |
3 files changed, 135 insertions, 14 deletions
diff --git a/rules/CC/foreign/cmake/EXPRESSIONS b/rules/CC/foreign/cmake/EXPRESSIONS index ee7c595..bf2385e 100644 --- a/rules/CC/foreign/cmake/EXPRESSIONS +++ b/rules/CC/foreign/cmake/EXPRESSIONS @@ -310,11 +310,60 @@ , "export TMPDIR=\"$(pwd)/scratch\"" , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" - , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" - , "export CMAKE=$([ -x \"${CMAKE}\" ] && echo $(pwd)/${CMAKE} || echo ${CMAKE})" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CC" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CC=$(pwd)/${CC}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CXX" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CXX=$(pwd)/${CXX}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "AR" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export AR=$(pwd)/${AR}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "MAKE" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export MAKE=$(pwd)/${MAKE}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CMAKE" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CMAKE=$(pwd)/${CMAKE}" + , "else": "" + } + , { "type": "join" + , "$1": + [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " + , { "type": "join_cmd" + , "$1": [{"type": "var", "name": "PATH"}] + } + , ")${PATH:+:}${PATH}\"" + ] + } , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " diff --git a/rules/CC/foreign/make/EXPRESSIONS b/rules/CC/foreign/make/EXPRESSIONS index 5f80fd8..bff8205 100644 --- a/rules/CC/foreign/make/EXPRESSIONS +++ b/rules/CC/foreign/make/EXPRESSIONS @@ -288,10 +288,42 @@ , "export DESTDIR=\"$(pwd)/install\"" , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" - , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CC" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CC=$(pwd)/${CC}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CXX" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CXX=$(pwd)/${CXX}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "AR" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export AR=$(pwd)/${AR}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "MAKE" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export MAKE=$(pwd)/${MAKE}" + , "else": "" + } , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " diff --git a/rules/CC/foreign/shell/EXPRESSIONS b/rules/CC/foreign/shell/EXPRESSIONS index 572835c..bf0ecdb 100644 --- a/rules/CC/foreign/shell/EXPRESSIONS +++ b/rules/CC/foreign/shell/EXPRESSIONS @@ -240,11 +240,51 @@ , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" , "export DESTDIR=\"$(pwd)/install\"" - , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" - , "export CMAKE=$([ -x \"${CMAKE}\" ] && echo $(pwd)/${CMAKE} || echo ${CMAKE})" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CC" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CC=$(pwd)/${CC}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CXX" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CXX=$(pwd)/${CXX}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "AR" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export AR=$(pwd)/${AR}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "MAKE" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export MAKE=$(pwd)/${MAKE}" + , "else": "" + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "CMAKE" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": "export CMAKE=$(pwd)/${CMAKE}" + , "else": "" + } , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " |