summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-02-14 17:20:48 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2023-05-30 15:33:18 +0200
commitf5fb09192d1ad244006964d2d1425506718d3e58 (patch)
tree2fe4b65b1286fd9d4e4832ad20bb46bd74297078
parent25cc5a5d9e225e8a1b8d1a7221eb1968b28d928d (diff)
downloadrules-cc-f5fb09192d1ad244006964d2d1425506718d3e58.tar.gz
rules-cc/foreign: Support project sub-directory
-rw-r--r--CC/foreign/cmake/EXPRESSIONS20
-rw-r--r--CC/foreign/cmake/RULES16
-rw-r--r--CC/foreign/make/EXPRESSIONS17
-rw-r--r--CC/foreign/make/RULES18
4 files changed, 56 insertions, 15 deletions
diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS
index be345c2..bdb05ce 100644
--- a/CC/foreign/cmake/EXPRESSIONS
+++ b/CC/foreign/cmake/EXPRESSIONS
@@ -1,6 +1,7 @@
{ "cmake-build":
{ "vars":
[ "source_dir"
+ , "cmake_subdir"
, "cmake_options"
, "cmake_defines"
, "cmake_jobs"
@@ -143,6 +144,12 @@
]
}
]
+ , [ "CMAKE_SUBDIR"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "var", "name": "cmake_subdir", "default": []}
+ }
+ ]
, [ "script"
, { "type": "singleton_map"
, "key": "run_cmake.sh"
@@ -169,9 +176,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 || (cat configure.log && exit 1)"
]
, [ { "type": "join"
, "separator": " "
@@ -222,7 +230,11 @@
, "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"}
]
}
diff --git a/CC/foreign/cmake/RULES b/CC/foreign/cmake/RULES
index 8651f4e..e5c7706 100644
--- a/CC/foreign/cmake/RULES
+++ b/CC/foreign/cmake/RULES
@@ -2,7 +2,8 @@
{ "doc": ["Data produced by CMake configure, build, and install."]
, "target_fields": ["project"]
, "string_fields":
- [ "options"
+ [ "subdir"
+ , "options"
, "defines"
, "jobs"
, "pre_cmds"
@@ -27,6 +28,10 @@
, "field_doc":
{ "project":
["The CMake project directory. It should contain a single tree artifact"]
+ , "subdir":
+ [ "The subdirectory that contains the entry CMakeLists.txt. Individual"
+ , "directory components are joined with \"/\"."
+ ]
, "options":
[ "CMake options for the configuration phase."
, "(e.g., [\"-GNinja\", \"-Ax64\"])"
@@ -162,6 +167,7 @@
}
}
]
+ , ["cmake_subdir", {"type": "FIELD", "name": "subdir"}]
, ["cmake_options", {"type": "FIELD", "name": "options"}]
, ["cmake_defines", {"type": "FIELD", "name": "defines"}]
, ["cmake_jobs", {"type": "FIELD", "name": "jobs"}]
@@ -218,7 +224,8 @@
{ "doc": ["Library produced by CMake configure, build, and install."]
, "target_fields": ["project", "deps"]
, "string_fields":
- [ "name"
+ [ "subdir"
+ , "name"
, "version"
, "stage"
, "options"
@@ -256,6 +263,10 @@
, "field_doc":
{ "project":
["The CMake project directory. It should contain a single tree artifact"]
+ , "subdir":
+ [ "The subdirectory that contains the entry CMakeLists.txt. Individual"
+ , "directory components are joined with \"/\"."
+ ]
, "name":
[ "The name of the library (without leading \"lib\" or trailing file name"
, "extension), also used as name for pkg-config files."
@@ -509,6 +520,7 @@
]
}
]
+ , ["cmake_subdir", {"type": "FIELD", "name": "subdir"}]
, ["cmake_options", {"type": "FIELD", "name": "options"}]
, ["cmake_defines", {"type": "FIELD", "name": "defines"}]
, ["cmake_jobs", {"type": "FIELD", "name": "jobs"}]
diff --git a/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS
index 3f04bbd..abe072d 100644
--- a/CC/foreign/make/EXPRESSIONS
+++ b/CC/foreign/make/EXPRESSIONS
@@ -1,7 +1,7 @@
{ "make-build":
{ "vars":
[ "source_dir"
- , "make_target"
+ , "subdir"
, "make_prefix"
, "make_options"
, "make_jobs"
@@ -203,6 +203,12 @@
]
}
]
+ , [ "SUBDIR"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "var", "name": "subdir", "default": []}
+ }
+ ]
, [ "script"
, { "type": "singleton_map"
, "key": "run_make.sh"
@@ -229,9 +235,11 @@
]
}
}
- , [ "readonly VAR_DESTDIR=$1"
- , "shift"
- , "make \"$@\" -C source ${VAR_DESTDIR}=$(pwd)/install >build.log || (cat build.log && exit 1)"
+ , [ "readonly SUBDIR=\"$1\""
+ , "readonly VAR_DESTDIR=$2"
+ , "shift 2"
+ ]
+ , [ "make \"$@\" -C \"source/${SUBDIR}\" ${VAR_DESTDIR}=$(pwd)/install >build.log || (cat build.log && exit 1)"
, "find ./install -type l -delete"
]
, { "type": "if"
@@ -266,6 +274,7 @@
{ "type": "++"
, "$1":
[ ["/bin/sh", "run_make.sh"]
+ , [{"type": "var", "name": "SUBDIR"}]
, { "type": "if"
, "cond": {"type": "var", "name": "var_destdir"}
, "then":
diff --git a/CC/foreign/make/RULES b/CC/foreign/make/RULES
index 9c8c738..7ae684f 100644
--- a/CC/foreign/make/RULES
+++ b/CC/foreign/make/RULES
@@ -2,7 +2,7 @@
{ "doc": ["Data produced by Make build and install."]
, "target_fields": ["project"]
, "string_fields":
- [ "target"
+ [ "subdir"
, "prefix"
, "options"
, "jobs"
@@ -37,7 +37,10 @@
, "field_doc":
{ "project":
["The Make project directory. It should contain a single tree artifact"]
- , "target": ["The Make target to build (default: [\"install\"])."]
+ , "subdir":
+ [ "The subdirectory that contains the configure and Makefile. Individual"
+ , "directory components are joined with \"/\"."
+ ]
, "prefix":
[ "The prefix used for the Make target. The path will be made absolute"
, "and individual directory components are joined with \"/\". If no"
@@ -195,7 +198,7 @@
}
}
]
- , ["make_target", {"type": "FIELD", "name": "target"}]
+ , ["subdir", {"type": "FIELD", "name": "subdir"}]
, ["make_prefix", {"type": "FIELD", "name": "prefix"}]
, ["make_options", {"type": "FIELD", "name": "options"}]
, ["make_jobs", {"type": "FIELD", "name": "jobs"}]
@@ -258,7 +261,8 @@
{ "doc": ["Library produced by Make build and install."]
, "target_fields": ["project", "deps"]
, "string_fields":
- [ "name"
+ [ "subdir"
+ , "name"
, "version"
, "stage"
, "target"
@@ -306,6 +310,10 @@
, "field_doc":
{ "project":
["The Make project directory. It should contain a single tree artifact"]
+ , "subdir":
+ [ "The subdirectory that contains the configure and Makefile. Individual"
+ , "directory components are joined with \"/\"."
+ ]
, "name":
[ "The name of the library (without leading \"lib\" or trailing file name"
, "extension), also used as name for pkg-config files."
@@ -581,7 +589,7 @@
]
}
]
- , ["make_target", {"type": "FIELD", "name": "target"}]
+ , ["subdir", {"type": "FIELD", "name": "subdir"}]
, ["make_prefix", {"type": "FIELD", "name": "prefix"}]
, ["make_options", {"type": "FIELD", "name": "options"}]
, ["make_jobs", {"type": "FIELD", "name": "jobs"}]