summaryrefslogtreecommitdiff
path: root/CC
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-06-10 10:12:34 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2024-06-10 10:20:36 +0200
commit153f2ef5035d82df02e2e748114279d54ac863ff (patch)
treeaafe9dea77d52a6092c3c5c281b90f0d1bd1d330 /CC
parent378ab0b30a90969e70d905a977bd53bb7828f052 (diff)
downloadrules-cc-153f2ef5035d82df02e2e748114279d54ac863ff.tar.gz
Add support for protobuf compiler flags
Diffstat (limited to 'CC')
-rw-r--r--CC/proto/EXPRESSIONS21
-rw-r--r--CC/proto/RULES35
2 files changed, 51 insertions, 5 deletions
diff --git a/CC/proto/EXPRESSIONS b/CC/proto/EXPRESSIONS
index 29c205c..2286d06 100644
--- a/CC/proto/EXPRESSIONS
+++ b/CC/proto/EXPRESSIONS
@@ -11,6 +11,19 @@
, "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
}
}
+, "default-PROTOCFLAGS":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "PROTOCFLAGS"]
+ , ["transition", {"type": "var", "name": "defaults-transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
, "default-LDFLAGS":
{ "vars": ["defaults-transition"]
, "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
@@ -128,6 +141,7 @@
, "artifacts_list": ["./", "../..", "field_artifacts_list"]
, "protoc-deps": "protoc-deps"
, "default-PROTOC": "default-PROTOC"
+ , "default-PROTOCFLAGS": "default-PROTOCFLAGS"
, "default-LDFLAGS": "default-LDFLAGS"
, "default-GRPC_PLUGIN": "default-GRPC_PLUGIN"
, "default-ENV": "default-ENV"
@@ -297,10 +311,9 @@
, [ "cmd"
, { "type": "++"
, "$1":
- [ [ {"type": "var", "name": "PROTOC"}
- , "--proto_path=work"
- , "--cpp_out=work"
- ]
+ [ [{"type": "var", "name": "PROTOC"}]
+ , {"type": "CALL_EXPRESSION", "name": "default-PROTOCFLAGS"}
+ , ["--proto_path=work", "--cpp_out=work"]
, { "type": "if"
, "cond": {"type": "var", "name": "service support"}
, "then":
diff --git a/CC/proto/RULES b/CC/proto/RULES
index 2fc0346..2e78799 100644
--- a/CC/proto/RULES
+++ b/CC/proto/RULES
@@ -7,7 +7,14 @@
]
, "target_fields": ["base", "toolchain", "deps"]
, "string_fields":
- ["PROTOC", "LDFLAGS", "ADD_LDFLAGS", "GRPC_PLUGIN", "PATH"]
+ [ "PROTOC"
+ , "PROTOCFLAGS"
+ , "ADD_PROTOCFLAGS"
+ , "LDFLAGS"
+ , "ADD_LDFLAGS"
+ , "GRPC_PLUGIN"
+ , "PATH"
+ ]
, "config_vars": ["ARCH", "HOST_ARCH"]
, "field_doc":
{ "base":
@@ -41,6 +48,14 @@
, "to be the relative path to the plugin in \"toolchain\". Specifying"
, "this field overwrites values from \"base\"."
]
+ , "PROTOCFLAGS":
+ [ "Protobuf compiler flags. Specifying this field overwrites values from"
+ , "\"base\"."
+ ]
+ , "ADD_PROTOCFLAGS":
+ [ "Additional protobuf compiler flags. Specifying this field extends"
+ , "values from \"base\"."
+ ]
, "LDFLAGS":
[ "Linker flags for linking the final CC library. Specifying this field"
, "overwrites values from \"base\"."
@@ -74,6 +89,7 @@
{ "type": "let*"
, "bindings":
[ ["PROTOC", {"type": "FIELD", "name": "PROTOC"}]
+ , ["PROTOCFLAGS", {"type": "FIELD", "name": "PROTOCFLAGS"}]
, ["LDFLAGS", {"type": "FIELD", "name": "LDFLAGS"}]
, ["GRPC_PLUGIN", {"type": "FIELD", "name": "GRPC_PLUGIN"}]
, ["PATH", {"type": "FIELD", "name": "PATH"}]
@@ -85,6 +101,14 @@
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
+ , ["provider", "PROTOCFLAGS"]
+ , [ "PROTOCFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "PROTOCFLAGS"}
+ , "then": {"type": "var", "name": "PROTOCFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
+ }
+ ]
, ["provider", "LDFLAGS"]
, [ "LDFLAGS"
, { "type": "if"
@@ -186,6 +210,14 @@
}
}
]
+ , [ "PROTOCFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PROTOCFLAGS"}
+ , {"type": "FIELD", "name": "ADD_PROTOCFLAGS"}
+ ]
+ }
+ ]
, [ "LDFLAGS"
, { "type": "++"
, "$1":
@@ -215,6 +247,7 @@
{ "type": "env"
, "vars":
[ "PROTOC"
+ , "PROTOCFLAGS"
, "LDFLAGS"
, "GRPC_PLUGIN"
, "PATH"