summaryrefslogtreecommitdiff
path: root/rules/CC/foreign
diff options
context:
space:
mode:
Diffstat (limited to 'rules/CC/foreign')
-rw-r--r--rules/CC/foreign/EXPRESSIONS123
-rw-r--r--rules/CC/foreign/RULES162
-rw-r--r--rules/CC/foreign/TARGETS7
-rw-r--r--rules/CC/foreign/cmake/EXPRESSIONS484
-rw-r--r--rules/CC/foreign/cmake/RULES772
-rwxr-xr-xrules/CC/foreign/expand_exec133
-rw-r--r--rules/CC/foreign/expand_exec.c99
-rw-r--r--rules/CC/foreign/make/EXPRESSIONS445
-rw-r--r--rules/CC/foreign/make/RULES803
-rw-r--r--rules/CC/foreign/shell/EXPRESSIONS363
-rw-r--r--rules/CC/foreign/shell/RULES624
11 files changed, 4015 insertions, 0 deletions
diff --git a/rules/CC/foreign/EXPRESSIONS b/rules/CC/foreign/EXPRESSIONS
new file mode 100644
index 0000000..2988b32
--- /dev/null
+++ b/rules/CC/foreign/EXPRESSIONS
@@ -0,0 +1,123 @@
+{ "default-MAKE":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "foreign-defaults"]
+ , ["provider", "MAKE"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-CMAKE":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "foreign-defaults"]
+ , ["provider", "CMAKE"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-ENV":
+ { "vars": ["defaults-transition"]
+ , "imports": {"map_provider": ["", "field_map_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "foreign-defaults"]
+ , ["provider", "ENV"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+, "default-PATH":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "foreign-defaults"]
+ , ["provider", "PATH"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-TOOLCHAIN":
+ { "vars": ["defaults-transition"]
+ , "imports": {"map_provider": ["", "field_map_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "foreign-defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+, "default-NON_SYSTEM_TOOLS":
+ { "vars": ["defaults-transition"]
+ , "expression":
+ { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "x"
+ , "range": {"type": "FIELD", "name": "foreign-defaults"}
+ , "body":
+ { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "x"}
+ , "provider": "NON_SYSTEM_TOOLS"
+ , "transition":
+ { "type": "var"
+ , "name": "defaults-transition"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": {"type": "empty_map"}
+ }
+ }
+ }
+ }
+, "strip-prefix":
+ { "doc":
+ [ "Returns list of artifact maps (each map contains a single artifact)"
+ , "with the given prefix being stripped from their path."
+ ]
+ , "vars": ["artifacts", "paths", "prefix"]
+ , "vars_doc":
+ { "artifacts": ["A single map containing all artifacts."]
+ , "paths": ["List of (unprefixed) artifacts paths to consider."]
+ , "prefix": ["Prefix to strip from the artifact's path."]
+ }
+ , "expression":
+ { "type": "foreach"
+ , "var": "path"
+ , "range": {"type": "var", "name": "paths"}
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "path"}
+ , "value":
+ { "type": "lookup"
+ , "key":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "prefix"}
+ , {"type": "var", "name": "path"}
+ ]
+ }
+ , "map": {"type": "var", "name": "artifacts"}
+ }
+ }
+ }
+ }
+}
diff --git a/rules/CC/foreign/RULES b/rules/CC/foreign/RULES
new file mode 100644
index 0000000..e6463f8
--- /dev/null
+++ b/rules/CC/foreign/RULES
@@ -0,0 +1,162 @@
+{ "defaults":
+ { "doc":
+ [ "A rule to provide defaults for foreign rules."
+ , "All foreign rules take their defaults for MAKE, CMAKE, etc from"
+ , "the target [\"CC/foreign\", \"defaults\"]."
+ ]
+ , "target_fields": ["base", "toolchain"]
+ , "string_fields": ["MAKE", "CMAKE", "PATH", "SYSTEM_TOOLS"]
+ , "field_doc":
+ { "base": ["Other targets (using the same rule) to inherit values from."]
+ , "toolchain":
+ [ "Optional toolchain directory. A collection of artifacts that provide"
+ , "the tools MAKE, CMAKE. Note that only artifacts of"
+ , "the specified targets are considered (no runfiles etc.). Specifying"
+ , "this field extends artifacts from \"base\"."
+ ]
+ , "MAKE": ["The make binary to use"]
+ , "CMAKE": ["The cmake binary to use"]
+ , "SYSTEM_TOOLS":
+ [ "List of tools (\"MAKE\", \"CMAKE\") that should be taken from"
+ , "the system instead of from \"toolchain\" (if specified)."
+ ]
+ , "PATH":
+ [ "Path for looking up the tools. Individual paths are joined with"
+ , "with \":\". Specifying this field extends values from \"base\"."
+ ]
+ }
+ , "config_vars": ["ARCH", "HOST_ARCH"]
+ , "imports":
+ { "base-provides": ["./", "..", "defaults-base-provides"]
+ , "base-provides-++": ["./", "..", "defaults-base-provides-++"]
+ , "base-provides-list": ["./", "..", "defaults-base-provides-list"]
+ , "artifacts_list": ["./", "../..", "field_artifacts_list"]
+ , "for host": ["transitions", "for host"]
+ }
+ , "config_transitions":
+ {"toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["MAKE", {"type": "FIELD", "name": "MAKE"}]
+ , ["CMAKE", {"type": "FIELD", "name": "CMAKE"}]
+ , ["PATH", {"type": "FIELD", "name": "PATH"}]
+ , ["provider", "MAKE"]
+ , [ "MAKE"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "MAKE"}
+ , "then": {"type": "var", "name": "MAKE"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "CMAKE"]
+ , [ "CMAKE"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "CMAKE"}
+ , "then": {"type": "var", "name": "CMAKE"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "PATH"]
+ , [ "PATH"
+ , { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
+ ]
+ }
+ }
+ ]
+ , ["provider", "ENV"]
+ , ["default", {"type": "empty_map"}]
+ , ["ENV", {"type": "CALL_EXPRESSION", "name": "base-provides"}]
+ , ["provider", "NON_SYSTEM_TOOLS"]
+ , ["default", {"type": "empty_map"}]
+ , [ "NON_SYSTEM_TOOLS"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "base-provides-list"}
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "MAKE"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "MAKE"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "CMAKE"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "CMAKE"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "SYSTEM_TOOLS"}
+ , "var": "tool"
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "tool"}
+ , "value": false
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ , [ "TOOLCHAIN"
+ , { "type": "disjoint_map_union"
+ , "msg": "toolchain artifacts may not overlap"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "base-provides-list"}
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "toolchain"]
+ , [ "transition"
+ , {"type": "CALL_EXPRESSION", "name": "for host"}
+ ]
+ ]
+ , "body":
+ {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "provides":
+ { "type": "env"
+ , "vars":
+ ["MAKE", "CMAKE", "PATH", "ENV", "TOOLCHAIN", "NON_SYSTEM_TOOLS"]
+ }
+ }
+ }
+ }
+}
diff --git a/rules/CC/foreign/TARGETS b/rules/CC/foreign/TARGETS
new file mode 100644
index 0000000..5fbb6a9
--- /dev/null
+++ b/rules/CC/foreign/TARGETS
@@ -0,0 +1,7 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make"]
+ , "CMAKE": ["cmake"]
+ , "PATH": ["/bin", "/usr/bin"]
+ }
+}
diff --git a/rules/CC/foreign/cmake/EXPRESSIONS b/rules/CC/foreign/cmake/EXPRESSIONS
new file mode 100644
index 0000000..e8217dd
--- /dev/null
+++ b/rules/CC/foreign/cmake/EXPRESSIONS
@@ -0,0 +1,484 @@
+{ "cmake-build":
+ { "vars":
+ [ "ARCH"
+ , "HOST_ARCH"
+ , "source_dir"
+ , "cmake_subdir"
+ , "localbase_dir"
+ , "cmake_options"
+ , "cmake_defines"
+ , "cmake_jobs"
+ , "cmake_targets"
+ , "pre_cmds"
+ , "post_cmds"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "defaults-transition"
+ , "expand_exec"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ , "resolve_symlinks"
+ ]
+ , "imports":
+ { "artifacts": ["", "field_artifacts"]
+ , "flags-cc": ["CC", "flags-cc"]
+ , "flags-cxx": ["CC", "flags-cxx"]
+ , "compiler-cc": ["CC", "compiler-cc"]
+ , "compiler-cxx": ["CC", "compiler-cxx"]
+ , "default-LDFLAGS": ["CC", "default-LDFLAGS"]
+ , "default-AR": ["CC", "default-AR"]
+ , "default-ENV": ["CC", "default-ENV"]
+ , "default-PATH": ["CC", "default-PATH"]
+ , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"]
+ , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"]
+ , "foreign-MAKE": ["CC/foreign", "default-MAKE"]
+ , "foreign-CMAKE": ["CC/foreign", "default-CMAKE"]
+ , "foreign-ENV": ["CC/foreign", "default-ENV"]
+ , "foreign-PATH": ["CC/foreign", "default-PATH"]
+ , "foreign-TOOLCHAIN": ["CC/foreign", "default-TOOLCHAIN"]
+ , "foreign-NON_SYSTEM_TOOLS": ["CC/foreign", "default-NON_SYSTEM_TOOLS"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ , "sh-PATH": ["shell", "PATH"]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "disjoint_map_union"
+ , "msg": "Toolchain trees may not overlap"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-TOOLCHAIN"}
+ , {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}
+ , {"type": "var", "name": "shell TOOLCHAIN"}
+ ]
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ ]
+ , [ "NON_SYSTEM_TOOLS"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-NON_SYSTEM_TOOLS"}
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
+ }
+ ]
+ , [ "CMAKE_FLAGS"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "define"
+ , "range": {"type": "var", "name": "cmake_defines"}
+ , "body":
+ { "type": "join"
+ , "$1": ["-D", {"type": "var", "name": "define"}]
+ }
+ }
+ , {"type": "var", "name": "cmake_options"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "BUILD_POSITION_INDEPENDENT"}
+ , "then": ["-DCMAKE_POSITION_INDEPENDENT_CODE=ON"]
+ }
+ , ["-DCMAKE_INSTALL_RPATH=$ORIGIN;$ORIGIN/../lib"]
+ ]
+ }
+ ]
+ , ["BUILD_POSITION_INDEPENDENT", null]
+ , [ "MAKE"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "MAKE"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "foreign-MAKE"}
+ ]
+ }
+ }
+ ]
+ , [ "CMAKE"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "CMAKE"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "foreign-CMAKE"}
+ ]
+ }
+ }
+ ]
+ , ["CC", {"type": "CALL_EXPRESSION", "name": "compiler-cc"}]
+ , ["CXX", {"type": "CALL_EXPRESSION", "name": "compiler-cxx"}]
+ , [ "CFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cc"}
+ }
+ ]
+ , [ "CXXFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cxx"}
+ }
+ ]
+ , [ "LDFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "var"
+ , "name": "LDFLAGS"
+ , "default":
+ {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ }
+ , {"type": "var", "name": "ldflags", "default": []}
+ ]
+ }
+ }
+ ]
+ , [ "AR"
+ , { "type": "var"
+ , "name": "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"}
+ ]
+ }
+ }
+ }
+ ]
+ , [ "sh-PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh-PATH"}
+ }
+ }
+ ]
+ , [ "sh-ENV"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "sh-PATH"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": {"type": "var", "name": "sh-PATH"}
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , [ "PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ ]
+ }
+ }
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "CC"
+ , "CXX"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "LDFLAGS"
+ , "AR"
+ , "MAKE"
+ , "CMAKE"
+ ]
+ }
+ , {"type": "var", "name": "sh-ENV"}
+ , {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , {"type": "CALL_EXPRESSION", "name": "foreign-ENV"}
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "CMAKE_JOBS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "cmake_jobs"}
+ , "then":
+ [ { "type": "join"
+ , "$1":
+ [ "CMAKE_BUILD_PARALLEL_LEVEL="
+ , { "type": "join_cmd"
+ , "$1": {"type": "var", "name": "cmake_jobs"}
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ , [ "CMAKE_SUBDIR"
+ , { "type": "join"
+ , "separator": "/"
+ , "$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"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [ "set -eu"
+ , "mkdir -p scratch install"
+ , "readonly ROOT=\"$(pwd)\""
+ , "export TMPDIR=\"$(pwd)/scratch\""
+ , "export TOOLCHAIN=\"$(pwd)/toolchain\""
+ , "export LOCALBASE=\"$(pwd)/localbase\""
+ , { "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="
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "PATH"}]
+ }
+ , "${PATH:+:}\"${PATH}\""
+ ]
+ }
+ ]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "pre_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["(", "set --", "cd ./source"]
+ , {"type": "var", "name": "pre_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ , [ "readonly CMAKE_SUBDIR=\"$1\""
+ , "readonly CMAKE_AR=$(command -v $2)"
+ , "shift 2"
+ ]
+ , [ { "type": "join"
+ , "separator": " "
+ , "$1":
+ [ "${ROOT}/expand_exec TMPDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR"
+ , "--"
+ , "${CMAKE} -S\"source/${CMAKE_SUBDIR}\" -Bbuild"
+ , "-DCMAKE_MAKE_PROGRAM=${MAKE}"
+ , "-DCMAKE_AR=${CMAKE_AR}"
+ , "-DCMAKE_INSTALL_PREFIX=./install"
+ , "-DCMAKE_PREFIX_PATH=\"$(pwd)/localbase\""
+ , "-DPKG_CONFIG_ARGN=--define-prefix"
+ , "--no-warn-unused-cli"
+ , "\"$@\""
+ , ">configure.log 2>&1 || (cat configure.log && exit 1)"
+ ]
+ }
+ ]
+ , { "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"
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "target"}]
+ }
+ , ">>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ ]
+ }
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "resolve_symlinks"}
+ , "then":
+ [ "mv install install_with_symlinks"
+ , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)"
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "post_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ [ "("
+ , "set --"
+ , "readonly CMAKE_SOURCE_DIR=\"$(pwd)/source\""
+ , "readonly CMAKE_BINARY_DIR=\"$(pwd)/build\""
+ , "cd ./install"
+ ]
+ , {"type": "var", "name": "post_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "TOOLCHAIN"}
+ , {"type": "var", "name": "source_dir"}
+ , {"type": "var", "name": "expand_exec"}
+ , { "type": "var"
+ , "name": "localbase_dir"
+ , "default": {"type": "empty_map"}
+ }
+ , {"type": "var", "name": "script"}
+ ]
+ }
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [ {"type": "var", "name": "sh"}
+ , "run_cmake.sh"
+ , {"type": "var", "name": "CMAKE_SUBDIR"}
+ , {"type": "var", "name": "AR"}
+ ]
+ , {"type": "var", "name": "CMAKE_FLAGS"}
+ ]
+ }
+ , "out_dirs": ["install"]
+ , "env": {"type": "var", "name": "ENV"}
+ , "timeout scaling":
+ {"type": "var", "name": "TIMEOUT_SCALE", "default": 10.0}
+ , "execution properties":
+ {"type": "var", "name": "FOREIGN_EXECUTION_PROPERTIES"}
+ }
+ }
+ }
+}
diff --git a/rules/CC/foreign/cmake/RULES b/rules/CC/foreign/cmake/RULES
new file mode 100644
index 0000000..917b4af
--- /dev/null
+++ b/rules/CC/foreign/cmake/RULES
@@ -0,0 +1,772 @@
+{ "data":
+ { "doc":
+ [ "Data produced by CMake configure, build, and install."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\","
+ , "and \"AR\". \"LOCALBASE\" contains the path to the installed artifacts"
+ , "from \"deps\"."
+ ]
+ , "target_fields": ["project"]
+ , "string_fields":
+ [ "subdir"
+ , "options"
+ , "defines"
+ , "targets"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "out_files"
+ , "out_dirs"
+ , "resolve_symlinks"
+ ]
+ , "config_vars":
+ [ "ARCH"
+ , "HOST_ARCH"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ , "expand_exec": [["./", "..", "expand_exec"]]
+ }
+ , "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\"])"
+ ]
+ , "defines":
+ [ "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."
+ ]
+ , "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. The CMake source and build directory can be"
+ , "accessed via \"$CMAKE_SOURCE_DIR\" and \"$CMAKE_BINARY_DIR\","
+ , "respectively."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after the install, before \"post_cmds\" are run."
+ ]
+ , "out_files":
+ [ "Paths to the produced output files. The paths are considered relative"
+ , "to the install directory."
+ , "Note that \"out_files\" and \"out_dirs\" may not overlap."
+ ]
+ , "out_dirs":
+ [ "Paths to the produced output directories. The paths are considered"
+ , "relative to the install directory."
+ , "Note that \"out_files\" and \"out_dirs\" may not overlap."
+ ]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ [ "The linker flags to be used instead of the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "stage_field": ["", "stage_singleton_field"]
+ , "cmake-build": "cmake-build"
+ , "strip-prefix": ["./", "..", "strip-prefix"]
+ , "for host": ["transitions", "for host"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["install_prefix", "install"]
+ , [ "source_dir"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"], ["location", "source"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "installed_out_files"
+ , { "type": "foreach"
+ , "var": "file_path"
+ , "range": {"type": "FIELD", "name": "out_files"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "file_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_out_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "FIELD", "name": "out_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , ["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"}]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["defaults-transition", {"type": "empty_map"}]
+ , [ "expand_exec"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "expand_exec"]
+ , ["location", "expand_exec"]
+ , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "full_install_dir"
+ , {"type": "CALL_EXPRESSION", "name": "cmake-build"}
+ ]
+ , ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "install_dir"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "shell TOOLCHAIN"}
+ , {"type": "var", "name": "full_install_dir"}
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "-c", ":"]
+ , "outs": {"type": "var", "name": "installed_out_files"}
+ , "out_dirs": {"type": "var", "name": "installed_out_dirs"}
+ }
+ ]
+ , [ "out_files"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_files"}]
+ , ["prefix", {"type": "var", "name": "install_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "out_dirs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_dirs"}]
+ , ["prefix", {"type": "var", "name": "install_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts":
+ { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "out_files"}
+ , {"type": "var", "name": "out_dirs"}
+ ]
+ }
+ }
+ }
+ }
+ }
+, "library":
+ { "doc":
+ [ "Library produced by CMake configure, build, and install."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\","
+ , "and \"AR\". \"LOCALBASE\" contains the path to the installed artifacts"
+ , "from \"deps\"."
+ ]
+ , "target_fields": ["project", "deps"]
+ , "string_fields":
+ [ "subdir"
+ , "name"
+ , "version"
+ , "stage"
+ , "options"
+ , "defines"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "out_hdrs"
+ , "out_hdr_dirs"
+ , "out_libs"
+ , "cflags"
+ , "ldflags"
+ , "pkg-config"
+ , "hdr_prefix"
+ , "lib_prefix"
+ , "pc_prefix"
+ , "resolve_symlinks"
+ ]
+ , "config_vars":
+ [ "ARCH"
+ , "HOST_ARCH"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]]
+ , "expand_exec": [["./", "..", "expand_exec"]]
+ }
+ , "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."
+ ]
+ , "version":
+ [ "The library version, used for pkg-config files. Individual version"
+ , "components are joined with \".\"."
+ ]
+ , "options":
+ [ "CMake options for the configuration phase"
+ , "(e.g., [\"-GNinja\", \"-Ax64\"]). Variables can be accessed via"
+ , "\"$(<varname>)\", e.g., \"$(TMPDIR)\" for variable \"$TMPDIR\"."
+ ]
+ , "defines":
+ [ "CMake defines for the configuration phase"
+ , "(e.g., [\"CMAKE_BUILD_TYPE=Release\"]). Variables can be accessed via"
+ , "\"$(<varname>)\", e.g., \"$(TMPDIR)\" for variable \"$TMPDIR\"."
+ ]
+ , "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. The CMake"
+ , "source and build directory can be accessed via \"$CMAKE_SOURCE_DIR\""
+ , "and \"$CMAKE_BINARY_DIR\", respectively."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after the install, before \"post_cmds\" are run."
+ ]
+ , "out_hdrs":
+ [ "Paths to produced public header files. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_hdr_dirs":
+ [ "Paths to produced public header directories. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_libs":
+ [ "Paths to produced library files. The path is considered relative"
+ , "to the library directory, which be set via \"lib_prefix\"."
+ , "Order matters in the case of one library depending on another."
+ ]
+ , "cflags":
+ ["List of compile flags set for this target and its consumers."]
+ , "ldflags":
+ [ "Additional linker flags that are required for the consumer of the"
+ , "produced libraries."
+ ]
+ , "stage":
+ [ "The logical location of the public headers and library files."
+ , "Individual directory components are joined with \"/\"."
+ ]
+ , "deps": ["Public dependency on other CC libraries."]
+ , "pkg-config":
+ [ "Pkg-config file for optional infer of public cflags and ldflags. If"
+ , "multiple files are specified (e.g., one depends on the other), the"
+ , "first one is used as entry. Note that if this field is non-empty the"
+ , "tool \"pkg-config\" must be available in \"PATH\", which is taken"
+ , "from [\"CC\", \"defaults\"] or the \"ENV\" variable."
+ ]
+ , "hdr_prefix":
+ [ "Prefix where headers will be installed by CMake. Individual directory"
+ , "components are joined with \"/\". Defaults to \"include\" if not set."
+ ]
+ , "lib_prefix":
+ [ "Prefix where libraries will be installed by CMake. Individual"
+ , "directory components are joined with \"/\". Defaults to \"lib\" if"
+ , "not set."
+ ]
+ , "pc_prefix":
+ [ "Prefix where pkg-config files will be installed by CMake. Individual"
+ , "directory components are joined with \"/\". Defaults to"
+ , "\"lib/pkgconfig\" if not set."
+ ]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ ["Global ld flags, for common link args,such as -Wl,-z,noexecstack"]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library"
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "stage_field": ["", "stage_singleton_field"]
+ , "cmake-build": "cmake-build"
+ , "strip-prefix": ["./", "..", "strip-prefix"]
+ , "prebuilt result": ["CC/prebuilt", "prebuilt result"]
+ , "install-deps": ["CC", "install-with-deps stage"]
+ , "for host": ["transitions", "for host"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "hdr_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "hdr_prefix"}
+ , "then": {"type": "FIELD", "name": "hdr_prefix"}
+ , "else": ["include"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "lib_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "lib_prefix"}
+ , "then": {"type": "FIELD", "name": "lib_prefix"}
+ , "else": ["lib"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "pc_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "pc_prefix"}
+ , "then": {"type": "FIELD", "name": "pc_prefix"}
+ , "else": ["lib", "pkgconfig"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "source_dir"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"], ["location", "source"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "localbase_dir"
+ , { "type": "to_subdir"
+ , "subdir": "localbase"
+ , "msg": "dependency installation files may not overlap"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["pc-install-dir", "lib/pkgconfig"]
+ , ["targets", {"type": "FIELD", "name": "deps"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"}
+ }
+ }
+ ]
+ , [ "installed_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "FIELD", "name": "out_hdr_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_files"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "lib_path"
+ , "range": {"type": "FIELD", "name": "out_libs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "lib_prefix"}
+ , {"type": "var", "name": "lib_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "hdr_path"
+ , "range": {"type": "FIELD", "name": "out_hdrs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "hdr_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "pc_path"
+ , "range": {"type": "FIELD", "name": "pkg-config"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "pc_prefix"}
+ , {"type": "var", "name": "pc_path"}
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ , ["cmake_subdir", {"type": "FIELD", "name": "subdir"}]
+ , ["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"}]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["defaults-transition", {"type": "empty_map"}]
+ , [ "expand_exec"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "expand_exec"]
+ , ["location", "expand_exec"]
+ , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "full_install_dir"
+ , {"type": "CALL_EXPRESSION", "name": "cmake-build"}
+ ]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "install_dir"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "shell TOOLCHAIN"}
+ , {"type": "var", "name": "full_install_dir"}
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "-c", ":"]
+ , "outs": {"type": "var", "name": "installed_files"}
+ , "out_dirs": {"type": "var", "name": "installed_dirs"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdrs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdr_dirs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ }
+ ]
+ , [ "libs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_libs"}]
+ , ["prefix", {"type": "var", "name": "lib_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "config_reader"
+ , { "type": "let*"
+ , "bindings":
+ [["fieldname", "config_reader"], ["location", "config_reader"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "pkg-configs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "pkg-config"}]
+ , ["prefix", {"type": "var", "name": "pc_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "name"
+ , { "type": "assert_non_empty"
+ , "msg": "name is required for cmake library"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
+ }
+ ]
+ , ["version", {"type": "FIELD", "name": "version"}]
+ , ["cflags", {"type": "FIELD", "name": "cflags"}]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
+ , [ "stage"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ ]
+ , ["deps-fieldnames", ["deps", "defaults"]]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "prebuilt result"}
+ }
+ }
+}
diff --git a/rules/CC/foreign/expand_exec b/rules/CC/foreign/expand_exec
new file mode 100755
index 0000000..df3000e
--- /dev/null
+++ b/rules/CC/foreign/expand_exec
@@ -0,0 +1,133 @@
+#!/bin/sh
+# Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+check_var_name() {
+ local NAME="$1"
+ if ! expr match "${NAME}" "[A-Z_a-z][0-9A-Z_a-z]*$" >/dev/null; then
+ echo "expand_exec error: invalid variable name '${NAME}'"
+ return 1
+ fi
+ return 0
+}
+
+in_list() {
+ local NAME="$1"
+ local VAR_LIST="$2"
+ check_var_name "${NAME}" && expr match "${NAME}" "\(${VAR_LIST}\)$" >/dev/null
+}
+
+EXPANDED_VAR=
+expand_var() {
+ local NAME="$1"
+ check_var_name "${NAME}" && EXPANDED_VAR="$(eval "printf \"%s\" \"\${$NAME}\"")"
+}
+
+PARSED_ARG=
+parse_arg() {
+ local ARG="$1"
+ local VAR_LIST="$2"
+ local RESULT=""
+ local VAR_NAME=""
+ local PARSE_EXPR=false
+ local PARSE_VAR_NAME=false
+
+ while [ ${#ARG} -gt 0 ]; do
+ local NEXT="${ARG#?}"
+ c="${ARG%"${NEXT}"}"
+ ARG="${NEXT}"
+
+ if $PARSE_VAR_NAME; then
+ # parse <var> from $(<var>)
+ if [ "$c" = ")" ]; then
+ # expand var if in cases list
+ if in_list "${VAR_NAME}" "${VAR_LIST}" && expand_var "${VAR_NAME}"; then
+ RESULT="${RESULT}${EXPANDED_VAR}"
+ else
+ RESULT="${RESULT}\$(${VAR_NAME})"
+ fi
+ VAR_NAME=""
+ PARSE_VAR_NAME=false
+ else
+ # accumulate VAR_NAME
+ VAR_NAME="${VAR_NAME}$c"
+ if [ ${#ARG} -eq 0 ]; then
+ # flush unterminated var name
+ RESULT="${RESULT}\$(${VAR_NAME}"
+ fi
+ fi
+ else
+ # parse single char
+ if $PARSE_EXPR; then
+ if [ "$c" = "(" ]; then
+ # found "$("
+ PARSE_VAR_NAME=true
+ else
+ RESULT="${RESULT}\$$c"
+ fi
+ PARSE_EXPR=false
+ elif [ "$c" = "$" ]; then
+ # found "$"
+ PARSE_EXPR=true
+ else
+ # append char
+ RESULT="${RESULT}$c"
+ fi
+ fi
+ done
+
+ PARSED_ARG="'"
+ while [ ${#RESULT} -gt 0 ]; do
+ local NEXT="${RESULT#?}"
+ c="${RESULT%"${NEXT}"}"
+ RESULT="${NEXT}"
+ if [ "$c" = "'" ]; then
+ PARSED_ARG="${PARSED_ARG}'\\''"
+ else
+ PARSED_ARG="${PARSED_ARG}$c"
+ fi
+ done
+ PARSED_ARG="${PARSED_ARG}'"
+}
+
+# usage: ./expand_exec [VARS...] -- ARGS...
+expand_exec() {
+ local VAR_LIST=""
+ local VAR_SEP=""
+ local EXEC_VEC=""
+ local EXEC_SEP=""
+ local READ_ARGS=false
+
+ while [ "$#" -ge 1 ]; do
+ local ARG="$1";shift
+ if $READ_ARGS; then
+ parse_arg "${ARG}" "${VAR_LIST}"
+ EXEC_VEC="${EXEC_VEC}${EXEC_SEP}${PARSED_ARG}"
+ EXEC_SEP=" "
+ else
+ if [ "${ARG}" = "--" ]; then
+ READ_ARGS=true
+ elif check_var_name "${ARG}"; then
+ VAR_LIST="${VAR_LIST}${VAR_SEP}${ARG}"
+ VAR_SEP="\|"
+ fi
+ fi
+ done
+
+ exec /bin/sh -c "${EXEC_VEC}"
+}
+
+expand_exec "$@"
diff --git a/rules/CC/foreign/expand_exec.c b/rules/CC/foreign/expand_exec.c
new file mode 100644
index 0000000..a4ff311
--- /dev/null
+++ b/rules/CC/foreign/expand_exec.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* usage: ./expand_exec [VARS...] -- ARGS... */
+int main(int argc, const char *argv[]) {
+ char **outv;
+ const char **varv;
+ int i, j, varc, sep = 0, retval = 0;
+ for (i = 1; i < argc; ++i)
+ if (strcmp(argv[i], "--") == 0) {
+ sep = i;
+ break;
+ }
+ varc = sep - 1;
+ argc -= sep + 1;
+ if (sep == 0 || argc < 1)
+ return 1; /* error: missing sep or args */
+ varv = &argv[1];
+ argv = &argv[sep + 1];
+ outv = (char **)calloc((size_t)(argc + 1), sizeof(char *));
+ for (i = 0; i < argc; ++i) { /* iterate ARGS */
+ const char *arg = argv[i];
+ size_t arg_pos = 0, arg_len = strlen(arg);
+ size_t out_pos = 0, out_len = arg_len;
+ size_t str_pos = 0, str_len = 0;
+ char *out = (char *)calloc((size_t)(out_len + 1), sizeof(char));
+ for (; arg_pos < arg_len; ++arg_pos) {
+ if (strncmp(&arg[arg_pos], "$(", 2) == 0) {
+ const char *start = &arg[arg_pos + 2];
+ const char *end = strchr(start, ')');
+ if (end == NULL) {
+ retval = 2; /* error: unterminated $(VAR) expression */
+ free(out);
+ goto cleanup;
+ }
+ for (j = 0; j < varc; ++j) { /* lookup VAR */
+ const char *var = varv[j];
+ size_t len_var = strlen(var);
+ if ((size_t)(end - start) != len_var)
+ continue;
+ if (strncmp(&arg[arg_pos + 2], var, len_var) == 0) {
+ size_t val_len, out_len_new;
+ const char *val = getenv(var);
+ if (val == NULL)
+ val = "";
+ val_len = strlen(val);
+ out_len_new = out_pos + str_len + val_len;
+ if (out_len_new > out_len) {
+ out = (char *)realloc(out, out_len_new + 1);
+ out_len = out_len_new;
+ }
+ strncat(out, &arg[str_pos], str_len); /* concat preceding substr */
+ strncat(out, val, val_len); /* concat variable value */
+ arg_pos += len_var + 2;
+ out_pos += str_len + val_len;
+ str_pos = arg_pos + 1;
+ str_len = 0;
+ break;
+ }
+ }
+ if (j != varc)
+ continue; /* success */
+ }
+ ++str_len;
+ }
+ if (str_len > 0) {
+ if (out_pos + str_len > out_len) {
+ out = (char *)realloc(out, out_pos + str_len + 1);
+ }
+ strncat(out, &arg[str_pos], str_len);
+ }
+ outv[i] = out;
+ }
+ execvp(outv[0], outv);
+ retval = 3; /* error: exec failed */
+cleanup:
+ for (i = 0; i < argc; ++i)
+ if (outv[i] != NULL)
+ free(outv[i]);
+ free(outv);
+ return retval;
+}
diff --git a/rules/CC/foreign/make/EXPRESSIONS b/rules/CC/foreign/make/EXPRESSIONS
new file mode 100644
index 0000000..55d9fa8
--- /dev/null
+++ b/rules/CC/foreign/make/EXPRESSIONS
@@ -0,0 +1,445 @@
+{ "make-build":
+ { "vars":
+ [ "source_dir"
+ , "subdir"
+ , "localbase_dir"
+ , "configure"
+ , "configure_options"
+ , "make_targets"
+ , "make_prefix"
+ , "make_options"
+ , "make_jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "defaults-transition"
+ , "expand_exec"
+ , "resolve_symlinks"
+ ]
+ , "imports":
+ { "artifacts": ["", "field_artifacts"]
+ , "flags-cc": ["CC", "flags-cc"]
+ , "flags-cxx": ["CC", "flags-cxx"]
+ , "compiler-cc": ["CC", "compiler-cc"]
+ , "compiler-cxx": ["CC", "compiler-cxx"]
+ , "default-LDFLAGS": ["CC", "default-LDFLAGS"]
+ , "default-AR": ["CC", "default-AR"]
+ , "default-ENV": ["CC", "default-ENV"]
+ , "default-PATH": ["CC", "default-PATH"]
+ , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"]
+ , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"]
+ , "foreign-MAKE": ["CC/foreign", "default-MAKE"]
+ , "foreign-ENV": ["CC/foreign", "default-ENV"]
+ , "foreign-PATH": ["CC/foreign", "default-PATH"]
+ , "foreign-TOOLCHAIN": ["CC/foreign", "default-TOOLCHAIN"]
+ , "foreign-NON_SYSTEM_TOOLS": ["CC/foreign", "default-NON_SYSTEM_TOOLS"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ , "sh-PATH": ["shell", "PATH"]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "disjoint_map_union"
+ , "msg": "Toolchain trees may not overlap"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-TOOLCHAIN"}
+ , {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}
+ , {"type": "var", "name": "shell TOOLCHAIN"}
+ ]
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ ]
+ , [ "NON_SYSTEM_TOOLS"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-NON_SYSTEM_TOOLS"}
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
+ }
+ ]
+ , [ "MAKE"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "MAKE"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "foreign-MAKE"}
+ ]
+ }
+ }
+ ]
+ , ["CC", {"type": "CALL_EXPRESSION", "name": "compiler-cc"}]
+ , ["CXX", {"type": "CALL_EXPRESSION", "name": "compiler-cxx"}]
+ , [ "CFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cc"}
+ }
+ ]
+ , [ "CXXFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cxx"}
+ }
+ ]
+ , [ "LDFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["-Wl,-rpath,$ORIGIN", "-Wl,-rpath,$ORIGIN/../lib"]
+ , { "type": "var"
+ , "name": "LDFLAGS"
+ , "default":
+ {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ }
+ , {"type": "var", "name": "ldflags", "default": []}
+ ]
+ }
+ }
+ ]
+ , [ "AR"
+ , { "type": "var"
+ , "name": "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"}
+ ]
+ }
+ }
+ }
+ ]
+ , [ "PREFIX"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "make_prefix"}
+ , "then":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1": [[""], {"type": "var", "name": "make_prefix"}]
+ }
+ }
+ , "else": {"type": "var", "name": "PREFIX", "default": "/"}
+ }
+ ]
+ , [ "sh-PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh-PATH"}
+ }
+ }
+ ]
+ , [ "sh-ENV"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "sh-PATH"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": {"type": "var", "name": "sh-PATH"}
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , [ "PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ ]
+ }
+ }
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "AR"
+ , "MAKE"
+ , "PREFIX"
+ ]
+ }
+ , {"type": "var", "name": "sh-ENV"}
+ , {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , {"type": "CALL_EXPRESSION", "name": "foreign-ENV"}
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "SUBDIR"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "var", "name": "subdir", "default": []}
+ }
+ ]
+ , [ "configure_args"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "configure"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "configure_options", "default": []}
+ , [ { "type": "join"
+ , "$1": ["--prefix=", {"type": "var", "name": "PREFIX"}]
+ }
+ ]
+ ]
+ }
+ }
+ ]
+ , [ "make_targets"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "make_targets"}
+ , "then": {"type": "var", "name": "make_targets"}
+ , "else": ["install"]
+ }
+ ]
+ , [ "script"
+ , { "type": "singleton_map"
+ , "key": "run_make.sh"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [ "set -eu"
+ , "mkdir -p scratch install"
+ , "readonly ROOT=\"$(pwd)\""
+ , "export TMPDIR=\"$(pwd)/scratch\""
+ , "export DESTDIR=\"$(pwd)/install\""
+ , "export TOOLCHAIN=\"$(pwd)/toolchain\""
+ , "export LOCALBASE=\"$(pwd)/localbase\""
+ , { "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="
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "PATH"}]
+ }
+ , "${PATH:+:}\"${PATH}\""
+ ]
+ }
+ ]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "pre_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["(", "set --", "cd ./source"]
+ , {"type": "var", "name": "pre_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ , ["readonly SUBDIR=\"$1\"", "shift"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "configure_args"}
+ , "then":
+ [ "( cd \"source/${SUBDIR}\""
+ , { "type": "join"
+ , "$1":
+ [ "${ROOT}/expand_exec TMPDIR DESTDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR PREFIX -- ./configure "
+ , { "type": "join_cmd"
+ , "$1": {"type": "var", "name": "configure_args"}
+ }
+ , " >\"${ROOT}/configure.log\" 2>&1 || (cat \"${ROOT}/configure.log\" && exit 1)"
+ ]
+ }
+ , ")"
+ ]
+ }
+ , { "type": "foreach"
+ , "range": {"type": "var", "name": "make_targets"}
+ , "var": "target"
+ , "body":
+ { "type": "join"
+ , "separator": " "
+ , "$1":
+ [ "${ROOT}/expand_exec TMPDIR DESTDIR LOCALBASE CC CXX CFLAGS CXXFLAGS LDFLAGS AR PREFIX"
+ , "--"
+ , "${MAKE} -C \"source/${SUBDIR}\" DESTDIR=${DESTDIR} \"$@\""
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "target"}]
+ }
+ , ">>build.log 2>&1 || (cat build.log && exit 1)"
+ ]
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "resolve_symlinks"}
+ , "then":
+ [ "mv install install_with_symlinks"
+ , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)"
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "post_cmds"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["(", "set --", "cd ./install"]
+ , {"type": "var", "name": "post_cmds"}
+ , [")"]
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "TOOLCHAIN"}
+ , {"type": "var", "name": "source_dir"}
+ , {"type": "var", "name": "expand_exec"}
+ , { "type": "var"
+ , "name": "localbase_dir"
+ , "default": {"type": "empty_map"}
+ }
+ , {"type": "var", "name": "script"}
+ ]
+ }
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [{"type": "var", "name": "sh"}, "run_make.sh"]
+ , [{"type": "var", "name": "SUBDIR"}]
+ , {"type": "var", "name": "make_options"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "make_jobs"}
+ , "then":
+ [ { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1": [["-j"], {"type": "var", "name": "make_jobs"}]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ , "out_dirs": ["install"]
+ , "env": {"type": "var", "name": "ENV"}
+ , "timeout scaling":
+ {"type": "var", "name": "TIMEOUT_SCALE", "default": 10.0}
+ , "execution properties":
+ {"type": "var", "name": "FOREIGN_EXECUTION_PROPERTIES"}
+ }
+ }
+ }
+}
diff --git a/rules/CC/foreign/make/RULES b/rules/CC/foreign/make/RULES
new file mode 100644
index 0000000..e831d4c
--- /dev/null
+++ b/rules/CC/foreign/make/RULES
@@ -0,0 +1,803 @@
+{ "data":
+ { "doc":
+ [ "Data produced by Configure and Make build and install."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\","
+ , "\"AR\", and \"PREFIX\". \"LOCALBASE\" contains the path to the"
+ , "installed artifacts from \"deps\"."
+ ]
+ , "target_fields": ["project"]
+ , "string_fields":
+ [ "subdir"
+ , "configure"
+ , "configure_options"
+ , "targets"
+ , "prefix"
+ , "options"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "out_files"
+ , "out_dirs"
+ , "resolve_symlinks"
+ ]
+ , "config_vars":
+ [ "ARCH"
+ , "HOST_ARCH"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ , "expand_exec": [["./", "..", "expand_exec"]]
+ }
+ , "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 \"/\"."
+ ]
+ , "configure": ["Run ./configure if non-empty."]
+ , "configure_options":
+ [ "The configure options (the \"--prefix\" option is automatically set)."
+ , "Variables can be accessed via \"$(<varname>)\", e.g., \"$(TMPDIR)\""
+ , "for variable \"$TMPDIR\"."
+ ]
+ , "targets":
+ [ "The Make targets to build in the specified order"
+ , "(default: [\"install\"])."
+ ]
+ , "prefix":
+ [ "The prefix used for the Make target. The path will be made absolute"
+ , "and individual directory components are joined with \"/\". If no"
+ , "prefix is specified, the value from the config variable \"PREFIX\" is"
+ , "taken, with the default value being \"/\"."
+ ]
+ , "options":
+ [ "Make options for the configuration phase"
+ , "(e.g., [\"-f\", \"Makefile\", \"ARCH=x86\", \"LD=$(CC)\"]). Variables"
+ , "can be accessed via \"$(<varname>)\", e.g., \"$(TMPDIR)\" for"
+ , "variable \"$TMPDIR\"."
+ ]
+ , "jobs":
+ [ "Number of jobs to run simultaneously. If omitted, Make's default"
+ , "number is used."
+ ]
+ , "pre_cmds":
+ [ "List of commands executed in the project directory before calling"
+ , "Configure or Make. 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."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after the install, before \"post_cmds\" are run."
+ ]
+ , "out_files":
+ [ "Paths to the produced output files. The paths are considered relative"
+ , "to the install directory."
+ , "Note that \"out_files\" and \"out_dirs\" may not overlap."
+ ]
+ , "out_dirs":
+ [ "Paths to the produced output directories. The paths are considered"
+ , "relative to the install directory."
+ , "Note that \"out_files\" and \"out_dirs\" may not overlap."
+ ]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ [ "The linker flags to be used instead of the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "PREFIX":
+ [ "The absolute path that is used as prefix inside generated pkg-config"
+ , "files. The default value for this variable is \"/\". This variable"
+ , "is ignored if the field \"prefix\" is set."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "stage_field": ["", "stage_singleton_field"]
+ , "make-build": "make-build"
+ , "strip-prefix": ["./", "..", "strip-prefix"]
+ , "for host": ["transitions", "for host"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["install_prefix", "install"]
+ , [ "source_dir"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"], ["location", "source"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "installed_out_files"
+ , { "type": "foreach"
+ , "var": "file_path"
+ , "range": {"type": "FIELD", "name": "out_files"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "file_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_out_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "FIELD", "name": "out_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , ["subdir", {"type": "FIELD", "name": "subdir"}]
+ , ["configure", {"type": "FIELD", "name": "configure"}]
+ , ["configure_options", {"type": "FIELD", "name": "configure_options"}]
+ , ["make_targets", {"type": "FIELD", "name": "targets"}]
+ , ["make_prefix", {"type": "FIELD", "name": "prefix"}]
+ , ["make_options", {"type": "FIELD", "name": "options"}]
+ , ["make_jobs", {"type": "FIELD", "name": "jobs"}]
+ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}]
+ , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["defaults-transition", {"type": "empty_map"}]
+ , [ "expand_exec"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "expand_exec"]
+ , ["location", "expand_exec"]
+ , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , ["full_install_dir", {"type": "CALL_EXPRESSION", "name": "make-build"}]
+ , ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "install_dir"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "shell TOOLCHAIN"}
+ , {"type": "var", "name": "full_install_dir"}
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "-c", ":"]
+ , "outs": {"type": "var", "name": "installed_out_files"}
+ , "out_dirs": {"type": "var", "name": "installed_out_dirs"}
+ }
+ ]
+ , [ "out_files"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_files"}]
+ , ["prefix", {"type": "var", "name": "install_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "out_dirs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_dirs"}]
+ , ["prefix", {"type": "var", "name": "install_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts":
+ { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "out_files"}
+ , {"type": "var", "name": "out_dirs"}
+ ]
+ }
+ }
+ }
+ }
+ }
+, "library":
+ { "doc":
+ [ "Library produced by Configure and Make build and install."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"CC\", \"CXX\", \"CFLAGS\", \"CXXFLAGS\", \"LDFLAGS\","
+ , "\"AR\", and \"PREFIX\". \"LOCALBASE\" contains the path to the"
+ , "installed artifacts from \"deps\"."
+ ]
+ , "target_fields": ["project", "deps"]
+ , "string_fields":
+ [ "subdir"
+ , "name"
+ , "version"
+ , "stage"
+ , "configure"
+ , "configure_options"
+ , "targets"
+ , "prefix"
+ , "options"
+ , "jobs"
+ , "pre_cmds"
+ , "post_cmds"
+ , "out_hdrs"
+ , "out_hdr_dirs"
+ , "out_libs"
+ , "cflags"
+ , "ldflags"
+ , "pkg-config"
+ , "hdr_prefix"
+ , "lib_prefix"
+ , "pc_prefix"
+ , "resolve_symlinks"
+ ]
+ , "config_vars":
+ [ "ARCH"
+ , "HOST_ARCH"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]]
+ , "expand_exec": [["./", "..", "expand_exec"]]
+ }
+ , "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."
+ ]
+ , "version":
+ [ "The library version, used for pkg-config files. Individual version"
+ , "components are joined with \".\"."
+ ]
+ , "configure": ["Run ./configure if non-empty."]
+ , "configure_options":
+ ["The configure options (the \"--prefix\" option is automatically set)."]
+ , "targets":
+ [ "The Make targets to build in the specified order"
+ , "(default: [\"install\"])."
+ ]
+ , "prefix":
+ [ "The prefix used for the Make target. The path will be made absolute"
+ , "and individual directory components are joined with \"/\". If no"
+ , "prefix is specified, the value from the config variable \"PREFIX\" is"
+ , "taken, with the default value being \"/\"."
+ ]
+ , "options":
+ [ "Make options for the build phase."
+ , "(e.g., [\"-f\", \"Makefile\", \"ARCH=x86\"])"
+ ]
+ , "jobs":
+ [ "Number of jobs to run simultaneously. If omitted, Make's default"
+ , "number is used."
+ ]
+ , "pre_cmds":
+ [ "List of commands executed in the project directory before calling"
+ , "Configure or Make. 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."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after the install, before \"post_cmds\" are run."
+ ]
+ , "out_hdrs":
+ [ "Paths to produced public header files. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_hdr_dirs":
+ [ "Paths to produced public header directories. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_libs":
+ [ "Paths to produced library files. The path is considered relative"
+ , "to the library directory, which be set via \"lib_prefix\"."
+ , "Order matters in the case of one library depending on another."
+ ]
+ , "cflags":
+ ["List of compile flags set for this target and its consumers."]
+ , "ldflags":
+ [ "Additional linker flags that are required for the consumer of the"
+ , "produced libraries."
+ ]
+ , "stage":
+ [ "The logical location of the public headers and library files."
+ , "Individual directory components are joined with \"/\"."
+ ]
+ , "deps": ["Public dependency on other CC libraries."]
+ , "pkg-config":
+ [ "Pkg-config file for optional infer of public cflags and ldflags. If"
+ , "multiple files are specified (e.g., one depends on the other), the"
+ , "first one is used as entry. Note that if this field is non-empty the"
+ , "tool \"pkg-config\" must be available in \"PATH\", which is taken"
+ , "from [\"CC\", \"defaults\"] or the \"ENV\" variable."
+ ]
+ , "hdr_prefix":
+ [ "Prefix where headers will be installed by Make. Individual directory"
+ , "components are joined with \"/\". Defaults to \"include\" if not set."
+ ]
+ , "lib_prefix":
+ [ "Prefix where libraries will be installed by Make. Individual"
+ , "directory components are joined with \"/\". Defaults to \"lib\" if"
+ , "not set."
+ ]
+ , "pc_prefix":
+ [ "Prefix where pkg-config files will be installed by Make. Individual"
+ , "directory components are joined with \"/\". Defaults to"
+ , "\"lib/pkgconfig\" if not set."
+ ]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ ["Global ld flags, for common link args,such as -Wl,-z,noexecstack"]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library"
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "PREFIX":
+ [ "The absolute path that is used as prefix inside generated pkg-config"
+ , "files. The default value for this variable is \"/\". This variable"
+ , "is ignored if the field \"prefix\" is set."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "stage_field": ["", "stage_singleton_field"]
+ , "make-build": "make-build"
+ , "strip-prefix": ["./", "..", "strip-prefix"]
+ , "prebuilt result": ["CC/prebuilt", "prebuilt result"]
+ , "install-deps": ["CC", "install-with-deps stage"]
+ , "for host": ["transitions", "for host"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "hdr_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "hdr_prefix"}
+ , "then": {"type": "FIELD", "name": "hdr_prefix"}
+ , "else": ["include"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "lib_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "lib_prefix"}
+ , "then": {"type": "FIELD", "name": "lib_prefix"}
+ , "else": ["lib"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "pc_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "pc_prefix"}
+ , "then": {"type": "FIELD", "name": "pc_prefix"}
+ , "else": ["lib", "pkgconfig"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "source_dir"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"], ["location", "source"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "localbase_dir"
+ , { "type": "to_subdir"
+ , "subdir": "localbase"
+ , "msg": "dependency installation files may not overlap"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["pc-install-dir", "lib/pkgconfig"]
+ , ["targets", {"type": "FIELD", "name": "deps"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"}
+ }
+ }
+ ]
+ , [ "installed_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "FIELD", "name": "out_hdr_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_files"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "lib_path"
+ , "range": {"type": "FIELD", "name": "out_libs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "lib_prefix"}
+ , {"type": "var", "name": "lib_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "hdr_path"
+ , "range": {"type": "FIELD", "name": "out_hdrs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "hdr_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "pc_path"
+ , "range": {"type": "FIELD", "name": "pkg-config"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "pc_prefix"}
+ , {"type": "var", "name": "pc_path"}
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ , ["subdir", {"type": "FIELD", "name": "subdir"}]
+ , ["configure", {"type": "FIELD", "name": "configure"}]
+ , ["configure_options", {"type": "FIELD", "name": "configure_options"}]
+ , ["make_targets", {"type": "FIELD", "name": "targets"}]
+ , ["make_prefix", {"type": "FIELD", "name": "prefix"}]
+ , ["make_options", {"type": "FIELD", "name": "options"}]
+ , ["make_jobs", {"type": "FIELD", "name": "jobs"}]
+ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}]
+ , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["defaults-transition", {"type": "empty_map"}]
+ , [ "expand_exec"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "expand_exec"]
+ , ["location", "expand_exec"]
+ , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , ["full_install_dir", {"type": "CALL_EXPRESSION", "name": "make-build"}]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "install_dir"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "shell TOOLCHAIN"}
+ , {"type": "var", "name": "full_install_dir"}
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "-c", ":"]
+ , "outs": {"type": "var", "name": "installed_files"}
+ , "out_dirs": {"type": "var", "name": "installed_dirs"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdrs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdr_dirs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ }
+ ]
+ , [ "libs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_libs"}]
+ , ["prefix", {"type": "var", "name": "lib_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "config_reader"
+ , { "type": "let*"
+ , "bindings":
+ [["fieldname", "config_reader"], ["location", "config_reader"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "pkg-configs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "pkg-config"}]
+ , ["prefix", {"type": "var", "name": "pc_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "name"
+ , { "type": "assert_non_empty"
+ , "msg": "name is required for make library"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
+ }
+ ]
+ , ["version", {"type": "FIELD", "name": "version"}]
+ , ["cflags", {"type": "FIELD", "name": "cflags"}]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
+ , [ "stage"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ ]
+ , ["deps-fieldnames", ["deps", "defaults"]]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "prebuilt result"}
+ }
+ }
+}
diff --git a/rules/CC/foreign/shell/EXPRESSIONS b/rules/CC/foreign/shell/EXPRESSIONS
new file mode 100644
index 0000000..7ca2741
--- /dev/null
+++ b/rules/CC/foreign/shell/EXPRESSIONS
@@ -0,0 +1,363 @@
+{ "shell-build":
+ { "vars":
+ [ "cmds"
+ , "sources"
+ , "localbase"
+ , "installed_files"
+ , "installed_dirs"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ , "resolve_symlinks"
+ ]
+ , "imports":
+ { "artifacts": ["", "field_artifacts"]
+ , "flags-cc": ["CC", "flags-cc"]
+ , "flags-cxx": ["CC", "flags-cxx"]
+ , "compiler-cc": ["CC", "compiler-cc"]
+ , "compiler-cxx": ["CC", "compiler-cxx"]
+ , "default-LDFLAGS": ["CC", "default-LDFLAGS"]
+ , "default-AR": ["CC", "default-AR"]
+ , "default-PATH": ["CC", "default-PATH"]
+ , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"]
+ , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"]
+ , "foreign-MAKE": ["CC/foreign", "default-MAKE"]
+ , "foreign-CMAKE": ["CC/foreign", "default-CMAKE"]
+ , "foreign-PATH": ["CC/foreign", "default-PATH"]
+ , "foreign-TOOLCHAIN": ["CC/foreign", "default-TOOLCHAIN"]
+ , "foreign-NON_SYSTEM_TOOLS": ["CC/foreign", "default-NON_SYSTEM_TOOLS"]
+ , "map_provider": ["", "field_map_provider"]
+ , "sh": ["shell", "sh"]
+ , "sh-PATH": ["shell", "PATH"]
+ , "sh prolog": ["shell", "prolog"]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "shell TOOLCHAIN"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "shell defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ ]
+ , [ "sh"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh"}
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "disjoint_map_union"
+ , "msg": "Toolchain trees may not overlap"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-TOOLCHAIN"}
+ , {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}
+ , {"type": "var", "name": "shell TOOLCHAIN"}
+ ]
+ }
+ ]
+ , [ "TOOLCHAIN"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ ]
+ , [ "NON_SYSTEM_TOOLS"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-NON_SYSTEM_TOOLS"}
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
+ }
+ ]
+ , [ "MAKE"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "MAKE"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "foreign-MAKE"}
+ ]
+ }
+ }
+ ]
+ , [ "CMAKE"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "CMAKE"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "foreign-CMAKE"}
+ ]
+ }
+ }
+ ]
+ , ["CC", {"type": "CALL_EXPRESSION", "name": "compiler-cc"}]
+ , ["CXX", {"type": "CALL_EXPRESSION", "name": "compiler-cxx"}]
+ , [ "CFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cc"}
+ }
+ ]
+ , [ "CXXFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1": {"type": "CALL_EXPRESSION", "name": "flags-cxx"}
+ }
+ ]
+ , [ "LDFLAGS"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["-Wl,-rpath,$ORIGIN", "-Wl,-rpath,$ORIGIN/../lib"]
+ , { "type": "var"
+ , "name": "LDFLAGS"
+ , "default":
+ {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ }
+ , {"type": "var", "name": "ldflags", "default": []}
+ ]
+ }
+ }
+ ]
+ , [ "AR"
+ , { "type": "var"
+ , "name": "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"}
+ ]
+ }
+ }
+ }
+ ]
+ , [ "PREFIX"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "make_prefix"}
+ , "then":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1": [[""], {"type": "var", "name": "make_prefix"}]
+ }
+ }
+ , "else": {"type": "var", "name": "PREFIX", "default": "/"}
+ }
+ ]
+ , [ "PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "foreign-PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ , { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh-PATH"}
+ }
+ ]
+ }
+ }
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "MAKE"
+ , "CMAKE"
+ , "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "AR"
+ , "PREFIX"
+ ]
+ }
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "localbase"
+ , { "type": "to_subdir"
+ , "subdir": "localbase"
+ , "$1": {"type": "var", "name": "localbase"}
+ }
+ ]
+ , [ "work_dir"
+ , { "type": "to_subdir"
+ , "subdir": "work"
+ , "$1": {"type": "var", "name": "sources"}
+ }
+ ]
+ , [ "script"
+ , { "type": "singleton_map"
+ , "key": "run_cmds.sh"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["fieldname", "shell defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh prolog"}
+ }
+ , [ "set -eu"
+ , "mkdir -p scratch work install"
+ , "export ACTION_DIR=\"$(pwd)\""
+ , "export TMPDIR=\"$(pwd)/scratch\""
+ , "export WORKDIR=\"$(pwd)/work\""
+ , "export TOOLCHAIN=\"$(pwd)/toolchain\""
+ , "export LOCALBASE=\"$(pwd)/localbase\""
+ , "export DESTDIR=\"$(pwd)/install\""
+ , { "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="
+ , { "type": "join_cmd"
+ , "$1": [{"type": "var", "name": "PATH"}]
+ }
+ , "${PATH:+:}\"${PATH}\""
+ ]
+ }
+ ]
+ , ["(", "set --", "cd ./work"]
+ , {"type": "var", "name": "cmds"}
+ , [")"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "resolve_symlinks"}
+ , "then":
+ [ "mv install install_with_symlinks"
+ , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)"
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ , [ "artifacts"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "TOOLCHAIN"}
+ , {"type": "var", "name": "work_dir"}
+ , {"type": "var", "name": "localbase"}
+ , {"type": "var", "name": "script"}
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "run_cmds.sh"]
+ , "outs": {"type": "var", "name": "installed_files"}
+ , "out_dirs": {"type": "var", "name": "installed_dirs"}
+ , "env": {"type": "var", "name": "ENV"}
+ , "timeout scaling":
+ {"type": "var", "name": "TIMEOUT_SCALE", "default": 10.0}
+ , "execution properties":
+ {"type": "var", "name": "FOREIGN_EXECUTION_PROPERTIES"}
+ }
+ ]
+ ]
+ , "body": {"type": "var", "name": "artifacts"}
+ }
+ }
+}
diff --git a/rules/CC/foreign/shell/RULES b/rules/CC/foreign/shell/RULES
new file mode 100644
index 0000000..182e46a
--- /dev/null
+++ b/rules/CC/foreign/shell/RULES
@@ -0,0 +1,624 @@
+{ "data":
+ { "doc":
+ [ "Data produced by generic shell commands with toolchain support."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"WORKDIR\", \"DESTDIR\", \"CC\", \"CXX\", \"CFLAGS\","
+ , "\"CXXFLAGS\", \"LDFLAGS\", and \"AR\". \"LOCALBASE\" contains the path"
+ , "to the staged artifacts from \"localbase\" and the installed artifacts"
+ , "from \"deps\". Furthermore, the variable \"ACTION_DIR\" points to the"
+ , "current action directory, if needed for achieving reproducibility."
+ ]
+ , "target_fields": ["project", "localbase", "deps"]
+ , "string_fields": ["cmds", "outs", "out_dirs", "resolve_symlinks"]
+ , "config_vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ }
+ , "field_doc":
+ { "project":
+ [ "The project directory. The disjoint union of the artifacts of the"
+ , "targets specified here are taken as project directory."
+ , "Its path can be accessed via the \"WORKDIR\" variable."
+ ]
+ , "localbase": ["Artifacts to stage to \"LOCALBASE\"."]
+ , "deps": ["CC targets to install to \"LOCALBASE\"."]
+ , "cmds":
+ [ "List of commands to execute by \"sh\". Multiple commands will be"
+ , "joined with the newline character."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after \"cmds\" were executed."
+ ]
+ , "outs": ["Paths to the produced output files in \"DESTDIR\"."]
+ , "out_dirs": ["Paths to the produced output directories in \"DESTDIR\"."]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ [ "The linker flags to be used instead of the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "PREFIX":
+ [ "The absolute path that is used as prefix inside generated pkg-config"
+ , "files. The default value for this variable is \"/\". This variable"
+ , "is ignored if the field \"prefix\" is set."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "artifacts": ["", "field_artifacts"]
+ , "stage_field": ["", "stage_singleton_field"]
+ , "shell-build": "shell-build"
+ , "install-deps": ["CC", "install-with-deps stage"]
+ , "strip-prefix": ["CC/foreign", "strip-prefix"]
+ , "for host": ["transitions", "for host"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["cmds", {"type": "FIELD", "name": "cmds"}]
+ , [ "sources"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ ]
+ , [ "localbase"
+ , { "type": "disjoint_map_union"
+ , "msg": "localbase and installed dependency files may not overlap"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings":
+ [ ["pc-install-dir", "lib/pkgconfig"]
+ , ["targets", {"type": "FIELD", "name": "deps"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"}
+ }
+ , { "type": "let*"
+ , "bindings": [["fieldname", "localbase"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ ]
+ }
+ ]
+ , ["outs", {"type": "FIELD", "name": "outs"}]
+ , ["out_dirs", {"type": "FIELD", "name": "out_dirs"}]
+ , ["install_prefix", "install"]
+ , [ "installed_files"
+ , { "type": "foreach"
+ , "var": "file_path"
+ , "range": {"type": "var", "name": "outs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "file_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "var", "name": "out_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "install_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["artifacts", {"type": "CALL_EXPRESSION", "name": "shell-build"}]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts":
+ { "type": "map_union"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "artifacts"}]
+ , [ "paths"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "outs"}
+ , {"type": "var", "name": "out_dirs"}
+ ]
+ }
+ ]
+ , ["prefix", {"type": "var", "name": "install_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ }
+ }
+ }
+ }
+, "library":
+ { "doc":
+ [ "Library produced by generic shell commands with toolchain support."
+ , ""
+ , "All variables accessible to commands and options are: \"TMPDIR\","
+ , "\"LOCALBASE\", \"WORKDIR\", \"DESTDIR\", \"CC\", \"CXX\", \"CFLAGS\","
+ , "\"CXXFLAGS\", \"LDFLAGS\", and \"AR\". \"LOCALBASE\" contains the path"
+ , "to the staged artifacts from \"localbase\" and the installed artifacts"
+ , "from \"deps\". Furthermore, the variable \"ACTION_DIR\" points to the"
+ , "current action directory, if needed for achieving reproducibility."
+ ]
+ , "target_fields": ["project", "localbase", "deps"]
+ , "string_fields":
+ [ "name"
+ , "version"
+ , "stage"
+ , "cmds"
+ , "out_hdrs"
+ , "out_hdr_dirs"
+ , "out_libs"
+ , "cflags"
+ , "ldflags"
+ , "pkg-config"
+ , "hdr_prefix"
+ , "lib_prefix"
+ , "pc_prefix"
+ , "resolve_symlinks"
+ ]
+ , "config_vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "AR"
+ , "PREFIX"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "TIMEOUT_SCALE"
+ , "FOREIGN_EXECUTION_PROPERTIES"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]]
+ }
+ , "field_doc":
+ { "project":
+ [ "The project directory. The disjoint union of the artifacts of the"
+ , "targets specified here are taken as project directory."
+ , "Its path can be accessed via the \"WORKDIR\" variable."
+ ]
+ , "name":
+ [ "The name of the library (without leading \"lib\" or trailing file name"
+ , "extension), also used as name for pkg-config files."
+ ]
+ , "version":
+ [ "The library version, used for pkg-config files. Individual version"
+ , "components are joined with \".\"."
+ ]
+ , "localbase": ["Artifacts to stage to \"LOCALBASE\"."]
+ , "cmds":
+ [ "List of commands to execute by \"sh\". Multiple commands will be"
+ , "joined with the newline character."
+ ]
+ , "resolve_symlinks":
+ [ "Resolve all symlinks in the install directory. This operation is"
+ , "performed immediately after \"cmds\" were executed."
+ ]
+ , "out_hdrs":
+ [ "Paths to produced public header files. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_hdr_dirs":
+ [ "Paths to produced public header directories. The path is considered"
+ , "relative to the include directory, which be set via \"hdr_prefix\"."
+ , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap."
+ ]
+ , "out_libs":
+ [ "Paths to produced library files. The path is considered relative"
+ , "to the library directory, which be set via \"lib_prefix\"."
+ , "Order matters in the case of one library depending on another."
+ ]
+ , "cflags":
+ ["List of compile flags set for this target and its consumers."]
+ , "ldflags":
+ [ "Additional linker flags that are required for the consumer of the"
+ , "produced libraries."
+ ]
+ , "stage":
+ [ "The logical location of the public headers and library files."
+ , "Individual directory components are joined with \"/\"."
+ ]
+ , "deps": ["Public dependency on other CC libraries."]
+ , "pkg-config":
+ [ "Pkg-config file for optional infer of public cflags and ldflags. If"
+ , "multiple files are specified (e.g., one depends on the other), the"
+ , "first one is used as entry. Note that if this field is non-empty the"
+ , "tool \"pkg-config\" must be available in \"PATH\", which is taken"
+ , "from [\"CC\", \"defaults\"] or the \"ENV\" variable."
+ ]
+ , "hdr_prefix":
+ [ "Prefix where headers will be installed by Make. Individual directory"
+ , "components are joined with \"/\". Defaults to \"include\" if not set."
+ ]
+ , "lib_prefix":
+ [ "Prefix where libraries will be installed by Make. Individual"
+ , "directory components are joined with \"/\". Defaults to \"lib\" if"
+ , "not set."
+ ]
+ , "pc_prefix":
+ [ "Prefix where pkg-config files will be installed by Make. Individual"
+ , "directory components are joined with \"/\". Defaults to"
+ , "\"lib/pkgconfig\" if not set."
+ ]
+ }
+ , "config_doc":
+ { "CC":
+ [ "The name of the C compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CXX":
+ [ "The name of the C++ compiler to be used."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "CXXFLAGS":
+ [ "The flags for CXX to be used instead of the default ones."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "LDFLAGS":
+ [ "The linker flags to be used instead of the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones."
+ , "For libraries that should be linked in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ENV":
+ [ "The environment for any action generated."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "AR":
+ [ "The archive tool to used for creating the library."
+ , "If null, the respective value from [\"CC\", \"defaults\"] will be taken."
+ ]
+ , "PREFIX":
+ [ "The absolute path that is used as prefix inside generated pkg-config"
+ , "files. The default value for this variable is \"/\". This variable"
+ , "is ignored if the field \"prefix\" is set."
+ ]
+ , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."]
+ , "TIMEOUT_SCALE":
+ [ "The scaling of the timeout for the invocation of the foreign build."
+ , "Defaults to 10."
+ ]
+ , "FOREIGN_EXECUTION_PROPERTIES":
+ [ "A map with extra remote-execution properties to be added to the foreign build action."
+ ]
+ }
+ , "imports":
+ { "artifacts": ["", "field_artifacts"]
+ , "stage_field": ["", "stage_singleton_field"]
+ , "shell-build": "shell-build"
+ , "prebuilt result": ["CC/prebuilt", "prebuilt result"]
+ , "install-deps": ["CC", "install-with-deps stage"]
+ , "strip-prefix": ["CC/foreign", "strip-prefix"]
+ , "for host": ["transitions", "for host"]
+ }
+ , "config_transitions":
+ { "defaults":
+ [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "hdr_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "hdr_prefix"}
+ , "then": {"type": "FIELD", "name": "hdr_prefix"}
+ , "else": ["include"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "lib_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "lib_prefix"}
+ , "then": {"type": "FIELD", "name": "lib_prefix"}
+ , "else": ["lib"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "pc_prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["install"]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "pc_prefix"}
+ , "then": {"type": "FIELD", "name": "pc_prefix"}
+ , "else": ["lib", "pkgconfig"]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "sources"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "project"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ ]
+ , [ "localbase"
+ , { "type": "disjoint_map_union"
+ , "msg": "localbase and installed dependency files may not overlap"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings":
+ [ ["pc-install-dir", "lib/pkgconfig"]
+ , ["targets", {"type": "FIELD", "name": "deps"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"}
+ }
+ , { "type": "let*"
+ , "bindings": [["fieldname", "localbase"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ ]
+ }
+ ]
+ , [ "installed_dirs"
+ , { "type": "foreach"
+ , "var": "dir_path"
+ , "range": {"type": "FIELD", "name": "out_hdr_dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "dir_path"}
+ ]
+ }
+ }
+ ]
+ , [ "installed_files"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "lib_path"
+ , "range": {"type": "FIELD", "name": "out_libs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "lib_prefix"}
+ , {"type": "var", "name": "lib_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "hdr_path"
+ , "range": {"type": "FIELD", "name": "out_hdrs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "hdr_prefix"}
+ , {"type": "var", "name": "hdr_path"}
+ ]
+ }
+ }
+ , { "type": "foreach"
+ , "var": "pc_path"
+ , "range": {"type": "FIELD", "name": "pkg-config"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ {"type": "var", "name": "pc_prefix"}
+ , {"type": "var", "name": "pc_path"}
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ , ["cmds", {"type": "FIELD", "name": "cmds"}]
+ , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}]
+ , ["defaults-transition", {"type": "empty_map"}]
+ , ["install_dir", {"type": "CALL_EXPRESSION", "name": "shell-build"}]
+ , [ "hdrs"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdrs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_hdr_dirs"}]
+ , ["prefix", {"type": "var", "name": "hdr_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ }
+ ]
+ , [ "libs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "out_libs"}]
+ , ["prefix", {"type": "var", "name": "lib_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "config_reader"
+ , { "type": "let*"
+ , "bindings":
+ [["fieldname", "config_reader"], ["location", "config_reader"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "pkg-configs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["artifacts", {"type": "var", "name": "install_dir"}]
+ , ["paths", {"type": "FIELD", "name": "pkg-config"}]
+ , ["prefix", {"type": "var", "name": "pc_prefix"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"}
+ }
+ ]
+ , [ "name"
+ , { "type": "assert_non_empty"
+ , "msg": "name is required for make library"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
+ }
+ ]
+ , ["version", {"type": "FIELD", "name": "version"}]
+ , ["cflags", {"type": "FIELD", "name": "cflags"}]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
+ , [ "stage"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ ]
+ , ["deps-fieldnames", ["deps", "defaults"]]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "prebuilt result"}
+ }
+ }
+}