summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-11 13:11:49 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-11 13:19:51 +0200
commit4752073b984845a407b45855d42f4d4733b49efd (patch)
treed4a22ba983ded872d7c7e93fc47d3e6b71e5f50e
parentd22a155812d4f24d6c6b1b3126635e41324e552a (diff)
downloadrules-cc-4752073b984845a407b45855d42f4d4733b49efd.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.
-rw-r--r--CC/foreign/cmake/EXPRESSIONS59
-rw-r--r--CC/foreign/make/EXPRESSIONS40
-rw-r--r--CC/foreign/shell/EXPRESSIONS50
3 files changed, 135 insertions, 14 deletions
diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS
index ee7c595..bf2385e 100644
--- a/CC/foreign/cmake/EXPRESSIONS
+++ b/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/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS
index 5f80fd8..bff8205 100644
--- a/CC/foreign/make/EXPRESSIONS
+++ b/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/CC/foreign/shell/EXPRESSIONS b/CC/foreign/shell/EXPRESSIONS
index 572835c..bf0ecdb 100644
--- a/CC/foreign/shell/EXPRESSIONS
+++ b/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 "