summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-04-25 17:35:35 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-04-26 11:31:04 +0200
commit0d35d779351a30d8b2bb6c27bca94acf56d6143d (patch)
tree162e65f80a8fcfd459d25cb3596c94b3f380295d
parent0d0f1172087fc52edb64dad58a4a3a76f41e37c0 (diff)
downloadrules-cc-0d35d779351a30d8b2bb6c27bca94acf56d6143d.tar.gz
rules: Support mixing system/toolchain for protoc/grpc
-rw-r--r--CC/proto/EXPRESSIONS38
-rw-r--r--CC/proto/RULES41
2 files changed, 77 insertions, 2 deletions
diff --git a/CC/proto/EXPRESSIONS b/CC/proto/EXPRESSIONS
index 6f51496..894b80b 100644
--- a/CC/proto/EXPRESSIONS
+++ b/CC/proto/EXPRESSIONS
@@ -75,6 +75,28 @@
, "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": "proto-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"}
+ }
+ }
+ }
+ }
, "protoc-deps":
{ "imports": {"map_provider": ["./", "../..", "field_map_provider"]}
, "expression":
@@ -107,6 +129,7 @@
, "default-GRPC_PLUGIN": "default-GRPC_PLUGIN"
, "default-ENV": "default-ENV"
, "default-TOOLCHAIN": "default-TOOLCHAIN"
+ , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS"
}
, "expression":
{ "type": "let*"
@@ -125,13 +148,20 @@
, "else": {"type": "empty_map"}
}
]
+ , [ "NON_SYSTEM_TOOLS"
+ , {"type": "CALL_EXPRESSION", "name": "default-NON_SYSTEM_TOOLS"}
+ ]
, [ "PROTOC"
, { "type": "join"
, "$1":
{ "type": "++"
, "$1":
[ { "type": "if"
- , "cond": {"type": "var", "name": "TOOLCHAIN"}
+ , "cond":
+ { "type": "lookup"
+ , "key": "PROTOC"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
, "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
}
, {"type": "CALL_EXPRESSION", "name": "default-PROTOC"}
@@ -145,7 +175,11 @@
{ "type": "++"
, "$1":
[ { "type": "if"
- , "cond": {"type": "var", "name": "TOOLCHAIN"}
+ , "cond":
+ { "type": "lookup"
+ , "key": "GRPC_PLUGIN"
+ , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"}
+ }
, "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
}
, {"type": "CALL_EXPRESSION", "name": "default-GRPC_PLUGIN"}
diff --git a/CC/proto/RULES b/CC/proto/RULES
index c6568cd..6d2e725 100644
--- a/CC/proto/RULES
+++ b/CC/proto/RULES
@@ -115,6 +115,46 @@
, "else": {"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"}]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "PROTOC"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "PROTOC"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "GRPC_PLUGIN"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "GRPC_PLUGIN"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
, ["provider", "TOOLCHAIN"]
, ["default", {"type": "empty_map"}]
, [ "TOOLCHAIN"
@@ -171,6 +211,7 @@
, "GRPC_PLUGIN"
, "ENV"
, "TOOLCHAIN"
+ , "NON_SYSTEM_TOOLS"
, "compile-deps"
, "compile-args"
, "link-deps"