summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-07-03 16:42:59 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-07-10 11:26:29 +0200
commit642f0b1637a331b072d63138157bae23b14c7b59 (patch)
tree2e33d795d51285774ce591eae2575725e0c11f15
parent8c8b65522659a0b476cc3943ff4555eb351164ae (diff)
downloadrules-cc-642f0b1637a331b072d63138157bae23b14c7b59.tar.gz
cmake: Support "targets" field
-rw-r--r--CC/foreign/cmake/EXPRESSIONS22
-rw-r--r--CC/foreign/cmake/RULES6
2 files changed, 25 insertions, 3 deletions
diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS
index c7e35b8..2266f61 100644
--- a/CC/foreign/cmake/EXPRESSIONS
+++ b/CC/foreign/cmake/EXPRESSIONS
@@ -8,6 +8,7 @@
, "cmake_options"
, "cmake_defines"
, "cmake_jobs"
+ , "cmake_targets"
, "pre_cmds"
, "post_cmds"
, "CC"
@@ -167,6 +168,13 @@
, "$1": {"type": "var", "name": "cmake_subdir", "default": []}
}
]
+ , [ "cmake_targets"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "cmake_targets"}
+ , "then": {"type": "var", "name": "cmake_targets"}
+ , "else": ["install"]
+ }
+ ]
, [ "script"
, { "type": "singleton_map"
, "key": "run_cmake.sh"
@@ -200,18 +208,26 @@
, "shift 2"
, "${ROOT}/expand_exec TMPDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR -- cmake -S\"source/${CMAKE_SUBDIR}\" -Bbuild -DCMAKE_AR=${CMAKE_AR} -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_PREFIX_PATH=\"$LOCALBASE\" -DPKG_CONFIG_ARGN=--define-prefix --no-warn-unused-cli \"$@\" >configure.log 2>&1 || (cat configure.log && exit 1)"
]
- , [ { "type": "join"
+ , { "type": "foreach"
+ , "range": {"type": "var", "name": "cmake_targets"}
+ , "var": "target"
+ , "body":
+ { "type": "join"
, "separator": " "
, "$1":
{ "type": "++"
, "$1":
[ {"type": "var", "name": "CMAKE_JOBS"}
- , [ "${ROOT}/expand_exec TMPDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR -- cmake --build build --target install >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , [ "${ROOT}/expand_exec TMPDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR -- cmake --build build --target"
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "target"}]
+ }
+ , ">>build.log 2>&1 || (cat build.log && exit 1)"
]
]
}
}
- ]
+ }
, ["find ./install -type l -delete"]
, { "type": "if"
, "cond": {"type": "var", "name": "post_cmds"}
diff --git a/CC/foreign/cmake/RULES b/CC/foreign/cmake/RULES
index 0b1086c..63d6e48 100644
--- a/CC/foreign/cmake/RULES
+++ b/CC/foreign/cmake/RULES
@@ -12,6 +12,7 @@
[ "subdir"
, "options"
, "defines"
+ , "targets"
, "jobs"
, "pre_cmds"
, "post_cmds"
@@ -50,6 +51,10 @@
[ "CMake defines for the configuration phase."
, "(e.g., [\"CMAKE_BUILD_TYPE=Release\"])"
]
+ , "targets":
+ [ "The CMake targets to build in the specified order"
+ , "(default: [\"install\"])."
+ ]
, "jobs":
[ "Number of jobs to run simultaneously. If omitted, CMake's default"
, "number is used."
@@ -190,6 +195,7 @@
, ["cmake_subdir", {"type": "FIELD", "name": "subdir"}]
, ["cmake_options", {"type": "FIELD", "name": "options"}]
, ["cmake_defines", {"type": "FIELD", "name": "defines"}]
+ , ["cmake_targets", {"type": "FIELD", "name": "targets"}]
, ["cmake_jobs", {"type": "FIELD", "name": "jobs"}]
, ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}]
, ["post_cmds", {"type": "FIELD", "name": "post_cmds"}]