summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CC/EXPRESSIONS1401
-rw-r--r--CC/RULES193
-rw-r--r--CC/TARGETS1
-rw-r--r--CC/foreign/EXPRESSIONS123
-rw-r--r--CC/foreign/RULES162
-rw-r--r--CC/foreign/TARGETS7
-rw-r--r--CC/foreign/cmake/EXPRESSIONS480
-rw-r--r--CC/foreign/cmake/RULES764
-rwxr-xr-xCC/foreign/expand_exec133
-rw-r--r--CC/foreign/expand_exec.c99
-rw-r--r--CC/foreign/make/EXPRESSIONS443
-rw-r--r--CC/foreign/make/RULES795
-rw-r--r--CC/foreign/shell/EXPRESSIONS360
-rw-r--r--CC/foreign/shell/RULES614
-rw-r--r--CC/pkgconfig/EXPRESSIONS108
-rw-r--r--CC/pkgconfig/RULES71
-rw-r--r--CC/pkgconfig/TARGETS2
-rw-r--r--CC/prebuilt/EXPRESSIONS503
-rw-r--r--CC/prebuilt/RULES147
-rwxr-xr-xCC/prebuilt/read_pkgconfig.py77
-rw-r--r--CC/proto/RULES16
-rw-r--r--CC/test/EXPRESSIONS29
-rw-r--r--CC/test/RULES15
-rw-r--r--data/EXPRESSIONS113
-rw-r--r--data/RULES39
-rw-r--r--shell/EXPRESSIONS69
-rw-r--r--shell/RULES189
-rw-r--r--shell/test/EXPRESSIONS86
-rw-r--r--shell/test/RULES23
-rwxr-xr-xshell/test/runner1
-rw-r--r--transitions/EXPRESSIONS56
31 files changed, 6940 insertions, 179 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS
index ee006da..c616dfa 100644
--- a/CC/EXPRESSIONS
+++ b/CC/EXPRESSIONS
@@ -236,13 +236,20 @@
, "debug-deps":
{ "doc":
["Collect debug dependencies (sources/headers) from given target_fields"]
- , "vars": ["deps-provider", "deps-fieldnames", "deps-transition"]
+ , "vars":
+ [ "deps-provider"
+ , "deps-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ ]
, "vars_doc":
{ "deps-provider": ["Name of provider to use (debug-srcs/debug-hdrs)."]
, "deps-fieldnames":
["List of target_field names to collect dependencies from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"provider_list": ["./", "..", "field_provider_list"]}
, "expression":
@@ -259,7 +266,17 @@
{ "type": "let*"
, "bindings":
[ ["provider", {"type": "var", "name": "deps-provider"}]
- , ["transition", {"type": "var", "name": "deps-transition"}]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
, ["default", {"type": "empty_map"}]
]
, "body": [{"type": "CALL_EXPRESSION", "name": "provider_list"}]
@@ -271,12 +288,19 @@
}
, "compile-deps":
{ "doc": ["Collect compile dependencies (headers) from given target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+ , "vars":
+ [ "deps-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ , "component-fieldnames"
+ ]
, "vars_doc":
{ "deps-fieldnames":
["List of target_field names to collect dependencies from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports":
{ "runfiles_list": ["./", "..", "field_runfiles_list"]
@@ -287,36 +311,80 @@
, "$1":
{ "type": "++"
, "$1":
- { "type": "foreach"
- , "var": "fieldname"
- , "range": {"type": "var", "name": "deps-fieldnames"}
- , "body":
- { "type": "++"
+ [ { "type": "++"
, "$1":
- { "type": "let*"
- , "bindings":
- [ ["provider", "compile-deps"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
- , ["default", {"type": "empty_map"}]
- ]
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "deps-fieldnames"}
+ , { "type": "var"
+ , "name": "component-fieldnames"
+ , "default": []
+ }
+ ]
+ }
, "body":
- [ {"type": "CALL_EXPRESSION", "name": "provider_list"}
- , {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
- ]
+ { "type": "let*"
+ , "bindings":
+ [ ["provider", "compile-deps"]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"}
+ }
}
}
- }
+ , { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range": {"type": "var", "name": "deps-fieldnames"}
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
+ }
+ }
+ }
+ ]
}
}
}
, "compile-args-deps":
{ "doc": ["Collect compile arguments from given target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
, "vars_doc":
{ "deps-fieldnames":
["List of target_field names to collect arguments from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"list_provider": ["./", "..", "field_list_provider"]}
, "expression":
@@ -331,7 +399,17 @@
{ "type": "let*"
, "bindings":
[ ["provider", "compile-args"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
]
, "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
}
@@ -341,19 +419,95 @@
}
, "link-deps":
{ "doc": ["Collect link dependencies (libraries) from given target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+ , "vars":
+ [ "deps-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ , "component-fieldnames"
+ ]
, "vars_doc":
{ "deps-fieldnames":
["List of target_field names to collect dependencies from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports":
{ "artifacts_list": ["./", "..", "field_artifacts_list"]
, "provider_list": ["./", "..", "field_provider_list"]
}
, "expression":
- { "type": "disjoint_map_union"
+ { "type": "let*"
+ , "bindings":
+ [ [ "drop_artifacts"
+ , { "type": "set"
+ , "$1":
+ {"type": "var", "name": "component-fieldnames", "default": []}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range": {"type": "var", "name": "deps-fieldnames"}
+ , "body":
+ { "type": "++"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["provider", "link-deps"]
+ , ["default", {"type": "empty_map"}]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ ]
+ , "body":
+ [ {"type": "CALL_EXPRESSION", "name": "provider_list"}
+ , { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "map": {"type": "var", "name": "drop_artifacts"}
+ , "key": {"type": "var", "name": "fieldname"}
+ }
+ , "then": []
+ , "else":
+ {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+, "link-args-deps":
+ { "doc": ["Collect linker arguments from given target_fields"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
+ , "vars_doc":
+ { "deps-fieldnames":
+ ["List of target_field names to collect arguments from."]
+ , "deps-transition":
+ ["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
+ }
+ , "imports": {"list_provider": ["./", "..", "field_list_provider"]}
+ , "expression":
+ { "type": "nub_right"
, "$1":
{ "type": "++"
, "$1":
@@ -361,32 +515,85 @@
, "var": "fieldname"
, "range": {"type": "var", "name": "deps-fieldnames"}
, "body":
- { "type": "++"
- , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["provider", "link-args"]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+ }
+ }
+ }
+, "run-libs-deps":
+ { "doc": ["Collect runtime libraries from given target_fields"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
+ , "vars_doc":
+ { "deps-fieldnames":
+ ["List of target_field names to collect dependencies from."]
+ , "deps-transition":
+ ["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
+ }
+ , "imports": {"provider_list": ["./", "..", "field_provider_list"]}
+ , "expression":
+ { "type": "to_subdir"
+ , "flat": true
+ , "$1":
+ { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range": {"type": "var", "name": "deps-fieldnames"}
+ , "body":
{ "type": "let*"
, "bindings":
- [ ["provider", "link-deps"]
+ [ ["provider", "run-libs"]
, ["default", {"type": "empty_map"}]
- , ["transition", {"type": "var", "name": "deps-transition"}]
- ]
- , "body":
- [ {"type": "CALL_EXPRESSION", "name": "provider_list"}
- , {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
]
+ , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"}
}
}
}
}
}
}
-, "link-args-deps":
- { "doc": ["Collect linker arguments from given target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+, "run-libs-args-deps":
+ { "doc":
+ ["Collect runtime libraries link arguments from given target_fields"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
, "vars_doc":
{ "deps-fieldnames":
["List of target_field names to collect arguments from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"list_provider": ["./", "..", "field_list_provider"]}
, "expression":
@@ -400,8 +607,18 @@
, "body":
{ "type": "let*"
, "bindings":
- [ ["provider", "link-args"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
+ [ ["provider", "run-libs-args"]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
]
, "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
}
@@ -411,12 +628,15 @@
}
, "pkg-map-provider-deps":
{ "doc": ["Collect maps from provider \"package\" for given target_fields"]
- , "vars": ["pkg-key", "deps-fieldnames", "deps-transition"]
+ , "vars":
+ ["pkg-key", "deps-fieldnames", "deps-transition", "modified-transitions"]
, "vars_doc":
{ "pkg-key": ["Key to lookup in provider \"package\"."]
, "deps-fieldnames": ["List of target_field names to collect maps from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"provider_list": ["./", "..", "field_provider_list"]}
, "expression":
@@ -432,7 +652,17 @@
, "bindings":
[ ["provider", "package"]
, ["default", {"type": "empty_map"}]
- , ["transition", {"type": "var", "name": "deps-transition"}]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
]
, "body":
{ "type": "foreach"
@@ -452,11 +682,13 @@
}
, "cflags-files-deps":
{ "doc": ["Collect cflags files from target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
, "vars_doc":
{ "deps-fieldnames": ["List of target_field names to collect files from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"pkg-provider": "pkg-map-provider-deps"}
, "expression":
@@ -467,11 +699,13 @@
}
, "ldflags-files-deps":
{ "doc": ["Collect cflags files from target_fields"]
- , "vars": ["deps-fieldnames", "deps-transition"]
+ , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"]
, "vars_doc":
{ "deps-fieldnames": ["List of target_field names to collect files from."]
, "deps-transition":
["The optional configuration transition for the targets."]
+ , "modified-transitions":
+ ["Map telling fields that need to be transitioned differently"]
}
, "imports": {"pkg-provider": "pkg-map-provider-deps"}
, "expression":
@@ -693,7 +927,11 @@
, "private-hdrs"
, "compile-deps"
, "cflags-files"
+ , "component-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
]
+ , "imports": {"field_artifacts": ["./", "..", "field_artifacts"]}
, "expression":
{ "type": "let*"
, "bindings":
@@ -721,93 +959,129 @@
]
}
]
- ]
- , "body":
- { "type": "map_union"
- , "$1":
- { "type": "foreach_map"
- , "var_key": "src_name"
- , "var_val": "src_val"
- , "range": {"type": "var", "name": "srcs"}
- , "body":
- { "type": "let*"
- , "bindings":
- [ [ "work src_name"
- , { "type": "join"
- , "separator": "/"
- , "$1": ["work", {"type": "var", "name": "src_name"}]
- }
- ]
- , [ "inputs"
- , { "type": "map_union"
- , "$1":
- [ {"type": "var", "name": "all hdrs"}
- , { "type": "singleton_map"
- , "key": {"type": "var", "name": "work src_name"}
- , "value": {"type": "var", "name": "src_val"}
+ , [ "my objects"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach_map"
+ , "var_key": "src_name"
+ , "var_val": "src_val"
+ , "range": {"type": "var", "name": "srcs"}
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "work src_name"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": ["work", {"type": "var", "name": "src_name"}]
}
- , { "type": "var"
- , "name": "cflags-files"
- , "default": {"type": "empty_map"}
+ ]
+ , [ "inputs"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "all hdrs"}
+ , { "type": "singleton_map"
+ , "key": {"type": "var", "name": "work src_name"}
+ , "value": {"type": "var", "name": "src_val"}
+ }
+ , { "type": "var"
+ , "name": "cflags-files"
+ , "default": {"type": "empty_map"}
+ }
+ , { "type": "var"
+ , "name": "TOOLCHAIN"
+ , "default": {"type": "empty_map"}
+ }
+ ]
}
- , { "type": "var"
- , "name": "TOOLCHAIN"
- , "default": {"type": "empty_map"}
+ ]
+ , [ "out"
+ , { "type": "change_ending"
+ , "$1": {"type": "var", "name": "src_name"}
+ , "ending": ".o"
}
]
- }
- ]
- , [ "out"
- , { "type": "change_ending"
- , "$1": {"type": "var", "name": "src_name"}
- , "ending": ".o"
- }
- ]
- , [ "work out"
- , { "type": "join"
- , "separator": "/"
- , "$1": ["work", {"type": "var", "name": "out"}]
- }
- ]
- , [ "action output"
- , { "type": "ACTION"
- , "outs": [{"type": "var", "name": "work out"}]
- , "inputs": {"type": "var", "name": "inputs"}
- , "env":
- { "type": "var"
- , "name": "ENV"
- , "default": {"type": "empty_map"}
- }
- , "cmd":
- { "type": "++"
- , "$1":
- [ [{"type": "var", "name": "COMPILER"}]
- , {"type": "var", "name": "COMPILE_FLAGS"}
- , ["-I", "work", "-isystem", "include"]
- , ["-c", {"type": "var", "name": "work src_name"}]
- , ["-o", {"type": "var", "name": "work out"}]
- ]
- }
- }
- ]
- , [ "staged output artifact"
- , { "type": "map_union"
- , "$1":
- { "type": "foreach_map"
- , "range": {"type": "var", "name": "action output"}
- , "var_val": "object"
- , "body":
- { "type": "singleton_map"
- , "key": {"type": "var", "name": "out"}
- , "value": {"type": "var", "name": "object"}
+ , [ "work out"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": ["work", {"type": "var", "name": "out"}]
}
- }
- }
- ]
- ]
- , "body": {"type": "var", "name": "staged output artifact"}
+ ]
+ , [ "action output"
+ , { "type": "ACTION"
+ , "outs": [{"type": "var", "name": "work out"}]
+ , "inputs": {"type": "var", "name": "inputs"}
+ , "env":
+ { "type": "var"
+ , "name": "ENV"
+ , "default": {"type": "empty_map"}
+ }
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [{"type": "var", "name": "COMPILER"}]
+ , {"type": "var", "name": "COMPILE_FLAGS"}
+ , ["-I", "work", "-isystem", "include"]
+ , ["-c", {"type": "var", "name": "work src_name"}]
+ , ["-o", {"type": "var", "name": "work out"}]
+ ]
+ }
+ }
+ ]
+ , [ "staged output artifact"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach_map"
+ , "range": {"type": "var", "name": "action output"}
+ , "var_val": "object"
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "out"}
+ , "value": {"type": "var", "name": "object"}
+ }
+ }
+ }
+ ]
+ ]
+ , "body": {"type": "var", "name": "staged output artifact"}
+ }
+ }
}
- }
+ ]
+ , [ "component artifacts"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range":
+ {"type": "var", "name": "component-fieldnames", "default": []}
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "field_artifacts"}
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "disjoint_map_union"
+ , "msg": "Stating conflict between own objects and objects of components"
+ , "$1":
+ [ {"type": "var", "name": "my objects"}
+ , {"type": "var", "name": "component artifacts"}
+ ]
}
}
}
@@ -823,6 +1097,7 @@
, "deps-fieldnames"
, "compile-args"
, "defaults-transition"
+ , "modified-transitions"
]
, "imports":
{ "objects": "objects"
@@ -876,17 +1151,28 @@
, { "type": "to_subdir"
, "subdir": "include"
, "$1":
- { "type": "let*"
- , "bindings":
- [["transition", {"type": "var", "name": "deps-transition"}]]
- , "body":
- { "type": "map_union"
+ { "type": "map_union"
+ , "$1":
+ { "type": "++"
, "$1":
- { "type": "++"
- , "$1":
- { "type": "foreach"
- , "var": "fieldname"
- , "range": {"type": "var", "name": "deps-fieldnames"}
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range": {"type": "var", "name": "deps-fieldnames"}
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
+ ]
, "body":
{"type": "CALL_EXPRESSION", "name": "runfiles_list"}
}
@@ -1051,7 +1337,17 @@
{ "type": "let*"
, "bindings":
[ ["provider", "lint"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
+ , [ "transition"
+ , { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "modified-transitions"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": {"type": "var", "name": "fieldname"}
+ , "default": {"type": "var", "name": "deps-transition"}
+ }
+ ]
]
, "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
}
@@ -1142,12 +1438,21 @@
}
}
, "flags-cc":
- { "vars": ["CFLAGS", "ADD_CFLAGS", "defaults-transition"]
+ { "vars":
+ [ "CFLAGS"
+ , "ADD_CFLAGS"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "defaults-transition"
+ ]
, "imports": {"default-CFLAGS": "default-CFLAGS"}
, "expression":
{ "type": "++"
, "$1":
- [ { "type": "var"
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "BUILD_POSITION_INDEPENDENT"}
+ , "then": ["-fPIC"]
+ }
+ , { "type": "var"
, "name": "CFLAGS"
, "default": {"type": "CALL_EXPRESSION", "name": "default-CFLAGS"}
}
@@ -1156,12 +1461,21 @@
}
}
, "flags-cxx":
- { "vars": ["CXXFLAGS", "ADD_CXXFLAGS", "defaults-transition"]
+ { "vars":
+ [ "CXXFLAGS"
+ , "ADD_CXXFLAGS"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "defaults-transition"
+ ]
, "imports": {"default-CXXFLAGS": "default-CXXFLAGS"}
, "expression":
{ "type": "++"
, "$1":
- [ { "type": "var"
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "BUILD_POSITION_INDEPENDENT"}
+ , "then": ["-fPIC"]
+ }
+ , { "type": "var"
, "name": "CXXFLAGS"
, "default": {"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"}
}
@@ -1175,6 +1489,7 @@
, "CXXFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "BUILD_POSITION_INDEPENDENT"
, "pure C"
, "defaults-transition"
]
@@ -1196,6 +1511,7 @@
, "ADD_CXXFLAGS"
, "AR"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "name"
, "pure C"
, "srcs"
@@ -1206,6 +1522,9 @@
, "compile-args"
, "cflags-files"
, "defaults-transition"
+ , "component-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
]
, "imports":
{ "compiler": "compiler"
@@ -1409,6 +1728,7 @@
, "ADD_CXXFLAGS"
, "AR"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "DEBUG"
, "LINT"
, "name"
@@ -1418,18 +1738,25 @@
, "private-hdrs"
, "cflags"
, "private-cflags"
+ , "ldflags"
, "private-ldflags"
, "stage"
, "pkg-name"
, "extra-provides"
, "public-fieldnames"
, "private-fieldnames"
+ , "component-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ , "defaults-transition"
]
, "imports":
{ "compile-deps": "compile-deps"
, "compile-args-deps": "compile-args-deps"
, "link-deps": "link-deps"
, "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
, "cflags-files-deps": "cflags-files-deps"
, "ldflags-files-deps": "ldflags-files-deps"
, "lib artifact": "lib artifact"
@@ -1458,7 +1785,7 @@
]
, ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
, ["lib", {"type": "CALL_EXPRESSION", "name": "lib artifact"}]
- , ["lint-deps fieldnames", ["deps", "private-deps"]]
+ , ["lint-deps fieldnames", ["deps", "private-deps", "components"]]
, [ "lint"
, { "type": "if"
, "cond": {"type": "var", "name": "LINT"}
@@ -1471,12 +1798,17 @@
{ "type": "++"
, "$1":
[ {"type": "keys", "$1": {"type": "var", "name": "lib"}}
+ , {"type": "var", "name": "ldflags", "default": []}
, {"type": "var", "name": "private-ldflags", "default": []}
, {"type": "CALL_EXPRESSION", "name": "link-args-deps"}
]
}
}
]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, [ "ldflags-files"
, {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
]
@@ -1551,6 +1883,726 @@
, "compile-args"
, "link-deps"
, "link-args"
+ , "run-libs"
+ , "run-libs-args"
+ , "package"
+ , "debug-srcs"
+ , "debug-hdrs"
+ , "lint"
+ ]
+ }
+ , { "type": "var"
+ , "name": "extra-provides"
+ , "default": {"type": "empty_map"}
+ }
+ ]
+ }
+ }
+ }
+ }
+, "shared artifact":
+ { "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "name"
+ , "pure C"
+ , "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "soversion"
+ , "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "run-libs"
+ , "run-libs-args"
+ , "cflags-files"
+ , "ldflags-files"
+ , "defaults-transition"
+ , "component-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ ]
+ , "imports":
+ { "compiler": "compiler"
+ , "flags": "flags"
+ , "objects": "objects"
+ , "default-ENV": "default-ENV"
+ , "default-PATH": "default-PATH"
+ , "default-LDFLAGS": "default-LDFLAGS"
+ , "default-TOOLCHAIN": "default-TOOLCHAIN"
+ , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["BUILD_POSITION_INDEPENDENT", true]
+ , ["TOOLCHAIN_DIR", "toolchain"]
+ , ["TOOLCHAIN", {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}]
+ , [ "TOOLCHAIN"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ ]
+ , [ "NON_SYSTEM_TOOLS"
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
+ , ["COMPILER", {"type": "CALL_EXPRESSION", "name": "compiler"}]
+ , [ "COMPILE_FLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "flags"}
+ , {"type": "var", "name": "compile-args"}
+ ]
+ }
+ ]
+ , [ "LDFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "var"
+ , "name": "LDFLAGS"
+ , "default":
+ {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ }
+ , {"type": "var", "name": "ADD_LDFLAGS", "default": []}
+ ]
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "ENV_PATH"
+ , { "type": "lookup"
+ , "map": {"type": "var", "name": "ENV"}
+ , "key": "PATH"
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "ENV"}
+ , { "type": "singleton_map"
+ , "key": "PATH"
+ , "value":
+ { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ENV_PATH"}
+ , "then": [{"type": "var", "name": "ENV_PATH"}]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}]
+ , [ "base name"
+ , { "type": "if"
+ , "cond":
+ { "type": "or"
+ , "$1":
+ [ {"type": "var", "name": "objects"}
+ , {"type": "var", "name": "link-deps"}
+ ]
+ }
+ , "then":
+ { "type": "assert_non_empty"
+ , "msg": "A name has to be provided for non-header-only libraries"
+ , "$1": {"type": "var", "name": "name"}
+ }
+ , "else": {"type": "var", "name": "name"}
+ }
+ ]
+ , [ "libname"
+ , { "type": "join"
+ , "$1": ["lib", {"type": "var", "name": "base name"}, ".so"]
+ }
+ ]
+ , [ "libname"
+ , { "type": "join"
+ , "separator": "."
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [{"type": "var", "name": "libname"}]
+ , {"type": "var", "name": "soversion"}
+ ]
+ }
+ }
+ ]
+ , [ "lib"
+ , { "type": "if"
+ , "cond":
+ { "type": "or"
+ , "$1":
+ [ {"type": "var", "name": "objects"}
+ , {"type": "var", "name": "link-deps"}
+ ]
+ }
+ , "else": {"type": "empty_map"}
+ , "then":
+ { "type": "ACTION"
+ , "outs": [{"type": "var", "name": "libname"}]
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "TOOLCHAIN"}
+ , {"type": "var", "name": "objects"}
+ , {"type": "var", "name": "link-deps"}
+ , {"type": "var", "name": "run-libs"}
+ , { "type": "var"
+ , "name": "cflags-files"
+ , "default": {"type": "empty_map"}
+ }
+ , { "type": "var"
+ , "name": "ldflags-files"
+ , "default": {"type": "empty_map"}
+ }
+ ]
+ }
+ , "env":
+ {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [ {"type": "var", "name": "COMPILER"}
+ , "-shared"
+ , "-Wl,-rpath,$ORIGIN"
+ , "-Wl,-rpath,$ORIGIN/../lib"
+ , { "type": "join"
+ , "$1":
+ ["-Wl,-soname,", {"type": "var", "name": "libname"}]
+ }
+ ]
+ , {"type": "var", "name": "COMPILE_FLAGS"}
+ , ["-o", {"type": "var", "name": "libname"}]
+ , {"type": "keys", "$1": {"type": "var", "name": "objects"}}
+ , {"type": "var", "name": "link-args"}
+ , {"type": "var", "name": "run-libs-args"}
+ , {"type": "var", "name": "LDFLAGS"}
+ ]
+ }
+ }
+ }
+ ]
+ ]
+ , "body": {"type": "var", "name": "lib"}
+ }
+ }
+, "shared result":
+ { "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_LDFLAGS"
+ , "ENV"
+ , "DEBUG"
+ , "LINT"
+ , "name"
+ , "pure C"
+ , "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "cflags"
+ , "private-cflags"
+ , "ldflags"
+ , "private-ldflags"
+ , "soversion"
+ , "pkg-name"
+ , "extra-provides"
+ , "defaults-transition"
+ , "deps-transition"
+ , "modified-transitions"
+ , "public-fieldnames"
+ , "private-fieldnames"
+ , "component-fieldnames"
+ ]
+ , "imports":
+ { "compile-deps": "compile-deps"
+ , "compile-args-deps": "compile-args-deps"
+ , "link-deps": "link-deps"
+ , "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
+ , "cflags-files-deps": "cflags-files-deps"
+ , "ldflags-files-deps": "ldflags-files-deps"
+ , "shared artifact": "shared artifact"
+ , "debug-deps": "debug-deps"
+ , "lint": "lint information"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["deps-fieldnames", {"type": "var", "name": "private-fieldnames"}]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "cflags"}
+ , {"type": "var", "name": "private-cflags"}
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
+ , ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "ldflags", "default": []}
+ , {"type": "var", "name": "private-ldflags", "default": []}
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "ldflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ ]
+ , ["lib", {"type": "CALL_EXPRESSION", "name": "shared artifact"}]
+ , [ "debug-srcs"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["deps-provider", "debug-srcs"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"}
+ }
+ , {"type": "var", "name": "srcs"}
+ , {"type": "var", "name": "private-hdrs"}
+ , {"type": "var", "name": "hdrs"}
+ ]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , ["lint-deps fieldnames", ["deps", "private-deps", "components"]]
+ , [ "lint"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "LINT"}
+ , "then": {"type": "CALL_EXPRESSION", "name": "lint"}
+ }
+ ]
+ , [ "debug-hdrs"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["deps-provider", "debug-hdrs"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"}
+ }
+ , {"type": "var", "name": "hdrs"}
+ ]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , ["deps-fieldnames", {"type": "var", "name": "public-fieldnames"}]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "cflags"}
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , ["link-deps", {"type": "empty_map"}]
+ , ["link-args", []]
+ , [ "run-libs"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "lib"}
+ , {"type": "var", "name": "run-libs"}
+ ]
+ }
+ ]
+ , [ "run-libs-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "keys", "$1": {"type": "var", "name": "lib"}}
+ , {"type": "var", "name": "ldflags", "default": []}
+ ]
+ }
+ }
+ ]
+ , [ "ldflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ ]
+ , [ "package"
+ , { "type": "let*"
+ , "bindings":
+ [ ["name", {"type": "var", "name": "pkg-name"}]
+ , [ "version"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "soversion"}
+ , "then":
+ { "type": "join"
+ , "separator": "."
+ , "$1": {"type": "var", "name": "soversion"}
+ }
+ , "else": null
+ }
+ ]
+ ]
+ , "body":
+ { "type": "env"
+ , "vars": ["name", "version", "cflags-files", "ldflags-files"]
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts": {"type": "var", "name": "lib"}
+ , "runfiles": {"type": "var", "name": "hdrs"}
+ , "provides":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "run-libs"
+ , "run-libs-args"
+ , "package"
+ , "debug-srcs"
+ , "debug-hdrs"
+ , "lint"
+ ]
+ }
+ , { "type": "var"
+ , "name": "extra-provides"
+ , "default": {"type": "empty_map"}
+ }
+ ]
+ }
+ }
+ }
+ }
+, "object artifacts":
+ { "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "AR"
+ , "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "name"
+ , "pure C"
+ , "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "stage"
+ , "compile-deps"
+ , "compile-args"
+ , "cflags-files"
+ , "defaults-transition"
+ , "modified-transitions"
+ , "component-fieldnames"
+ ]
+ , "imports":
+ { "compiler": "compiler"
+ , "flags": "flags"
+ , "objects": "objects"
+ , "default-AR": "default-AR"
+ , "default-ENV": "default-ENV"
+ , "default-PATH": "default-PATH"
+ , "default-TOOLCHAIN": "default-TOOLCHAIN"
+ , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["TOOLCHAIN_DIR", "toolchain"]
+ , ["TOOLCHAIN", {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}]
+ , [ "TOOLCHAIN"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ ]
+ , [ "NON_SYSTEM_TOOLS"
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
+ , ["COMPILER", {"type": "CALL_EXPRESSION", "name": "compiler"}]
+ , [ "COMPILE_FLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "flags"}
+ , {"type": "var", "name": "compile-args"}
+ ]
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "ENV_PATH"
+ , { "type": "lookup"
+ , "map": {"type": "var", "name": "ENV"}
+ , "key": "PATH"
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "ENV"}
+ , { "type": "singleton_map"
+ , "key": "PATH"
+ , "value":
+ { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ENV_PATH"}
+ , "then": [{"type": "var", "name": "ENV_PATH"}]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "objects"}
+ }
+ }
+, "object result":
+ { "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "AR"
+ , "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
+ , "DEBUG"
+ , "LINT"
+ , "name"
+ , "pure C"
+ , "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "cflags"
+ , "private-cflags"
+ , "ldflags"
+ , "private-ldflags"
+ , "stage"
+ , "pkg-name"
+ , "extra-provides"
+ , "public-fieldnames"
+ , "private-fieldnames"
+ , "component-fieldnames"
+ , "deps-transition"
+ , "modified-transitions"
+ , "defaults-transition"
+ ]
+ , "imports":
+ { "compile-deps": "compile-deps"
+ , "compile-args-deps": "compile-args-deps"
+ , "link-deps": "link-deps"
+ , "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
+ , "cflags-files-deps": "cflags-files-deps"
+ , "ldflags-files-deps": "ldflags-files-deps"
+ , "object artifacts": "object artifacts"
+ , "debug-deps": "debug-deps"
+ , "lint": "lint information"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["deps-fieldnames", {"type": "var", "name": "private-fieldnames"}]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "cflags"}
+ , {"type": "var", "name": "private-cflags"}
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
+ , ["objects", {"type": "CALL_EXPRESSION", "name": "object artifacts"}]
+ , ["lint-deps fieldnames", ["deps", "private-deps", "components"]]
+ , [ "lint"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "LINT"}
+ , "then": {"type": "CALL_EXPRESSION", "name": "lint"}
+ }
+ ]
+ , [ "link-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "var"
+ , "name": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
+ }
+ , "then": []
+ , "else":
+ {"type": "keys", "$1": {"type": "var", "name": "objects"}}
+ }
+ , {"type": "var", "name": "ldflags", "default": []}
+ , {"type": "var", "name": "private-ldflags", "default": []}
+ , {"type": "CALL_EXPRESSION", "name": "link-args-deps"}
+ ]
+ }
+ }
+ ]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , { "type": "nub_right"
+ , "$1": {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ }
+ ]
+ , [ "ldflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ ]
+ , [ "debug-srcs"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["deps-provider", "debug-srcs"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"}
+ }
+ , {"type": "var", "name": "srcs"}
+ , {"type": "var", "name": "private-hdrs"}
+ , {"type": "var", "name": "hdrs"}
+ ]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , [ "debug-hdrs"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["deps-provider", "debug-hdrs"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"}
+ }
+ , {"type": "var", "name": "hdrs"}
+ ]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , ["deps-fieldnames", {"type": "var", "name": "public-fieldnames"}]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "cflags"}
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , [ "package"
+ , { "type": "let*"
+ , "bindings": [["name", {"type": "var", "name": "pkg-name"}]]
+ , "body":
+ {"type": "env", "vars": ["name", "cflags-files", "ldflags-files"]}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts": {"type": "var", "name": "objects"}
+ , "runfiles": {"type": "var", "name": "hdrs"}
+ , "provides":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "run-libs"
+ , "run-libs-args"
, "package"
, "debug-srcs"
, "debug-hdrs"
@@ -1573,9 +2625,12 @@
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "name"
, "pure C"
, "srcs"
@@ -1585,6 +2640,8 @@
, "compile-args"
, "link-deps"
, "link-args"
+ , "run-libs"
+ , "run-libs-args"
, "cflags-files"
, "ldflags-files"
, "defaults-transition"
@@ -1622,7 +2679,18 @@
]
}
]
- , ["LDFLAGS", {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}]
+ , [ "LDFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "var"
+ , "name": "LDFLAGS"
+ , "default":
+ {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ }
+ , {"type": "var", "name": "ADD_LDFLAGS", "default": []}
+ ]
+ }
+ ]
, [ "ENV"
, { "type": "map_union"
, "$1":
@@ -1721,11 +2789,14 @@
, { "type": "++"
, "$1":
[ [ {"type": "var", "name": "COMPILER"}
+ , "-Wl,-rpath,$ORIGIN"
+ , "-Wl,-rpath,$ORIGIN/../lib"
, "-o"
, {"type": "var", "name": "binpath"}
]
, {"type": "var", "name": "COMPILE_FLAGS"}
, {"type": "var", "name": "link-args"}
+ , {"type": "var", "name": "run-libs-args"}
, {"type": "var", "name": "LDFLAGS"}
]
}
@@ -1744,6 +2815,7 @@
, "$1":
[ {"type": "var", "name": "objects"}
, {"type": "var", "name": "link-deps"}
+ , {"type": "var", "name": "run-libs"}
, { "type": "var"
, "name": "cflags-files"
, "default": {"type": "empty_map"}
@@ -1783,9 +2855,12 @@
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "DEBUG"
, "LINT"
, "name"
@@ -1796,12 +2871,15 @@
, "private-ldflags"
, "stage"
, "private-fieldnames"
+ , "component-fieldnames"
]
, "imports":
{ "compile-deps": "compile-deps"
, "compile-args-deps": "compile-args-deps"
, "link-deps": "link-deps"
, "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
, "cflags-files-deps": "cflags-files-deps"
, "ldflags-files-deps": "ldflags-files-deps"
, "binary": "bin artifact"
@@ -1833,6 +2911,10 @@
}
}
]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, [ "cflags-files"
, {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
]
@@ -1892,12 +2974,12 @@
, "artifacts": {"type": "CALL_EXPRESSION", "name": "binary"}
, "provides":
{ "type": "env"
- , "vars": ["package", "debug-srcs", "debug-hdrs", "lint"]
+ , "vars": ["run-libs", "package", "debug-srcs", "debug-hdrs", "lint"]
}
}
}
}
-, "install-with-deps result":
+, "install-with-deps stage":
{ "vars":
[ "pc-install-dir"
, "targets"
@@ -1906,7 +2988,15 @@
, "hdrs-only"
, "skip-debug-stage"
]
- , "imports": {"pkg-config": "pkg-config"}
+ , "imports":
+ { "compile-deps": "compile-deps"
+ , "compile-args-deps": "compile-args-deps"
+ , "link-deps": "link-deps"
+ , "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
+ , "pkg-config": "pkg-config"
+ }
, "expression":
{ "type": "let*"
, "bindings":
@@ -1987,6 +3077,13 @@
, "default": {"type": "empty_map"}
}
]
+ , [ "run-libs"
+ , { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "target"}
+ , "provider": "run-libs"
+ , "default": {"type": "empty_map"}
+ }
+ ]
, [ "package"
, { "type": "DEP_PROVIDES"
, "dep": {"type": "var", "name": "target"}
@@ -2019,6 +3116,7 @@
, "else": [{"type": "var", "name": "artifacts"}]
}
, [{"type": "var", "name": "link-deps"}]
+ , [{"type": "var", "name": "run-libs"}]
]
}
}
@@ -2057,6 +3155,11 @@
, "provider": "link-args"
, "default": []
}
+ , { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "target"}
+ , "provider": "run-libs-args"
+ , "default": []
+ }
]
}
]
@@ -2139,8 +3242,22 @@
}
]
]
- , "body":
- {"type": "RESULT", "artifacts": {"type": "var", "name": "install-stage"}}
+ , "body": {"type": "var", "name": "install-stage"}
+ }
+ }
+, "install-with-deps result":
+ { "vars":
+ [ "pc-install-dir"
+ , "targets"
+ , "prefix"
+ , "flat-libs"
+ , "hdrs-only"
+ , "skip-debug-stage"
+ ]
+ , "imports": {"install stage": "install-with-deps stage"}
+ , "expression":
+ { "type": "RESULT"
+ , "artifacts": {"type": "CALL_EXPRESSION", "name": "install stage"}
}
}
}
diff --git a/CC/RULES b/CC/RULES
index 0f1b0ff..6c07275 100644
--- a/CC/RULES
+++ b/CC/RULES
@@ -103,6 +103,8 @@
, "compile-args-deps": "compile-args-deps"
, "link-deps": "link-deps"
, "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
, "cflags-files-deps": "cflags-files-deps"
, "ldflags-files-deps": "ldflags-files-deps"
, "for host": ["transitions", "for host"]
@@ -315,6 +317,10 @@
]
, ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
, ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, [ "cflags-files"
, {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
]
@@ -370,6 +376,8 @@
, "compile-args"
, "link-deps"
, "link-args"
+ , "run-libs"
+ , "run-libs-args"
, "package"
, "debug-srcs"
, "debug-hdrs"
@@ -381,7 +389,15 @@
, "library":
{ "doc": ["A C++ library"]
, "target_fields":
- ["srcs", "hdrs", "private-hdrs", "deps", "private-deps", "proto"]
+ [ "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "deps"
+ , "private-deps"
+ , "proto"
+ , "private-proto"
+ , "components"
+ ]
, "string_fields":
[ "name"
, "stage"
@@ -390,18 +406,26 @@
, "private-defines"
, "cflags"
, "private-cflags"
+ , "ldflags"
, "private-ldflags"
+ , "soversion"
, "pkg-name"
]
+ , "config_fields": ["shared"]
, "config_vars":
[ "CC"
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "AR"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "BUILD_OBJECT_ONLY"
+ , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
, "DEBUG"
, "LINT"
]
@@ -415,6 +439,11 @@
[ "Any header files that only need to be present when compiling the"
, "source files, but are not needed for any consumer of the library."
]
+ , "components":
+ [ "Any other libraries that are considered part of this library;"
+ , "all object files of those are included unconditionally into this"
+ , "library."
+ ]
, "stage":
[ "The logical location of all header and source files, as well as the"
, "resulting library file. Individual directory components are joined"
@@ -437,6 +466,11 @@
["List of compile flags set for this target and its consumers."]
, "private-cflags":
["List of compile flags set for source files local to this target."]
+ , "ldflags":
+ [ "Additional linker flags for linking external libraries for this"
+ , "target and its consumers (not built by this tool, typically system"
+ , "libraries)."
+ ]
, "private-ldflags":
[ "Additional linker flags for linking external libraries (not built"
, "by this tool, typically system libraries)."
@@ -453,6 +487,18 @@
, "duplicate work will be carried out, even if the same proto library"
, "is used at various places)."
]
+ , "private-proto":
+ [ "Any [\"proto\", \"library\"] this target depends upon privately."
+ , "The creation of C++ bindings for this proto library as well as of"
+ , "its dependencies will be taken care of (as anonymous targets, so no"
+ , "duplicate work will be carried out, even if the same proto library"
+ , "is used at various places)."
+ ]
+ , "shared": ["If non-empty, produce a shared instead of a static library."]
+ , "soversion":
+ [ "The SOVERSION for shared libraries. Individual version components are"
+ , "joined with \".\"."
+ ]
, "pkg-name":
[ "Name to use for pkg-config files. If this field is empty, the field"
, "\"name\" is used instead."
@@ -480,6 +526,12 @@
, "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 built 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"
@@ -492,12 +544,31 @@
, "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 built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
, "AR":
[ "The archive tool to used for creating the library"
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "ENV": ["The environment for any action generated."]
+ , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."]
, "DEBUG": ["Compute the debug-stage, needed for local debugging."]
+ , "BUILD_OBJECT_ONLY":
+ [ "If true, produce an object library, resulting in object files"
+ , "added to the linker line of all depending targets. If this"
+ , "configuration is set, the \"shared\" option is ignored. This"
+ , "variable is cleared for all dependencies."
+ ]
+ , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING":
+ [ "If true, do not include the objects in the provided \"link-args\"."
+ , "This allows consuming libraries that pick on the objects themselves"
+ , "to still forward the \"link-args\" of that library, and thus getting"
+ , "correct linking instructions for the resulting library."
+ ]
, "LINT":
[ "Also provide nodes describing compile actions and header files;"
, "those can be used by lint rules (doing also the config transition)"
@@ -522,6 +593,20 @@
]
, "debug-srcs": ["Map of all sources needed for debugging."]
, "debug-hdrs": ["Map of all additional headers needed for debugging."]
+ , "run-libs":
+ [ "Map of artifacts specifying libraries that have to be present at"
+ , "runtime (as well as during linking)."
+ ]
+ , "run-libs-args":
+ [ "Additional arguments for linking that are related to the run-libs."
+ , "Those are added on the linker command line after the regular link-args."
+ ]
+ , "package":
+ [ "Information related to packaging the library. This provider is a map,"
+ , "specifying \"name\" and \"version\" of the package, as well as"
+ , "additional stages \"cflags-files\" and \"ldflags-files\" for files"
+ , "with compile-flags or link-flags, respctively."
+ ]
}
, "anonymous":
{ "proto-deps":
@@ -532,9 +617,34 @@
, "service library": ["./", "proto", "service library"]
}
}
+ , "private-proto-deps":
+ { "target": "private-proto"
+ , "provider": "proto"
+ , "rule_map":
+ { "library": ["./", "proto", "library"]
+ , "service library": ["./", "proto", "service library"]
+ }
+ }
}
, "imports":
- {"artifacts": ["./", "..", "field_artifacts"], "result": "lib result"}
+ { "artifacts": ["./", "..", "field_artifacts"]
+ , "runfiles": ["./", "..", "field_runfiles"]
+ , "static result": "lib result"
+ , "shared result": "shared result"
+ , "object result": "object result"
+ , "fPIC transition": ["transitions", "with fPIC, not object-only"]
+ , "component transition": ["transitions", "with fPIC, object-only"]
+ }
+ , "config_transitions":
+ { "deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "private-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "proto-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "private-proto-deps":
+ [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "defaults": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "components":
+ [{"type": "CALL_EXPRESSION", "name": "component transition"}]
+ }
, "expression":
{ "type": "let*"
, "bindings":
@@ -592,6 +702,27 @@
}
}
]
+ , [ "component transition"
+ , {"type": "CALL_EXPRESSION", "name": "component transition"}
+ ]
+ , [ "component hdrs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "components"]
+ , ["transition", {"type": "var", "name": "component transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "runfiles"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "disjoint_map_union"
+ , "msg": "Staging conflict between component and own header files"
+ , "$1":
+ [ {"type": "var", "name": "hdrs"}
+ , {"type": "var", "name": "component hdrs"}
+ ]
+ }
+ ]
, [ "private-hdrs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
@@ -602,7 +733,9 @@
}
}
]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
, ["private-ldflags", {"type": "FIELD", "name": "private-ldflags"}]
+ , ["soversion", {"type": "FIELD", "name": "soversion"}]
, [ "pkg-name"
, { "type": "if"
, "cond": {"type": "FIELD", "name": "pkg-name"}
@@ -611,12 +744,52 @@
, "else": {"type": "var", "name": "name"}
}
]
+ , [ "defaults-transition"
+ , {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
+ ]
+ , [ "deps-transition"
+ , {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
+ ]
, ["public-fieldnames", ["deps", "proto-deps", "defaults"]]
, [ "private-fieldnames"
- , ["deps", "private-deps", "proto-deps", "defaults"]
+ , [ "deps"
+ , "private-deps"
+ , "proto-deps"
+ , "private-proto-deps"
+ , "defaults"
+ , "components"
+ ]
+ ]
+ , ["component-fieldnames", ["components"]]
+ , [ "modified-transitions"
+ , { "type": "singleton_map"
+ , "key": "components"
+ , "value": {"type": "var", "name": "component transition"}
+ }
+ ]
+ , [ "shared"
+ , { "type": "and"
+ , "$1":
+ [ {"type": "FIELD", "name": "shared"}
+ , { "type": "not"
+ , "$1": {"type": "var", "name": "BUILD_OBJECT_ONLY"}
+ }
+ ]
+ }
]
]
- , "body": {"type": "CALL_EXPRESSION", "name": "result"}
+ , "body":
+ { "type": "cond"
+ , "cond":
+ [ [ {"type": "var", "name": "shared"}
+ , {"type": "CALL_EXPRESSION", "name": "shared result"}
+ ]
+ , [ {"type": "var", "name": "BUILD_OBJECT_ONLY"}
+ , {"type": "CALL_EXPRESSION", "name": "object result"}
+ ]
+ ]
+ , "default": {"type": "CALL_EXPRESSION", "name": "static result"}
+ }
}
}
, "binary":
@@ -635,9 +808,12 @@
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "DEBUG"
, "LINT"
]
@@ -688,6 +864,10 @@
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "LDFLAGS":
+ [ "The linker flags do be used instead of the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "ADD_CFLAGS":
[ "The flags to add to the default ones for CC"
, "taken from the [\"CC\", \"defaults\"] target"
@@ -696,7 +876,12 @@
[ "The flags to add to the default ones for CXX"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "ENV": ["The environment for any action generated."]
+ , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."]
, "DEBUG": ["Compute the debug-stage, needed for local debugging."]
, "LINT":
[ "Also provide nodes describing compile actions and header files;"
diff --git a/CC/TARGETS b/CC/TARGETS
index 2da456b..8860e8b 100644
--- a/CC/TARGETS
+++ b/CC/TARGETS
@@ -4,6 +4,7 @@
, "CXX": ["c++"]
, "CFLAGS": []
, "CXXFLAGS": []
+ , "LDFLAGS": []
, "AR": ["ar"]
, "PATH": ["/bin", "/usr/bin"]
}
diff --git a/CC/foreign/EXPRESSIONS b/CC/foreign/EXPRESSIONS
new file mode 100644
index 0000000..2988b32
--- /dev/null
+++ b/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/CC/foreign/RULES b/CC/foreign/RULES
new file mode 100644
index 0000000..e6463f8
--- /dev/null
+++ b/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/CC/foreign/TARGETS b/CC/foreign/TARGETS
new file mode 100644
index 0000000..5fbb6a9
--- /dev/null
+++ b/CC/foreign/TARGETS
@@ -0,0 +1,7 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make"]
+ , "CMAKE": ["cmake"]
+ , "PATH": ["/bin", "/usr/bin"]
+ }
+}
diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS
new file mode 100644
index 0000000..a36725b
--- /dev/null
+++ b/CC/foreign/cmake/EXPRESSIONS
@@ -0,0 +1,480 @@
+{ "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"
+ , "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 scratch"
+ , "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}
+ }
+ }
+ }
+}
diff --git a/CC/foreign/cmake/RULES b/CC/foreign/cmake/RULES
new file mode 100644
index 0000000..b7fd406
--- /dev/null
+++ b/CC/foreign/cmake/RULES
@@ -0,0 +1,764 @@
+{ "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"
+ ]
+ , "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."
+ ]
+ }
+ , "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"
+ ]
+ , "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."
+ ]
+ }
+ , "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/CC/foreign/expand_exec b/CC/foreign/expand_exec
new file mode 100755
index 0000000..32891ca
--- /dev/null
+++ b/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/CC/foreign/expand_exec.c b/CC/foreign/expand_exec.c
new file mode 100644
index 0000000..a4ff311
--- /dev/null
+++ b/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/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS
new file mode 100644
index 0000000..68aa728
--- /dev/null
+++ b/CC/foreign/make/EXPRESSIONS
@@ -0,0 +1,443 @@
+{ "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 scratch"
+ , "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}
+ }
+ }
+ }
+}
diff --git a/CC/foreign/make/RULES b/CC/foreign/make/RULES
new file mode 100644
index 0000000..cf67998
--- /dev/null
+++ b/CC/foreign/make/RULES
@@ -0,0 +1,795 @@
+{ "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"
+ ]
+ , "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."
+ ]
+ }
+ , "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"
+ ]
+ , "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."
+ ]
+ }
+ , "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/CC/foreign/shell/EXPRESSIONS b/CC/foreign/shell/EXPRESSIONS
new file mode 100644
index 0000000..a37d315
--- /dev/null
+++ b/CC/foreign/shell/EXPRESSIONS
@@ -0,0 +1,360 @@
+{ "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"
+ , "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}
+ }
+ ]
+ ]
+ , "body": {"type": "var", "name": "artifacts"}
+ }
+ }
+}
diff --git a/CC/foreign/shell/RULES b/CC/foreign/shell/RULES
new file mode 100644
index 0000000..ed96aa3
--- /dev/null
+++ b/CC/foreign/shell/RULES
@@ -0,0 +1,614 @@
+{ "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"
+ ]
+ , "implicit":
+ { "defaults": [["CC", "defaults"]]
+ , "foreign-defaults": [["CC/foreign", "defaults"]]
+ , "shell defaults": [["shell", "defaults"]]
+ }
+ , "field_doc":
+ { "project":
+ [ "The project directory. It should contain a single tree artifact."
+ , "It's 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."
+ ]
+ }
+ , "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"
+ ]
+ , "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. It should contain a single tree artifact."
+ , "It's 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."
+ ]
+ }
+ , "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"}
+ }
+ }
+}
diff --git a/CC/pkgconfig/EXPRESSIONS b/CC/pkgconfig/EXPRESSIONS
index d6bdf08..72d66fd 100644
--- a/CC/pkgconfig/EXPRESSIONS
+++ b/CC/pkgconfig/EXPRESSIONS
@@ -4,6 +4,7 @@
{ "default-ENV": ["./", "..", "default-ENV"]
, "default-PATH": ["./", "..", "default-PATH"]
, "stage": ["", "stage_singleton_field"]
+ , "list_provider": ["", "field_list_provider"]
, "map_provider": ["", "field_map_provider"]
, "sh": ["shell", "sh"]
, "sh-PATH": ["shell", "PATH"]
@@ -25,32 +26,86 @@
, "key": "PATH"
}
]
+ , [ "ENV_PKG_CONFIG_PATH"
+ , { "type": "lookup"
+ , "map": {"type": "var", "name": "ENV"}
+ , "key": "PKG_CONFIG_PATH"
+ }
+ ]
, [ "sh-PATH"
, { "type": "let*"
, "bindings": [["fieldname", "shell defaults"]]
, "body": {"type": "CALL_EXPRESSION", "name": "sh-PATH"}
}
]
+ , [ "pkgconfig PATH"
+ , { "type": "let*"
+ , "bindings":
+ [["fieldname", "pkgconfig defaults"], ["provider", "PATH"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ ]
+ , [ "PKG_CONFIG_PATH"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "pkgconfig defaults"]
+ , ["provider", "PKG_CONFIG_PATH"]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ ]
+ , [ "final PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "pkgconfig PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ , {"type": "var", "name": "sh-PATH"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ENV_PATH"}
+ , "then": [{"type": "var", "name": "ENV_PATH"}]
+ }
+ ]
+ }
+ }
+ ]
+ , [ "final PKG_CONFIG_PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PKG_CONFIG_PATH"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ENV_PKG_CONFIG_PATH"}
+ , "then": [{"type": "var", "name": "ENV_PKG_CONFIG_PATH"}]
+ }
+ ]
+ }
+ }
+ ]
, [ "ENV"
, { "type": "map_union"
, "$1":
[ {"type": "var", "name": "ENV"}
- , { "type": "singleton_map"
- , "key": "PATH"
- , "value":
- { "type": "join"
- , "separator": ":"
- , "$1":
- { "type": "++"
- , "$1":
- [ {"type": "CALL_EXPRESSION", "name": "default-PATH"}
- , {"type": "var", "name": "sh-PATH"}
- , { "type": "if"
- , "cond": {"type": "var", "name": "ENV_PATH"}
- , "then": [{"type": "var", "name": "ENV_PATH"}]
- }
- ]
- }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "final PATH"}
+ , "else": {"type": "empty_map"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": {"type": "var", "name": "final PATH"}
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "final PKG_CONFIG_PATH"}
+ , "else": {"type": "empty_map"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PKG_CONFIG_PATH"
+ , "value": {"type": "var", "name": "final PKG_CONFIG_PATH"}
}
}
]
@@ -77,6 +132,23 @@
, "body": {"type": "CALL_EXPRESSION", "name": "sh"}
}
]
+ , [ "pkg-config"
+ , { "type": "join"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [["fieldname", "pkgconfig defaults"], ["provider", "pkg-config"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+ ]
+ , [ "pkg-config"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "pkg-config"}
+ , "then": {"type": "var", "name": "pkg-config"}
+ , "else": "pkg-config"
+ }
+ ]
, [ "cflags-filename"
, {"type": "join", "$1": [{"type": "var", "name": "name"}, ".cflags"]}
]
@@ -94,7 +166,7 @@
, "$1":
{ "type": "++"
, "$1":
- [ ["pkg-config"]
+ [ [{"type": "var", "name": "pkg-config"}]
, [ { "type": "join_cmd"
, "$1":
{ "type": "++"
@@ -141,7 +213,7 @@
, "$1":
{ "type": "++"
, "$1":
- [ ["pkg-config"]
+ [ [{"type": "var", "name": "pkg-config"}]
, [ { "type": "join_cmd"
, "$1":
{ "type": "++"
diff --git a/CC/pkgconfig/RULES b/CC/pkgconfig/RULES
index f51d949..f72fdf6 100644
--- a/CC/pkgconfig/RULES
+++ b/CC/pkgconfig/RULES
@@ -1,10 +1,74 @@
-{ "system_library":
+{ "defaults":
+ { "doc": ["A rule to provide defaults for pkgconfig"]
+ , "string_fields": ["pkg-config", "PATH", "PKG_CONFIG_PATH"]
+ , "target_fields": ["base"]
+ , "field_doc":
+ { "pkg-config":
+ ["The name of the pkg-config binary to use, potentially with full path."]
+ , "PATH": ["Additional paths to add to \"PATH\" when calling pkg-config"]
+ , "PKG_CONFIG_PATH":
+ [ "Additional paths to add to \"PKG_CONFIG_PATH\" when calling pkg-config"
+ ]
+ , "base": ["Other targets (using the same rule) to inherit from."]
+ }
+ , "imports":
+ { "base-provides": ["./", "..", "defaults-base-provides"]
+ , "base-provides-++": ["./", "..", "defaults-base-provides-++"]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["pkg-config", {"type": "FIELD", "name": "pkg-config"}]
+ , ["provider", "pkg-config"]
+ , [ "pkg-config"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "pkg-config"}
+ , "then": {"type": "var", "name": "pkg-config"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["PATH", {"type": "FIELD", "name": "PATH"}]
+ , ["provider", "PATH"]
+ , [ "PATH"
+ , { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
+ ]
+ }
+ }
+ ]
+ , ["PKG_CONFIG_PATH", {"type": "FIELD", "name": "PKG_CONFIG_PATH"}]
+ , ["provider", "PKG_CONFIG_PATH"]
+ , [ "PKG_CONFIG_PATH"
+ , { "type": "nub_left"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PKG_CONFIG_PATH"}
+ , {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
+ ]
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "provides":
+ {"type": "env", "vars": ["pkg-config", "PATH", "PKG_CONFIG_PATH"]}
+ }
+ }
+ }
+, "system_library":
{ "doc": ["A system library via pkg-config"]
, "string_fields": ["name", "args", "stage"]
, "implicit":
{ "defaults": [["./", "..", "defaults"]]
, "shell defaults": [["shell", "defaults"]]
, "add_rpath": ["add_rpath"]
+ , "pkgconfig defaults": ["defaults"]
}
, "config_vars": ["PKG_CONFIG_ARGS", "ENV"]
, "field_doc":
@@ -15,6 +79,7 @@
]
, "stage": ["The stage of the internally created flag files."]
, "defaults": ["The C/C++ toolchain to use"]
+ , "pkgconfig defaults": ["The pkgconfig configuration to use"]
}
, "config_doc":
{ "PKG_CONFIG_ARGS":
@@ -23,7 +88,9 @@
]
, "ENV":
[ "The environment for any action generated. May contain colon-separated"
- , "\"PKG_CONFIG_PATH\" for looking up pkg-config files."
+ , "\"PKG_CONFIG_PATH\" for looking up pkg-config files; this variable,"
+ , "as well as \"PATH\", is prefixed by the values provided in"
+ , "the \"defaults\"."
]
}
, "imports": {"pkgconfig result": "pkgconfig result"}
diff --git a/CC/pkgconfig/TARGETS b/CC/pkgconfig/TARGETS
index 0967ef4..705d1d7 100644
--- a/CC/pkgconfig/TARGETS
+++ b/CC/pkgconfig/TARGETS
@@ -1 +1 @@
-{}
+{"defaults": {"type": "defaults"}}
diff --git a/CC/prebuilt/EXPRESSIONS b/CC/prebuilt/EXPRESSIONS
new file mode 100644
index 0000000..b84e494
--- /dev/null
+++ b/CC/prebuilt/EXPRESSIONS
@@ -0,0 +1,503 @@
+{ "check-file-ending":
+ { "doc": ["Returns true if all file names end with the given ending."]
+ , "vars": ["files", "ending", "invert"]
+ , "vars_doc":
+ { "files": ["Artifact map that contains the files."]
+ , "ending": ["The ending to check for (without \".\")."]
+ , "invert": ["Invert condition to file name not ending with \"ending\"."]
+ }
+ , "expression":
+ { "type": "and"
+ , "$1":
+ { "type": "foreach"
+ , "var": "file"
+ , "range": {"type": "keys", "$1": {"type": "var", "name": "files"}}
+ , "body":
+ { "type": "let*"
+ , "bindings":
+ [ [ "is-equal"
+ , { "type": "=="
+ , "$1": {"type": "var", "name": "file"}
+ , "$2":
+ { "type": "change_ending"
+ , "$1": {"type": "var", "name": "file"}
+ , "ending":
+ { "type": "join"
+ , "$1": [".", {"type": "var", "name": "ending"}]
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "invert", "default": false}
+ , "then":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "is-equal"}
+ , "then": false
+ , "else": true
+ }
+ , "else": {"type": "var", "name": "is-equal"}
+ }
+ }
+ }
+ }
+ }
+, "check-libs-non-static":
+ { "doc":
+ [ "Returns true if all libs are non-static libraries or false otherwise."
+ , "Throws if static and non-static libraries are mixed."
+ ]
+ , "vars": ["libs"]
+ , "vars_doc": {"libs": ["List of artifact maps that contain the libraries."]}
+ , "imports": {"check-file-ending": "check-file-ending"}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["files", {"type": "map_union", "$1": {"type": "var", "name": "libs"}}]
+ , [ "static"
+ , { "type": "let*"
+ , "bindings": [["ending", "a"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "check-file-ending"}
+ }
+ ]
+ , [ "shared"
+ , { "type": "let*"
+ , "bindings": [["ending", "a"], ["invert", true]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "check-file-ending"}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "if"
+ , "cond":
+ { "type": "or"
+ , "$1":
+ [ {"type": "var", "name": "static"}
+ , {"type": "var", "name": "shared"}
+ ]
+ }
+ , "then": {"type": "var", "name": "shared"}
+ , "else":
+ { "type": "fail"
+ , "msg": "Prebuilt library types (static/shared) may not be mixed."
+ }
+ }
+ }
+ }
+, "prebuilt result":
+ { "vars":
+ [ "ENV"
+ , "name"
+ , "version"
+ , "stage"
+ , "cflags"
+ , "ldflags"
+ , "libs"
+ , "hdrs"
+ , "config_reader"
+ , "pkg-configs"
+ , "deps-fieldnames"
+ ]
+ , "imports":
+ { "check-libs-non-static": "check-libs-non-static"
+ , "compile-deps": ["./", "..", "compile-deps"]
+ , "compile-args-deps": ["./", "..", "compile-args-deps"]
+ , "link-deps": ["./", "..", "link-deps"]
+ , "link-args-deps": ["./", "..", "link-args-deps"]
+ , "run-libs-deps": ["./", "..", "run-libs-deps"]
+ , "run-libs-args-deps": ["./", "..", "run-libs-args-deps"]
+ , "cflags-files-deps": ["./", "..", "cflags-files-deps"]
+ , "ldflags-files-deps": ["./", "..", "ldflags-files-deps"]
+ , "default-ENV": ["./", "..", "default-ENV"]
+ , "default-PATH": ["./", "..", "default-PATH"]
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "shared"
+ , {"type": "CALL_EXPRESSION", "name": "check-libs-non-static"}
+ ]
+ , [ "lib-stage"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "shared"}
+ , "then": "."
+ , "else": {"type": "var", "name": "stage"}
+ }
+ ]
+ , [ "staged-libs"
+ , { "type": "foreach"
+ , "var": "lib"
+ , "range": {"type": "var", "name": "libs"}
+ , "body":
+ { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "lib-stage"}
+ , "flat": true
+ , "msg": "prebuilt libraries may not overlap"
+ , "$1": {"type": "var", "name": "lib"}
+ }
+ }
+ ]
+ , [ "link-args"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "shared"}
+ , "then": []
+ , "else":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "libs"
+ , "range": {"type": "var", "name": "staged-libs"}
+ , "body": {"type": "keys", "$1": {"type": "var", "name": "libs"}}
+ }
+ }
+ }
+ ]
+ , [ "run-libs-args"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "shared"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "libs"
+ , "range": {"type": "var", "name": "staged-libs"}
+ , "body": {"type": "keys", "$1": {"type": "var", "name": "libs"}}
+ }
+ }
+ }
+ ]
+ , [ "libs"
+ , { "type": "disjoint_map_union"
+ , "msg": "prebuilt libraries may not overlap"
+ , "$1": {"type": "var", "name": "staged-libs"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "stage"}
+ , "$1":
+ { "type": "disjoint_map_union"
+ , "msg": "prebuilt headers may not overlap"
+ , "$1": {"type": "var", "name": "hdrs"}
+ }
+ }
+ ]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "cflags"}
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ }
+ }
+ ]
+ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
+ , [ "link-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "link-args"}
+ , {"type": "CALL_EXPRESSION", "name": "link-args-deps"}
+ ]
+ }
+ }
+ ]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , { "type": "nub_right"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "run-libs-args"}
+ , {"type": "var", "name": "ldflags"}
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
+ }
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ ]
+ }
+ ]
+ , [ "ENV_PATH"
+ , { "type": "lookup"
+ , "map": {"type": "var", "name": "ENV"}
+ , "key": "PATH"
+ }
+ ]
+ , [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "ENV"}
+ , { "type": "singleton_map"
+ , "key": "PATH"
+ , "value":
+ { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ENV_PATH"}
+ , "then": [{"type": "var", "name": "ENV_PATH"}]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ , [ "main-pkg-config"
+ , { "type": "foldl"
+ , "range":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "configs"
+ , "range": {"type": "var", "name": "pkg-configs", "default": []}
+ , "body":
+ {"type": "keys", "$1": {"type": "var", "name": "configs"}}
+ }
+ }
+ , "start": null
+ , "accum_var": "name"
+ , "var": "config"
+ , "body":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "name"}
+ , "then": {"type": "var", "name": "name"}
+ , "else": {"type": "var", "name": "config"}
+ }
+ }
+ ]
+ , [ "reader-inputs"
+ , { "type": "to_subdir"
+ , "subdir": "lib"
+ , "$1":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "libs"}
+ , {"type": "var", "name": "link-deps"}
+ , {"type": "var", "name": "run-libs"}
+ , { "type": "to_subdir"
+ , "subdir": "pkgconfig"
+ , "flat": true
+ , "$1":
+ { "type": "map_union"
+ , "$1": {"type": "var", "name": "pkg-configs", "default": []}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , [ "pc-args"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "shared"}
+ , "then": []
+ , "else": ["--static"]
+ }
+ ]
+ , [ "cflags-filename"
+ , {"type": "join", "$1": [{"type": "var", "name": "name"}, ".cflags"]}
+ ]
+ , [ "cflags-file"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "stage"}
+ , "$1":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "pkg-configs"}
+ , "then":
+ { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "config_reader"}
+ , {"type": "var", "name": "reader-inputs"}
+ ]
+ }
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [ "./config_reader"
+ , {"type": "var", "name": "cflags-filename"}
+ , {"type": "var", "name": "main-pkg-config"}
+ ]
+ , {"type": "var", "name": "pc-args"}
+ ]
+ }
+ , "env": {"type": "var", "name": "ENV"}
+ , "outs": [{"type": "var", "name": "cflags-filename"}]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ }
+ ]
+ , [ "cflags-files"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ , {"type": "var", "name": "cflags-file"}
+ ]
+ }
+ ]
+ , [ "compile-args"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "compile-args"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "cflags-file"}
+ , "then":
+ [ { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["@"]
+ , { "type": "keys"
+ , "$1": {"type": "var", "name": "cflags-file"}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ , [ "ldflags-filename"
+ , {"type": "join", "$1": [{"type": "var", "name": "name"}, ".ldflags"]}
+ ]
+ , [ "ldflags-file"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "stage"}
+ , "$1":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "pkg-configs"}
+ , "then":
+ { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "config_reader"}
+ , {"type": "var", "name": "reader-inputs"}
+ ]
+ }
+ , "cmd":
+ { "type": "++"
+ , "$1":
+ [ [ "./config_reader"
+ , {"type": "var", "name": "ldflags-filename"}
+ , {"type": "var", "name": "main-pkg-config"}
+ ]
+ , {"type": "var", "name": "pc-args"}
+ ]
+ }
+ , "env": {"type": "var", "name": "ENV"}
+ , "outs": [{"type": "var", "name": "ldflags-filename"}]
+ }
+ , "else": {"type": "empty_map"}
+ }
+ }
+ ]
+ , [ "ldflags-files"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ , {"type": "var", "name": "ldflags-file"}
+ ]
+ }
+ ]
+ , [ "run-libs"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "shared"}
+ , "then": {"type": "var", "name": "libs"}
+ , "else": {"type": "empty_map"}
+ }
+ , {"type": "var", "name": "run-libs"}
+ ]
+ }
+ ]
+ , [ "run-libs-args"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "run-libs-args"}
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "ldflags-file"}
+ , "then":
+ [ { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["@"]
+ , { "type": "keys"
+ , "$1": {"type": "var", "name": "ldflags-file"}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ , [ "package"
+ , { "type": "let*"
+ , "bindings":
+ [ ["name", {"type": "var", "name": "name"}]
+ , [ "version"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "version"}
+ , "then":
+ { "type": "join"
+ , "separator": "."
+ , "$1": {"type": "var", "name": "version"}
+ }
+ , "else": null
+ }
+ ]
+ ]
+ , "body":
+ { "type": "env"
+ , "vars": ["name", "version", "cflags-files", "ldflags-files"]
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts": {"type": "var", "name": "libs"}
+ , "runfiles": {"type": "var", "name": "hdrs"}
+ , "provides":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "env"
+ , "vars":
+ [ "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "run-libs"
+ , "run-libs-args"
+ , "package"
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+}
diff --git a/CC/prebuilt/RULES b/CC/prebuilt/RULES
new file mode 100644
index 0000000..16f9f26
--- /dev/null
+++ b/CC/prebuilt/RULES
@@ -0,0 +1,147 @@
+{ "library":
+ { "doc": ["A prebuilt C++ library"]
+ , "target_fields": ["lib", "hdrs", "deps", "pkg-config"]
+ , "string_fields":
+ ["name", "version", "stage", "defines", "cflags", "ldflags"]
+ , "implicit":
+ { "defaults": [["./", "..", "defaults"]]
+ , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]]
+ }
+ , "config_vars": ["ENV"]
+ , "field_doc":
+ { "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 \".\"."
+ ]
+ , "lib":
+ [ "The actual prebuilt library. If multiple libraries are specified"
+ , "(e.g., one depends on the other), the order matters. Library types"
+ , "cannot be mixed. All of them have to be either static or shared."
+ ]
+ , "hdrs": ["Any public header files of the library."]
+ , "deps": ["Any other libraries this library depends upon."]
+ , "stage":
+ [ "The logical location of all header and source files, as well as the"
+ , "resulting library file. Individual directory components are joined"
+ , "with \"/\"."
+ ]
+ , "defines":
+ [ "List of defines set for this target and its consumers."
+ , "Each list entry will be prepended by \"-D\"."
+ ]
+ , "cflags":
+ ["List of compile flags set for this target and its consumers."]
+ , "ldflags":
+ ["Additional linker flags (typically for linking system 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."
+ ]
+ }
+ , "artifacts_doc":
+ [ "The actual library (libname.a or libname.so). Only static libraries are"
+ , "staged in the specified directory."
+ ]
+ , "runfiles_doc": ["The public headers staged to the specified directory."]
+ , "provides_doc":
+ { "compile-deps":
+ [ "Map of artifacts specifying any additional files that, besides the"
+ , "runfiles have to be present in compile actions of targets depending on"
+ , "this library."
+ ]
+ , "link-deps":
+ [ "Map of artifacts specifying any additional files that, besides the artifacts,"
+ , "have to be present in a link actions of targets depending on this library"
+ ]
+ , "run-libs":
+ [ "Map of artifacts specifying all files, including the artifacts of this"
+ , "library if shared, that have to be present in link actions of targets"
+ , "depending on this library."
+ ]
+ , "link-args":
+ [ "List of strings that have to be added to the command line for linking"
+ , "actions in targets depending on this library."
+ ]
+ , "run-libs-args":
+ [ "List of strings that have to be added to the command line for linking"
+ , "runtime libraries in targets depending on this library."
+ ]
+ , "compile-args":
+ [ "List of strings that have to be added to the command line for compile"
+ , "actions in targets depending on this library."
+ ]
+ }
+ , "imports":
+ { "artifacts": ["./", "../..", "field_artifacts"]
+ , "artifacts_list": ["./", "../..", "field_artifacts_list"]
+ , "stage_field": ["", "stage_singleton_field"]
+ , "prebuilt result": "prebuilt result"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "name"
+ , { "type": "assert_non_empty"
+ , "msg": "name is required for prebuilt library"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
+ }
+ ]
+ , ["version", {"type": "FIELD", "name": "version"}]
+ , [ "stage"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ ]
+ , [ "cflags"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "FIELD", "name": "cflags"}
+ , { "type": "foreach"
+ , "var": "def"
+ , "range": {"type": "FIELD", "name": "defines"}
+ , "body":
+ {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]}
+ }
+ ]
+ }
+ ]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
+ , [ "libs"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "lib"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "hdrs"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ }
+ ]
+ , [ "config_reader"
+ , { "type": "let*"
+ , "bindings":
+ [["fieldname", "config_reader"], ["location", "config_reader"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"}
+ }
+ ]
+ , [ "pkg-configs"
+ , { "type": "let*"
+ , "bindings": [["fieldname", "pkg-config"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ }
+ ]
+ , ["deps-fieldnames", ["deps"]]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "prebuilt result"}
+ }
+ }
+}
diff --git a/CC/prebuilt/read_pkgconfig.py b/CC/prebuilt/read_pkgconfig.py
new file mode 100755
index 0000000..115c305
--- /dev/null
+++ b/CC/prebuilt/read_pkgconfig.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+# 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.
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+from typing import Dict, List, Set
+
+
+def run_pkgconfig(args: List[str], env: Dict[str, str]) -> str:
+ result = subprocess.run(["pkg-config"] + args, env=env, capture_output=True)
+ if result.returncode != 0:
+ print(result.stderr.decode("utf-8"), file=sys.stderr)
+ exit(1)
+ return result.stdout.decode("utf-8").strip()
+
+
+def read_ldflags(pkg: str, args: List[str], env: Dict[str, str]) -> str:
+ def libname(filename: str) -> str:
+ return filename.split(".")[0]
+
+ local_libs = {
+ libname(f)
+ for it in os.walk(".") for f in it[2] if f.startswith("lib")
+ }
+
+ link_flags = run_pkgconfig(args + ["--libs-only-l", pkg], env).split(" ")
+
+ # deduplicate, keep right-most
+ seen: Set[str] = set()
+ link_flags = [
+ f for f in link_flags[::-1] if f not in seen and not seen.add(f)
+ ][::-1]
+
+ def is_local(flag: str) -> bool:
+ if not flag.startswith("-l"):
+ return False
+ lib = libname(flag[3:]) if flag.startswith("-l:") else f"lib{flag[2:]}"
+ return lib in local_libs
+
+ return " ".join([f for f in link_flags if not is_local(f)])
+
+
+def read_pkgconfig() -> None:
+ if len(sys.argv) < 3:
+ print(f"usage: read_pkgconfig OUT_NAME PC_FILE [PC_ARGS...]")
+ exit(1)
+
+ name = sys.argv[1]
+ pkg = Path(sys.argv[2]).stem
+ args = sys.argv[3:]
+ env = dict(os.environ, PKG_CONFIG_PATH="./lib/pkgconfig")
+
+ if name.endswith(".cflags"):
+ data = run_pkgconfig(args + ["--cflags-only-other", pkg], env)
+ else:
+ data = read_ldflags(pkg, args, env)
+
+ with open(f"{name}", 'w') as f:
+ f.write(data)
+
+
+if __name__ == "__main__":
+ read_pkgconfig()
diff --git a/CC/proto/RULES b/CC/proto/RULES
index 07b2dad..e7a2f46 100644
--- a/CC/proto/RULES
+++ b/CC/proto/RULES
@@ -87,6 +87,8 @@
, "compile-args-deps": ["CC", "compile-args-deps"]
, "link-deps": ["CC", "link-deps"]
, "link-args-deps": ["CC", "link-args-deps"]
+ , "run-libs-deps": ["CC", "run-libs-deps"]
+ , "run-libs-args-deps": ["CC", "run-libs-args-deps"]
, "cflags-files-deps": ["CC", "cflags-files-deps"]
, "ldflags-files-deps": ["CC", "ldflags-files-deps"]
, "for host": ["transitions", "for host"]
@@ -239,6 +241,10 @@
]
, ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
, ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, [ "cflags-files"
, {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
]
@@ -291,6 +297,8 @@
, "compile-args"
, "link-deps"
, "link-args"
+ , "run-libs"
+ , "run-libs-args"
, "package"
, "debug-srcs"
, "debug-hdrs"
@@ -322,8 +330,8 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
- , ["public-fieldnames", ["deps", "proto-defaults"]]
- , ["private-fieldnames", ["deps", "proto-defaults"]]
+ , ["public-fieldnames", ["deps", "proto-defaults", "defaults"]]
+ , ["private-fieldnames", ["deps", "proto-defaults", "defaults"]]
]
, "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"}
}
@@ -354,8 +362,8 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
- , ["public-fieldnames", ["deps", "proto-defaults"]]
- , ["private-fieldnames", ["deps", "proto-defaults"]]
+ , ["public-fieldnames", ["deps", "proto-defaults", "defaults"]]
+ , ["private-fieldnames", ["deps", "proto-defaults", "defaults"]]
]
, "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"}
}
diff --git a/CC/test/EXPRESSIONS b/CC/test/EXPRESSIONS
index 18028f8..1389bbc 100644
--- a/CC/test/EXPRESSIONS
+++ b/CC/test/EXPRESSIONS
@@ -48,12 +48,15 @@
, "compile-args-deps": ["./", "..", "compile-args-deps"]
, "link-deps": ["./", "..", "link-deps"]
, "link-args-deps": ["./", "..", "link-args-deps"]
+ , "run-libs-deps": ["./", "..", "run-libs-deps"]
+ , "run-libs-args-deps": ["./", "..", "run-libs-args-deps"]
, "cflags-files-deps": ["./", "..", "cflags-files-deps"]
, "ldflags-files-deps": ["./", "..", "ldflags-files-deps"]
, "binary": ["./", "..", "bin artifact"]
, "host transition": ["transitions", "for host"]
, "target properties": ["transitions", "target properties"]
, "stage": ["./", "../..", "stage_singleton_field"]
+ , "list_provider": ["./", "../..", "field_list_provider"]
, "lint": ["./", "..", "lint information"]
}
, "expression":
@@ -90,6 +93,10 @@
]
}
]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, ["binary", {"type": "CALL_EXPRESSION", "name": "binary"}]
, [ "lint"
, { "type": "if"
@@ -167,6 +174,7 @@
, {"type": "var", "name": "test-args"}
, {"type": "var", "name": "test-launcher"}
, {"type": "var", "name": "staged test binary"}
+ , {"type": "var", "name": "run-libs"}
]
}
]
@@ -314,6 +322,17 @@
}
}
]
+ , [ "summary PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [["fieldname", "shell-defaults"], ["provider", "PATH"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+ ]
, [ "summary"
, { "type": "ACTION"
, "inputs":
@@ -331,6 +350,16 @@
, "name": "TEST_SUMMARY_EXECUTION_PROPERTIES"
, "default": {"type": "empty_map"}
}
+ , "env":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "summary PATH"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": {"type": "var", "name": "summary PATH"}
+ }
+ , "else": {"type": "empty_map"}
+ }
}
]
, [ "attempts"
diff --git a/CC/test/RULES b/CC/test/RULES
index c0d54b5..3401974 100644
--- a/CC/test/RULES
+++ b/CC/test/RULES
@@ -19,9 +19,12 @@
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "TEST_ENV"
, "TIMEOUT_SCALE"
, "CC_TEST_LAUNCHER"
@@ -32,6 +35,7 @@
]
, "implicit":
{ "defaults": [["./", "..", "defaults"]]
+ , "shell-defaults": [["./", "../../shell", "defaults"]]
, "runner": ["runner"]
, "summarizer": [["./", "../../shell/test", "summarizer"]]
}
@@ -75,6 +79,8 @@
]
, "data": ["Any files the test binary needs access to when running"]
, "defaults": ["The C/C++ toolchain to use"]
+ , "shell-defaults":
+ ["The shell toolchain to use PATH from for calling the summary action"]
, "runner":
[ "The test runner which starts the actual test binary after providing"
, "the respective environment. The runner also takes care of capturing"
@@ -97,6 +103,10 @@
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "LDFLAGS":
+ [ "The linker flags do be used instead of the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "ADD_CFLAGS":
[ "The flags to add to the default ones for CC"
, "taken from the [\"CC\", \"defaults\"] target"
@@ -105,7 +115,12 @@
[ "The flags to add to the default ones for CXX"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "ENV": ["The environment for any action generated."]
+ , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."]
, "TEST_ENV": ["The environment for executing the test runner."]
, "TIMEOUT_SCALE":
["Factor on how to scale the timeout for this test. Defaults to 1.0."]
diff --git a/data/EXPRESSIONS b/data/EXPRESSIONS
new file mode 100644
index 0000000..929eaf8
--- /dev/null
+++ b/data/EXPRESSIONS
@@ -0,0 +1,113 @@
+{ "field_artifacts_without":
+ { "doc":
+ [ "Query and merge artifacts from target_field's targets,"
+ , "leaving out the specified logical paths."
+ ]
+ , "vars": ["fieldname", "transition", "exclude"]
+ , "vars_doc":
+ { "fieldname": ["The name of the target_field to query."]
+ , "transition": ["The optional configuration transition for the targets."]
+ , "exclude": ["The logical paths to exclude"]
+ }
+ , "expression":
+ { "type": "disjoint_map_union"
+ , "msg":
+ [ "artifacts"
+ , {"type": "var", "name": "fieldname"}
+ , "must not overlap after dropping paths"
+ , {"type": "var", "name": "exclude"}
+ ]
+ , "$1":
+ { "type": "foreach"
+ , "var": "x"
+ , "range":
+ {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
+ , "body":
+ { "type": "map_union"
+ , "$1":
+ { "type": "foreach_map"
+ , "range":
+ { "type": "DEP_ARTIFACTS"
+ , "dep": {"type": "var", "name": "x"}
+ , "transition":
+ { "type": "var"
+ , "name": "transition"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "body":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": {"type": "var", "name": "_"}
+ , "map": {"type": "var", "name": "exclude"}
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "_"}
+ , "value": {"type": "var", "name": "$_"}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+, "field_runfiles_without":
+ { "doc":
+ [ "Query and merge runfiles from target_field's targets,"
+ , "leaving out the specified logical paths."
+ ]
+ , "vars": ["fieldname", "transition", "exclude"]
+ , "vars_doc":
+ { "fieldname": ["The name of the target_field to query."]
+ , "transition": ["The optional configuration transition for the targets."]
+ , "exclude": ["The logical paths to exclude"]
+ }
+ , "expression":
+ { "type": "disjoint_map_union"
+ , "msg":
+ [ "artifacts"
+ , {"type": "var", "name": "fieldname"}
+ , "must not overlap after dropping paths"
+ , {"type": "var", "name": "exclude"}
+ ]
+ , "$1":
+ { "type": "foreach"
+ , "var": "x"
+ , "range":
+ {"type": "FIELD", "name": {"type": "var", "name": "fieldname"}}
+ , "body":
+ { "type": "map_union"
+ , "$1":
+ { "type": "foreach_map"
+ , "range":
+ { "type": "DEP_RUNFILES"
+ , "dep": {"type": "var", "name": "x"}
+ , "transition":
+ { "type": "var"
+ , "name": "transition"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "body":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": {"type": "var", "name": "_"}
+ , "map": {"type": "var", "name": "exclude"}
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "_"}
+ , "value": {"type": "var", "name": "$_"}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/data/RULES b/data/RULES
index feb1a73..ab5c92e 100644
--- a/data/RULES
+++ b/data/RULES
@@ -1,7 +1,7 @@
{ "staged":
{ "doc": ["Stage data to a logical subdirectory."]
, "target_fields": ["srcs", "deps"]
- , "string_fields": ["stage"]
+ , "string_fields": ["stage", "drop"]
, "field_doc":
{ "srcs": ["The files to be staged"]
, "stage":
@@ -12,9 +12,15 @@
[ "Targets of with their runfiles should be added as well."
, "Their staging is not changed."
]
+ , "drop":
+ [ "List of paths to drop from (each of) the \"srcs\" targets"
+ , "before joining and staging. In this way, GLOB constructs can"
+ , "be used is \"srcs\"."
+ ]
}
, "artifacts_doc":
- [ "The runfiles of the \"srcs\" targets staged to the directory"
+ [ "The runfiles and artifacts of the \"srcs\" targets, leaving out"
+ , "the ones with logical path in \"drop\", staged to the directory"
, "specified in \"stage\" together the runfiles of the targets"
, "specied in the field \"deps\" (in their original location)."
]
@@ -22,6 +28,8 @@
, "imports":
{ "runfiles": ["./", "..", "field_runfiles"]
, "artifacts": ["./", "..", "field_artifacts"]
+ , "runfiles w/o": "field_runfiles_without"
+ , "artifacts w/o": "field_artifacts_without"
}
, "expression":
{ "type": "let*"
@@ -32,15 +40,36 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
+ , [ "exclude"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "drop"}
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "_"}
+ , "value": true
+ }
+ }
+ }
+ ]
, [ "srcs"
, { "type": "let*"
, "bindings": [["fieldname", "srcs"]]
, "body":
{ "type": "map_union"
, "$1":
- [ {"type": "CALL_EXPRESSION", "name": "runfiles"}
- , {"type": "CALL_EXPRESSION", "name": "artifacts"}
- ]
+ { "type": "if"
+ , "cond": {"type": "var", "name": "exclude"}
+ , "then":
+ [ {"type": "CALL_EXPRESSION", "name": "runfiles w/o"}
+ , {"type": "CALL_EXPRESSION", "name": "artifacts w/o"}
+ ]
+ , "else":
+ [ {"type": "CALL_EXPRESSION", "name": "runfiles"}
+ , {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ ]
+ }
}
}
]
diff --git a/shell/EXPRESSIONS b/shell/EXPRESSIONS
index 722e897..34a5c92 100644
--- a/shell/EXPRESSIONS
+++ b/shell/EXPRESSIONS
@@ -99,4 +99,73 @@
, "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
}
}
+, "prolog":
+ { "vars": ["fieldname", "TOOLCHAIN_DIR"]
+ , "imports": {"list_provider": ["./", "..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["provider", "bin dirs"]
+ , ["bin dirs", {"type": "CALL_EXPRESSION", "name": "list_provider"}]
+ , [ "relative paths"
+ , { "type": "foreach"
+ , "range": {"type": "var", "name": "bin dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ "."
+ , { "type": "var"
+ , "name": "TOOLCHAIN_DIR"
+ , "default": "toolchain"
+ }
+ , {"type": "var", "name": "_"}
+ ]
+ }
+ }
+ ]
+ , [ "pwd paths"
+ , { "type": "foreach"
+ , "range": {"type": "var", "name": "bin dirs"}
+ , "body":
+ { "type": "join"
+ , "separator": "/"
+ , "$1":
+ [ "$(pwd)"
+ , { "type": "var"
+ , "name": "TOOLCHAIN_DIR"
+ , "default": "toolchain"
+ }
+ , {"type": "var", "name": "_"}
+ ]
+ }
+ }
+ ]
+ ]
+ , "body":
+ [ "__PATH=$PATH"
+ , { "type": "join"
+ , "$1":
+ [ "export PATH="
+ , { "type": "join"
+ , "separator": ":"
+ , "$1": {"type": "var", "name": "relative paths"}
+ }
+ , "${PATH:+:}${PATH}"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "export PATH="
+ , { "type": "join"
+ , "separator": ":"
+ , "$1": {"type": "var", "name": "pwd paths"}
+ }
+ , "${__PATH:+:}${__PATH}"
+ ]
+ }
+ , "unset __PATH"
+ ]
+ }
+ }
}
diff --git a/shell/RULES b/shell/RULES
index b9e91bb..7f53a4b 100644
--- a/shell/RULES
+++ b/shell/RULES
@@ -155,4 +155,193 @@
}
}
}
+, "cmds":
+ { "doc":
+ [ "Execute comands using the shell"
+ , ""
+ , "This rule behaves similar to the built-in \"generic\" rule, however"
+ , "with the difference that the shell toolchain is honored."
+ ]
+ , "target_fields": ["deps"]
+ , "string_fields": ["cmds", "outs", "out_dirs"]
+ , "implicit": {"defaults": ["defaults"]}
+ , "field_doc":
+ { "deps":
+ [ "Any inputs to the argument."
+ , "Both, artifacts and rufiles of the dependecies are staged into"
+ , "the (effective) working directory of the action. Conflicts are"
+ , "resolved by giving artifacts priority to runfiles, and within"
+ , "each of those priority to ones brought by the latest dependency."
+ ]
+ , "cmds":
+ [ "The command to be executed."
+ , "Individual entries are joined by newline characters; the whole"
+ , "script is then prefixed by commands necessary to set up the"
+ , "work environment using the shell tool chain."
+ ]
+ , "defaults": ["The shell toolchain to use."]
+ , "outs": ["The expected file outputs"]
+ , "out_dirs": ["The expected output directories"]
+ }
+ , "imports":
+ { "artifacts_list": ["", "field_artifacts_list"]
+ , "runfiles_list": ["", "field_runfiles_list"]
+ , "map_provider": ["", "field_map_provider"]
+ , "prolog": "prolog"
+ , "sh": "sh"
+ , "PATH": "PATH"
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "deps"]
+ , [ "deps"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
+ , {"type": "CALL_EXPRESSION", "name": "artifacts_list"}
+ ]
+ }
+ }
+ ]
+ , ["fieldname", "defaults"]
+ , ["TOOLCHAIN_DIR", "toolchain"]
+ , [ "toolchain"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [["provider", "TOOLCHAIN"], ["default", {"type": "empty_map"}]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+ ]
+ , ["WRKDIR", "work"]
+ , [ "cmds"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "prolog"}
+ , [ { "type": "join_cmd"
+ , "$1": ["cd", {"type": "var", "name": "WRKDIR"}]
+ }
+ ]
+ , {"type": "FIELD", "name": "cmds"}
+ ]
+ }
+ ]
+ , ["sh", {"type": "CALL_EXPRESSION", "name": "sh"}]
+ , [ "cmdfile"
+ , { "type": "singleton_map"
+ , "key": "cmd"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1": {"type": "var", "name": "cmds"}
+ }
+ }
+ }
+ ]
+ , ["PATH", {"type": "CALL_EXPRESSION", "name": "PATH"}]
+ , [ "env"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "PATH"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value":
+ { "type": "join"
+ , "separator": ":"
+ , "$1": {"type": "var", "name": "PATH"}
+ }
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ , [ "outs in WRKDIR"
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "outs"}
+ , "body":
+ { "type": "join"
+ , "$1":
+ [ {"type": "var", "name": "WRKDIR"}
+ , "/"
+ , {"type": "var", "name": "_"}
+ ]
+ }
+ }
+ ]
+ , [ "out_dirs in WRKDIR"
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "out_dirs"}
+ , "body":
+ { "type": "join"
+ , "$1":
+ [ {"type": "var", "name": "WRKDIR"}
+ , "/"
+ , {"type": "var", "name": "_"}
+ ]
+ }
+ }
+ ]
+ , [ "artifacts"
+ , { "type": "ACTION"
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "toolchain"}
+ , {"type": "var", "name": "cmdfile"}
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "WRKDIR"}
+ , "$1": {"type": "var", "name": "deps"}
+ }
+ ]
+ }
+ , "cmd": [{"type": "var", "name": "sh"}, "cmd"]
+ , "outs": {"type": "var", "name": "outs in WRKDIR"}
+ , "out_dirs": {"type": "var", "name": "out_dirs in WRKDIR"}
+ , "env": {"type": "var", "name": "env"}
+ }
+ ]
+ , [ "staged artifacts"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "foreach"
+ , "range":
+ { "type": "++"
+ , "$1":
+ [ {"type": "FIELD", "name": "outs"}
+ , {"type": "FIELD", "name": "out_dirs"}
+ ]
+ }
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "_"}
+ , "value":
+ { "type": "lookup"
+ , "map": {"type": "var", "name": "artifacts"}
+ , "key":
+ { "type": "join"
+ , "$1":
+ [ {"type": "var", "name": "WRKDIR"}
+ , "/"
+ , {"type": "var", "name": "_"}
+ ]
+ }
+ }
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "artifacts": {"type": "var", "name": "staged artifacts"}
+ }
+ }
+ }
}
diff --git a/shell/test/EXPRESSIONS b/shell/test/EXPRESSIONS
index c4e0a3c..9791911 100644
--- a/shell/test/EXPRESSIONS
+++ b/shell/test/EXPRESSIONS
@@ -15,11 +15,13 @@
, "imports":
{ "artifacts_list": ["./", "../..", "field_artifacts_list"]
, "runfiles_list": ["./", "../..", "field_runfiles_list"]
+ , "map_provider": ["./", "../..", "field_map_provider"]
, "default-TOOLCHAIN": ["./", "../../CC", "default-TOOLCHAIN"]
, "default-NON_SYSTEM_TOOLS":
["./", "../../CC", "default-NON_SYSTEM_TOOLS"]
, "default-PATH": ["./", "../../CC", "default-PATH"]
, "default-sh": ["./", "..", "default-sh"]
+ , "sh prolog": ["shell", "prolog"]
}
, "expression":
{ "type": "let*"
@@ -59,6 +61,20 @@
, [ "NON_SYSTEM_TOOLS"
, {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
]
+ , [ "sh from outside"
+ , { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "sh"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
+ , "then":
+ { "type": "join"
+ , "$1": ["./toolchain/", {"type": "var", "name": "sh"}]
+ }
+ , "else": {"type": "var", "name": "sh"}
+ }
+ ]
, [ "sh from workdir"
, { "type": "if"
, "cond":
@@ -73,6 +89,36 @@
, "else": {"type": "var", "name": "sh"}
}
]
+ , [ "with-env"
+ , { "type": "singleton_map"
+ , "key": "with-env"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "let*"
+ , "bindings": [["fieldname", "defaults"]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "sh prolog"}
+ }
+ , [ ""
+ , { "type": "join_cmd"
+ , "$1":
+ { "type": "++"
+ , "$1": [["./runner"], {"type": "var", "name": "keep"}]
+ }
+ }
+ , ""
+ ]
+ ]
+ }
+ }
+ }
+ }
+ ]
, [ "invocation cmd"
, [{"type": "var", "name": "sh from workdir"}, "../test.sh"]
]
@@ -154,6 +200,19 @@
}
}
]
+ , [ "run-libs"
+ , { "type": "TREE"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", {"type": "var", "name": "deps-fieldname"}]
+ , ["provider", "run-libs"]
+ , ["transition", {"type": "var", "name": "deps-transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+ ]
, [ "attempt marker"
, { "type": "if"
, "cond":
@@ -202,7 +261,12 @@
, "key": "work"
, "value": {"type": "var", "name": "deps"}
}
+ , { "type": "singleton_map"
+ , "key": "libs"
+ , "value": {"type": "var", "name": "run-libs"}
+ }
, {"type": "var", "name": "toolchain"}
+ , {"type": "var", "name": "with-env"}
, {"type": "var", "name": "runner"}
, {"type": "var", "name": "invocation"}
, {"type": "var", "name": "test.sh"}
@@ -210,8 +274,26 @@
]
}
]
- , [ "cmd"
- , {"type": "++", "$1": [["./runner"], {"type": "var", "name": "keep"}]}
+ , ["cmd", [{"type": "var", "name": "sh from outside"}, "with-env"]]
+ , [ "test_env"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1": {"type": "var", "name": "ATTEMPT"}
+ , "$2": null
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "singleton_map"
+ , "key": "TEST_RUN_NUMBER"
+ , "value": {"type": "var", "name": "ATTEMPT"}
+ }
+ }
+ , {"type": "var", "name": "test_env"}
+ ]
+ }
]
]
, "body":
diff --git a/shell/test/RULES b/shell/test/RULES
index 3d49db2..bab1d8b 100644
--- a/shell/test/RULES
+++ b/shell/test/RULES
@@ -50,6 +50,10 @@
, "outside the working directory and the TEST_TMPDIR."
, "For convenience, the environment variable TMPDIR is also set to TEST_TMPDIR."
, ""
+ , "If the configuration variable RUNS_PER_TEST is set, the environment"
+ , "variable TEST_RUN_NUMBER will also be set to the number of the attempt,"
+ , "counting from 0."
+ , ""
, "This running of the test is carried out by the implicit dependency"
, "on the target \"runner\". By setting this target in the target layer"
, "of this rues repository (instead of letting it default to the"
@@ -97,7 +101,7 @@
, "default to the respective file) the layout of the summary can be"
, "changed globally."
]
- , "TEST_ENV": ["The environment for executing the test runner."]
+ , "TEST_ENV": ["Additional environment for executing the test runner."]
, "TIMEOUT_SCALE":
["Factor on how to scale the timeout for this test. Defaults to 1.0."]
, "TARGET_ARCH":
@@ -146,6 +150,7 @@
, "stage": ["./", "../..", "stage_singleton_field"]
, "host transition": ["transitions", "maybe for host"]
, "target properties": ["transitions", "target properties"]
+ , "default-PATH": ["./", "../../CC", "default-PATH"]
, "field_list": ["", "field_list_provider"]
}
, "config_transitions":
@@ -276,6 +281,12 @@
}
}
]
+ , [ "summary PATH"
+ , { "type": "join"
+ , "separator": ":"
+ , "$1": {"type": "CALL_EXPRESSION", "name": "default-PATH"}
+ }
+ ]
, [ "summary"
, { "type": "ACTION"
, "inputs":
@@ -293,6 +304,16 @@
, "name": "TEST_SUMMARY_EXECUTION_PROPERTIES"
, "default": {"type": "empty_map"}
}
+ , "env":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "summary PATH"}
+ , "then":
+ { "type": "singleton_map"
+ , "key": "PATH"
+ , "value": {"type": "var", "name": "summary PATH"}
+ }
+ , "else": {"type": "empty_map"}
+ }
}
]
, [ "attempts"
diff --git a/shell/test/runner b/shell/test/runner
index 624610b..f2f5766 100755
--- a/shell/test/runner
+++ b/shell/test/runner
@@ -26,6 +26,7 @@ pwd > pwd
mkdir scratch
export TEST_TMPDIR=$(realpath scratch)
export TMPDIR="${TEST_TMPDIR}"
+export LD_LIBRARY_PATH=$(realpath ./libs):$LD_LIBRARY_PATH
# Change to the working directory; note: while unlikely, the test
# might not have test data, so we have to ensure the presence of
diff --git a/transitions/EXPRESSIONS b/transitions/EXPRESSIONS
index 596b20e..d1ecefa 100644
--- a/transitions/EXPRESSIONS
+++ b/transitions/EXPRESSIONS
@@ -19,6 +19,62 @@
, "body": {"type": "env", "vars": ["BUILD_ARCH", "TARGET_ARCH"]}
}
}
+, "with fPIC":
+ { "doc":
+ [ "Transition that enables BUILD_POSITION_INDEPENDENT if config_field"
+ , "\"shared\" is not empty."
+ ]
+ , "var": ["BUILD_OBJECT_ONLY"]
+ , "expression":
+ { "type": "if"
+ , "cond":
+ { "type": "and"
+ , "$1":
+ [ {"type": "FIELD", "name": "shared"}
+ , {"type": "not", "$1": {"type": "var", "name": "BUILD_OBJECT_ONLY"}}
+ ]
+ }
+ , "then":
+ { "type": "singleton_map"
+ , "key": "BUILD_POSITION_INDEPENDENT"
+ , "value": true
+ }
+ , "else": {"type": "empty_map"}
+ }
+ }
+, "with fPIC, not object-only":
+ { "doc": ["Like \"with fPIC\", but also clearing BUILD_OBJECT_ONLY"]
+ , "var": ["BUILD_OBJECT_ONLY"]
+ , "imports": {"with fPIC": "with fPIC"}
+ , "expression":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "with fPIC"}
+ , {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": null}
+ , { "type": "singleton_map"
+ , "key": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
+ , "value": null
+ }
+ ]
+ }
+ }
+, "with fPIC, object-only":
+ { "doc":
+ ["Like \"with fPIC\", but also unconditionally setting BUILD_OBJECT_ONLY"]
+ , "var": ["BUILD_OBJECT_ONLY"]
+ , "imports": {"with fPIC": "with fPIC"}
+ , "expression":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "with fPIC"}
+ , {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": true}
+ , { "type": "singleton_map"
+ , "key": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
+ , "value": true
+ }
+ ]
+ }
+ }
, "target properties":
{ "vars": ["ARCH", "TARGET_ARCH", "ARCH_DISPATCH"]
, "expression":