diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-05-30 15:38:40 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-05-30 15:38:40 +0200 |
commit | 14300d3768522b1a201c30c94b6e54e096520b20 (patch) | |
tree | eaa057fd88ddba1a94c48585fcfcbb71628fcbe7 /rules/CC/foreign/cmake/EXPRESSIONS | |
parent | 2d7051782625966857286aace6ff18760114ecc7 (diff) | |
parent | 9f535dadf06c6c6554bac632069777cf1b63ebf5 (diff) | |
download | rules-cc-14300d3768522b1a201c30c94b6e54e096520b20.tar.gz |
Merge commit '9f535dadf06c6c6554bac632069777cf1b63ebf5' into rules/rules-cc
Diffstat (limited to 'rules/CC/foreign/cmake/EXPRESSIONS')
-rw-r--r-- | rules/CC/foreign/cmake/EXPRESSIONS | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/rules/CC/foreign/cmake/EXPRESSIONS b/rules/CC/foreign/cmake/EXPRESSIONS index 8977d5a..4c21f4b 100644 --- a/rules/CC/foreign/cmake/EXPRESSIONS +++ b/rules/CC/foreign/cmake/EXPRESSIONS @@ -1,6 +1,7 @@ { "cmake-build": { "vars": [ "source_dir" + , "cmake_subdir" , "cmake_options" , "cmake_defines" , "cmake_jobs" @@ -27,11 +28,24 @@ , "default-LDFLAGS": ["CC", "default-LDFLAGS"] , "default-AR": ["CC", "default-AR"] , "default-ENV": ["CC", "default-ENV"] + , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"] + , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"] } , "expression": { "type": "let*" , "bindings": - [ [ "CMAKE_FLAGS" + [ ["TOOLCHAIN_DIR", "toolchain"] + , ["TOOLCHAIN", {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}] + , [ "TOOLCHAIN" + , { "type": "to_subdir" + , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"} + , "$1": {"type": "var", "name": "TOOLCHAIN"} + } + ] + , [ "NON_SYSTEM_TOOLS" + , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"} + ] + , [ "CMAKE_FLAGS" , { "type": "++" , "$1": [ { "type": "foreach" @@ -47,6 +61,7 @@ , "cond": {"type": "var", "name": "BUILD_POSITION_INDEPENDENT"} , "then": ["-DCMAKE_POSITION_INDEPENDENT_CODE=ON"] } + , ["-DCMAKE_INSTALL_RPATH=$ORIGIN;$ORIGIN/../lib"] ] } ] @@ -84,26 +99,35 @@ , [ "ENV" , { "type": "map_union" , "$1": - { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} - , [ { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - ] - , [ { "type": "env" - , "vars": ["CC", "CXX", "CXXFLAGS", "CFLAGS", "LDFLAGS"] - } - ] - ] - } + [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} + , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}} + , { "type": "env" + , "vars": ["CC", "CXX", "CXXFLAGS", "CFLAGS", "LDFLAGS"] + } + ] } ] , [ "AR" , { "type": "var" , "name": "AR" - , "default": {"type": "CALL_EXPRESSION", "name": "default-AR"} + , "default": + { "type": "join" + , "$1": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": + { "type": "lookup" + , "key": "AR" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": + ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"] + } + , {"type": "CALL_EXPRESSION", "name": "default-AR"} + ] + } + } } ] , [ "CMAKE_JOBS" @@ -121,6 +145,12 @@ ] } ] + , [ "CMAKE_SUBDIR" + , { "type": "join" + , "separator": "/" + , "$1": {"type": "var", "name": "cmake_subdir", "default": []} + } + ] , [ "script" , { "type": "singleton_map" , "key": "run_cmake.sh" @@ -147,9 +177,10 @@ ] } } - , [ "readonly CMAKE_AR=$(which $1)" - , "shift" - , "cmake \"$@\" -Ssource -Bbuild -DCMAKE_AR=${CMAKE_AR} -DCMAKE_INSTALL_PREFIX=./install >configure.log || (cat configure.log && exit 1)" + , [ "readonly CMAKE_SUBDIR=\"$1\"" + , "readonly CMAKE_AR=$(which $2)" + , "shift 2" + , "cmake \"$@\" -S\"source/${CMAKE_SUBDIR}\" -Bbuild -DCMAKE_AR=${CMAKE_AR} -DCMAKE_INSTALL_PREFIX=./install >configure.log 2>&1 || (cat configure.log && exit 1)" ] , [ { "type": "join" , "separator": " " @@ -157,7 +188,7 @@ { "type": "++" , "$1": [ {"type": "var", "name": "CMAKE_JOBS"} - , [ "cmake --build build --target install >build.log || (cat configure.log build.log && exit 1)" + , [ "cmake --build build --target install >build.log 2>&1 || (cat configure.log build.log && exit 1)" ] ] } @@ -192,14 +223,19 @@ , "inputs": { "type": "map_union" , "$1": - [ {"type": "var", "name": "source_dir"} + [ {"type": "var", "name": "TOOLCHAIN"} + , {"type": "var", "name": "source_dir"} , {"type": "var", "name": "script"} ] } , "cmd": { "type": "++" , "$1": - [ ["/bin/sh", "run_cmake.sh", {"type": "var", "name": "AR"}] + [ [ "/bin/sh" + , "run_cmake.sh" + , {"type": "var", "name": "CMAKE_SUBDIR"} + , {"type": "var", "name": "AR"} + ] , {"type": "var", "name": "CMAKE_FLAGS"} ] } |