summaryrefslogtreecommitdiff
path: root/rules/CC/foreign/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'rules/CC/foreign/cmake')
-rw-r--r--rules/CC/foreign/cmake/EXPRESSIONS61
-rw-r--r--rules/CC/foreign/cmake/RULES56
2 files changed, 105 insertions, 12 deletions
diff --git a/rules/CC/foreign/cmake/EXPRESSIONS b/rules/CC/foreign/cmake/EXPRESSIONS
index a3fd429..4dfcc07 100644
--- a/rules/CC/foreign/cmake/EXPRESSIONS
+++ b/rules/CC/foreign/cmake/EXPRESSIONS
@@ -3,6 +3,9 @@
[ "source_dir"
, "cmake_options"
, "cmake_defines"
+ , "cmake_jobs"
+ , "pre_cmds"
+ , "post_cmds"
, "CC"
, "CXX"
, "CFLAGS"
@@ -44,7 +47,6 @@
, "cond": {"type": "var", "name": "BUILD_POSITION_INDEPENDENT"}
, "then": ["-DCMAKE_POSITION_INDEPENDENT_CODE=ON"]
}
- , [{"type": "join", "$1": ["-DCMAKE_AR=/usr/bin/ar"]}]
]
}
]
@@ -79,6 +81,11 @@
}
}
]
+ , [ "CMAKE_BUILD_PARALLEL_LEVEL"
+ , { "type": "join"
+ , "$1": {"type": "var", "name": "cmake_jobs", "default": []}
+ }
+ ]
, [ "ENV"
, { "type": "map_union"
, "$1":
@@ -91,7 +98,14 @@
}
]
, [ { "type": "env"
- , "vars": ["CC", "CXX", "CXXFLAGS", "CFLAGS", "LDFLAGS"]
+ , "vars":
+ [ "CC"
+ , "CXX"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "LDFLAGS"
+ , "CMAKE_BUILD_PARALLEL_LEVEL"
+ ]
}
]
]
@@ -113,13 +127,42 @@
{ "type": "join"
, "separator": "\n"
, "$1":
- [ "set -eu"
- , "readonly CMAKE_AR=$(which $1)"
- , "shift"
- , "cmake \"$@\" -Ssource -Bbuild -DCMAKE_AR=${CMAKE_AR} -DCMAKE_INSTALL_PREFIX=./install >configure.log || (cat configure.log && exit 1)"
- , "cmake --build build --target install >build.log || (cat configure.log build.log && exit 1)"
- , "find ./install -type l -delete"
- ]
+ { "type": "++"
+ , "$1":
+ [ [ "set -eu"
+ , "mkdir scratch"
+ , "readonly TMPDIR=\"$(pwd)/scratch\""
+ ]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "pre_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["(", "set --", "cd ./source"]
+ , {"type": "var", "name": "pre_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ , [ "readonly CMAKE_AR=$(which $1)"
+ , "shift"
+ , "cmake \"$@\" -Ssource -Bbuild -DCMAKE_AR=${CMAKE_AR} -DCMAKE_INSTALL_PREFIX=./install >configure.log || (cat configure.log && exit 1)"
+ , "cmake --build build --target install >build.log || (cat configure.log build.log && exit 1)"
+ , "find ./install -type l -delete"
+ ]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "post_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["(", "set --", "cd ./install"]
+ , {"type": "var", "name": "post_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ ]
+ }
}
}
}
diff --git a/rules/CC/foreign/cmake/RULES b/rules/CC/foreign/cmake/RULES
index 8ca23e8..8e8b934 100644
--- a/rules/CC/foreign/cmake/RULES
+++ b/rules/CC/foreign/cmake/RULES
@@ -1,7 +1,15 @@
{ "data":
{ "doc": ["Data produced by CMake configure, build, and install."]
, "target_fields": ["project"]
- , "string_fields": ["options", "defines", "out_files", "out_dirs"]
+ , "string_fields":
+ [ "options"
+ , "defines"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "out_files"
+ , "out_dirs"
+ ]
, "config_vars":
[ "CC"
, "CXX"
@@ -27,6 +35,23 @@
[ "CMake defines for the configuration phase."
, "(e.g., [\"CMAKE_BUILD_TYPE=Release\"])"
]
+ , "jobs":
+ [ "Number of jobs to run simultaneously. If omitted, CMake's default"
+ , "number is used."
+ ]
+ , "pre_cmds":
+ [ "List of commands executed in the project directory before calling"
+ , "CMake. Useful for renaming files or directories. Note that data"
+ , "between \"pre_cmds\" and \"post_cmds\" can be exchanged via $TMPDIR,"
+ , "which is uniquely reserved for this action."
+ ]
+ , "post_cmds":
+ [ "List of commands executed in the install directory after successful"
+ , "installation but before the output files are collected. Useful for"
+ , "renaming files or directories. Note that data between \"pre_cmds\" and"
+ , "\"post_cmds\" can be exchanged via $TMPDIR, which is uniquely reserved"
+ , "for this action."
+ ]
, "out_files":
[ "Paths to the produced output files. The paths are considered relative"
, "to the install directory."
@@ -138,6 +163,9 @@
]
, ["cmake_options", {"type": "FIELD", "name": "options"}]
, ["cmake_defines", {"type": "FIELD", "name": "defines"}]
+ , ["cmake_jobs", {"type": "FIELD", "name": "jobs"}]
+ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}]
+ , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}]
, [ "full_install_dir"
, {"type": "CALL_EXPRESSION", "name": "cmake-build"}
]
@@ -173,8 +201,7 @@
, "body":
{ "type": "RESULT"
, "artifacts":
- { "type": "var"
- , "name": "map_union"
+ { "type": "map_union"
, "$1":
{ "type": "++"
, "$1":
@@ -195,6 +222,9 @@
, "stage"
, "options"
, "defines"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
, "out_hdrs"
, "out_hdr_dirs"
, "out_libs"
@@ -241,6 +271,23 @@
[ "CMake defines for the configuration phase."
, "(e.g., [\"CMAKE_BUILD_TYPE=Release\"])"
]
+ , "jobs":
+ [ "Number of jobs to run simultaneously. If omitted, CMake's default"
+ , "number is used."
+ ]
+ , "pre_cmds":
+ [ "List of commands executed in the project directory before calling"
+ , "CMake. Useful for renaming files or directories. Note that data"
+ , "between \"pre_cmds\" and \"post_cmds\" can be exchanged via $TMPDIR,"
+ , "which is uniquely reserved for this action."
+ ]
+ , "post_cmds":
+ [ "List of commands executed in the install directory after successful"
+ , "installation but before the output files are collected. Useful for"
+ , "renaming files or directories (e.g., in case of SONAME mismatch). Note"
+ , "that data between \"pre_cmds\" and \"post_cmds\" can be exchanged via"
+ , "$TMPDIR, which is uniquely reserved for this action."
+ ]
, "out_hdrs":
[ "Paths to produced public header files. The path is considered"
, "relative to the include directory, which be set via \"hdr_prefix\"."
@@ -461,6 +508,9 @@
]
, ["cmake_options", {"type": "FIELD", "name": "options"}]
, ["cmake_defines", {"type": "FIELD", "name": "defines"}]
+ , ["cmake_jobs", {"type": "FIELD", "name": "jobs"}]
+ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}]
+ , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}]
, [ "full_install_dir"
, {"type": "CALL_EXPRESSION", "name": "cmake-build"}
]