diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-30 17:03:14 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-30 19:01:12 +0200 |
commit | 4118e0b9930d11f6062751db4f1656e8cc2a680a (patch) | |
tree | a839d9d63048f38f596e4613fdf5d11bd22b4ca2 /CC/foreign/make | |
parent | a27d18f2265c74804842c1170396dbc273c9e1c9 (diff) | |
download | rules-cc-4118e0b9930d11f6062751db4f1656e8cc2a680a.tar.gz |
foreign: Implement 'expand_exec' via POSIX shell
... and coreutils by default. This has the advantage that no
C compiler and no specific toolchain definition is required
to build rule-internal tools. 'expand_exec' is provided via
an implicit target with proper config transition for host,
so it could be overwritten by the rule user. The C code of
the previous implementation is still kept as an example.
Diffstat (limited to 'CC/foreign/make')
-rw-r--r-- | CC/foreign/make/EXPRESSIONS | 15 | ||||
-rw-r--r-- | CC/foreign/make/RULES | 26 |
2 files changed, 24 insertions, 17 deletions
diff --git a/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS index aeafbfc..ceb5913 100644 --- a/CC/foreign/make/EXPRESSIONS +++ b/CC/foreign/make/EXPRESSIONS @@ -25,7 +25,7 @@ , "BUILD_POSITION_INDEPENDENT" , "TIMEOUT_SCALE" , "defaults-transition" - , "host-defaults-transition" + , "expand_exec" ] , "imports": { "artifacts": ["", "field_artifacts"] @@ -40,7 +40,6 @@ , "default-PATH": ["CC", "default-PATH"] , "default-TOOLCHAIN": ["CC", "default-TOOLCHAIN"] , "default-NON_SYSTEM_TOOLS": ["CC", "default-NON_SYSTEM_TOOLS"] - , "expand_exec_tool": ["./", "..", "expand_exec_tool"] , "foreign-MAKE": ["CC/foreign", "default-MAKE"] , "foreign-ENV": ["CC/foreign", "default-ENV"] , "foreign-PATH": ["CC/foreign", "default-PATH"] @@ -50,17 +49,7 @@ , "expression": { "type": "let*" , "bindings": - [ [ "expand_exec" - , { "type": "let*" - , "bindings": - [ [ "defaults-transition" - , {"type": "var", "name": "host-defaults-transition"} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "expand_exec_tool"} - } - ] - , ["TOOLCHAIN_DIR", "toolchain"] + [ ["TOOLCHAIN_DIR", "toolchain"] , [ "TOOLCHAIN" , { "type": "disjoint_map_union" , "msg": "Toolchain trees may not overlap" diff --git a/CC/foreign/make/RULES b/CC/foreign/make/RULES index 08e5414..76fca18 100644 --- a/CC/foreign/make/RULES +++ b/CC/foreign/make/RULES @@ -41,6 +41,7 @@ , "implicit": { "defaults": [["CC", "defaults"]] , "foreign-defaults": [["CC/foreign", "defaults"]] + , "expand_exec": [["./", "..", "expand_exec"]] } , "field_doc": { "project": @@ -172,6 +173,7 @@ , "config_transitions": { "defaults": [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}] + , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}] } , "expression": { "type": "let*" @@ -221,8 +223,15 @@ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] , ["defaults-transition", {"type": "empty_map"}] - , [ "host-defaults-transition" - , {"type": "CALL_EXPRESSION", "name": "for host"} + , [ "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"}] , [ "install_dir" @@ -323,6 +332,7 @@ { "defaults": [["CC", "defaults"]] , "foreign-defaults": [["CC/foreign", "defaults"]] , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]] + , "expand_exec": [["./", "..", "expand_exec"]] } , "field_doc": { "project": @@ -492,6 +502,7 @@ , "config_transitions": { "defaults": [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}] + , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}] } , "expression": { "type": "let*" @@ -630,8 +641,15 @@ , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] , ["defaults-transition", {"type": "empty_map"}] - , [ "host-defaults-transition" - , {"type": "CALL_EXPRESSION", "name": "for host"} + , [ "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"}] , [ "install_dir" |