summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-04-18 15:37:59 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-04-18 15:37:59 +0200
commit6591e8aa71be7950725c0fb10341a73ab3da4c52 (patch)
tree09db85f77d8d21eda22cad222ebdff9108698a88
parent13c0918cf74186561b89a0c4f59489069ff58d27 (diff)
parent48f4317f428719a55c70ac7a8a58df834418cd17 (diff)
downloadrules-cc-6591e8aa71be7950725c0fb10341a73ab3da4c52.tar.gz
Merge commit '48f4317'
-rw-r--r--CC/EXPRESSIONS3
-rw-r--r--CC/IDE/RULES96
-rw-r--r--CC/pkgconfig/EXPRESSIONS136
-rw-r--r--CC/pkgconfig/RULES52
-rw-r--r--CC/proto/EXPRESSIONS166
-rw-r--r--CC/proto/RULES238
-rw-r--r--CC/proto/TARGETS13
7 files changed, 527 insertions, 177 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS
index f1868d7..a520cde 100644
--- a/CC/EXPRESSIONS
+++ b/CC/EXPRESSIONS
@@ -115,7 +115,7 @@
}
, "defaults-base-provides":
{ "doc": ["Query list-provider from 'base' targets (last wins)"]
- , "vars": ["provider"]
+ , "vars": ["provider", "default"]
, "vars_doc":
{"provider": ["The name of the list-provider in the provides map."]}
, "imports": {"provider_list": ["./", "..", "field_provider_list"]}
@@ -125,6 +125,7 @@
, "body":
{ "type": "foldl"
, "var": "next"
+ , "start": {"type": "var", "name": "default", "default": []}
, "accum_var": "curr"
, "range": {"type": "CALL_EXPRESSION", "name": "provider_list"}
, "body":
diff --git a/CC/IDE/RULES b/CC/IDE/RULES
deleted file mode 100644
index dc4b607..0000000
--- a/CC/IDE/RULES
+++ /dev/null
@@ -1,96 +0,0 @@
-{ "headers":
- { "doc": ["Transitive public headers of C++ target"]
- , "target_fields": ["proto", "deps"]
- , "string_fields": ["stage"]
- , "field_doc":
- { "proto": ["The proto source files for creating cc bindings."]
- , "deps": ["The targets to obtain the headers from."]
- , "stage":
- [ "The logical location of the header files. Individual directory"
- , "components are joined with \"/\"."
- ]
- }
- , "anonymous":
- { "proto-deps":
- { "target": "proto"
- , "provider": "proto"
- , "rule_map":
- { "library": ["./", "../proto", "library"]
- , "service library": ["./", "../proto", "service library"]
- }
- }
- }
- , "imports": {"runfiles_list": ["./", "../..", "field_runfiles_list"]}
- , "expression":
- { "type": "let*"
- , "bindings":
- [ [ "stage"
- , { "type": "join"
- , "separator": "/"
- , "$1": {"type": "FIELD", "name": "stage"}
- }
- ]
- , [ "artifacts"
- , { "type": "to_subdir"
- , "subdir": {"type": "var", "name": "stage"}
- , "$1":
- { "type": "map_union"
- , "$1":
- { "type": "++"
- , "$1":
- [ { "type": "let*"
- , "bindings": [["fieldname", "proto-deps"]]
- , "body":
- {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
- }
- , { "type": "foreach"
- , "var": "x"
- , "range": {"type": "FIELD", "name": "proto-deps"}
- , "body":
- { "type": "DEP_PROVIDES"
- , "provider": "compile-deps"
- , "dep": {"type": "var", "name": "x"}
- , "default":
- { "type": "fail"
- , "msg":
- [ "Expected a library target, but got:"
- , {"type": "var", "name": "x"}
- ]
- }
- }
- }
- , { "type": "let*"
- , "bindings": [["fieldname", "deps"]]
- , "body":
- {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
- }
- , { "type": "foreach"
- , "var": "x"
- , "range": {"type": "FIELD", "name": "deps"}
- , "body":
- { "type": "DEP_PROVIDES"
- , "provider": "compile-deps"
- , "dep": {"type": "var", "name": "x"}
- , "default":
- { "type": "fail"
- , "msg":
- [ "Expected a library target, but got:"
- , {"type": "var", "name": "x"}
- ]
- }
- }
- }
- ]
- }
- }
- }
- ]
- ]
- , "body":
- { "type": "RESULT"
- , "artifacts": {"type": "var", "name": "artifacts"}
- , "runfiles": {"type": "var", "name": "artifacts"}
- }
- }
- }
-}
diff --git a/CC/pkgconfig/EXPRESSIONS b/CC/pkgconfig/EXPRESSIONS
new file mode 100644
index 0000000..c770421
--- /dev/null
+++ b/CC/pkgconfig/EXPRESSIONS
@@ -0,0 +1,136 @@
+{ "pkgconfig result":
+ { "vars": ["ENV", "name", "args", "stage"]
+ , "imports": {"default-ENV": ["./", "..", "default-ENV"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "ENV"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "default-ENV"}
+ , [ { "type": "var"
+ , "name": "ENV"
+ , "default": {"type": "empty_map"}
+ }
+ ]
+ ]
+ }
+ }
+ ]
+ , [ "cflags-filename"
+ , {"type": "join", "$1": [{"type": "var", "name": "name"}, ".cflags"]}
+ ]
+ , [ "cflags-files"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "stage"}
+ , "$1":
+ { "type": "ACTION"
+ , "inputs": {"type": "empty_map"}
+ , "cmd":
+ [ "/bin/sh"
+ , "-c"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["pkg-config"]
+ , [ { "type": "join_cmd"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "args", "default": []}
+ , ["--cflags", {"type": "var", "name": "name"}]
+ ]
+ }
+ }
+ ]
+ , [">"]
+ , [ { "type": "join_cmd"
+ , "$1": {"type": "var", "name": "cflags-filename"}
+ }
+ ]
+ ]
+ }
+ }
+ ]
+ , "env": {"type": "var", "name": "ENV"}
+ , "outs": [{"type": "var", "name": "cflags-filename"}]
+ }
+ }
+ ]
+ , [ "compile-args"
+ , { "type": "foreach_map"
+ , "var_key": "flag-file"
+ , "range": {"type": "var", "name": "cflags-files"}
+ , "body":
+ {"type": "join", "$1": ["@", {"type": "var", "name": "flag-file"}]}
+ }
+ ]
+ , [ "ldflags-filename"
+ , {"type": "join", "$1": [{"type": "var", "name": "name"}, ".ldflags"]}
+ ]
+ , [ "ldflags-files"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "stage"}
+ , "$1":
+ { "type": "ACTION"
+ , "inputs": {"type": "empty_map"}
+ , "cmd":
+ [ "/bin/sh"
+ , "-c"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ ["pkg-config"]
+ , [ { "type": "join_cmd"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "args", "default": []}
+ , ["--libs", {"type": "var", "name": "name"}]
+ ]
+ }
+ }
+ ]
+ , [">"]
+ , [ { "type": "join_cmd"
+ , "$1": {"type": "var", "name": "ldflags-filename"}
+ }
+ ]
+ ]
+ }
+ }
+ ]
+ , "env": {"type": "var", "name": "ENV"}
+ , "outs": [{"type": "var", "name": "ldflags-filename"}]
+ }
+ }
+ ]
+ , [ "link-args"
+ , { "type": "foreach_map"
+ , "var_key": "flag-file"
+ , "range": {"type": "var", "name": "ldflags-files"}
+ , "body":
+ {"type": "join", "$1": ["@", {"type": "var", "name": "flag-file"}]}
+ }
+ ]
+ , ["package", {"type": "env", "vars": ["cflags-files", "ldflags-files"]}]
+ , ["compile-deps", {"type": "empty_map"}]
+ , ["link-deps", {"type": "empty_map"}]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "provides":
+ { "type": "env"
+ , "vars":
+ ["compile-deps", "compile-args", "link-deps", "link-args", "package"]
+ }
+ }
+ }
+ }
+}
diff --git a/CC/pkgconfig/RULES b/CC/pkgconfig/RULES
new file mode 100644
index 0000000..a6f6ce8
--- /dev/null
+++ b/CC/pkgconfig/RULES
@@ -0,0 +1,52 @@
+{ "system_library":
+ { "doc": ["A system library via pkg-config"]
+ , "string_fields": ["name", "args", "stage"]
+ , "implicit": {"defaults": [["./", "..", "defaults"]]}
+ , "config_vars": ["PKG_CONFIG_ARGS", "ENV"]
+ , "field_doc":
+ { "name": ["The pkg-config name of the library."]
+ , "args":
+ [ "Additional pkg-config arguments (e.g., \"--define-prefix\" or"
+ , "\"--static\"), appended to the config variable \"PKG_CONFIG_ARGS\"."
+ ]
+ , "stage": ["The stage of the internally created flag files."]
+ }
+ , "config_doc":
+ { "PKG_CONFIG_ARGS":
+ [ "Additional pkg-config arguments (e.g., \"--define-prefix\" or"
+ , "\"--static\")."
+ ]
+ , "ENV":
+ [ "The environment for any action generated. May contain colon-separated"
+ , "\"PKG_CONFIG_PATH\" for looking up pkg-config files."
+ ]
+ }
+ , "imports": {"pkgconfig result": "pkgconfig result"}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "name"
+ , { "type": "assert_non_empty"
+ , "msg": "system_library requires non-empty name"
+ , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}}
+ }
+ ]
+ , [ "args"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "PKG_CONFIG_ARGS", "default": []}
+ , {"type": "FIELD", "name": "args"}
+ ]
+ }
+ ]
+ , [ "stage"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "pkgconfig result"}
+ }
+ }
+}
diff --git a/CC/proto/EXPRESSIONS b/CC/proto/EXPRESSIONS
index 1ab17a5..d2705f1 100644
--- a/CC/proto/EXPRESSIONS
+++ b/CC/proto/EXPRESSIONS
@@ -1,4 +1,81 @@
-{ "protoc-deps":
+{ "default-PROTOC":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "PROTOC"]
+ , [ "transition"
+ , {"type": "var", "name": "defaults-transition", "default": null}
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-LDFLAGS":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "LDFLAGS"]
+ , [ "transition"
+ , {"type": "var", "name": "defaults-transition", "default": null}
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-GRPC_PLUGIN":
+ { "vars": ["defaults-transition"]
+ , "imports": {"list_provider": ["./", "../..", "field_list_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "GRPC_PLUGIN"]
+ , [ "transition"
+ , {"type": "var", "name": "defaults-transition", "default": null}
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
+ }
+ }
+, "default-ENV":
+ { "vars": ["defaults-transition"]
+ , "imports": {"map_provider": ["./", "../..", "field_map_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "ENV"]
+ , [ "transition"
+ , {"type": "var", "name": "defaults-transition", "default": null}
+ ]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+, "default-TOOLCHAIN":
+ { "vars": ["defaults-transition"]
+ , "imports": {"map_provider": ["./", "../..", "field_map_provider"]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "proto-defaults"]
+ , ["provider", "TOOLCHAIN"]
+ , [ "transition"
+ , {"type": "var", "name": "defaults-transition", "default": null}
+ ]
+ , ["default", {"type": "empty_map"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"}
+ }
+ }
+, "protoc-deps":
{ "imports": {"map_provider": ["./", "../..", "field_map_provider"]}
, "expression":
{ "type": "let*"
@@ -16,57 +93,66 @@
, "name"
, "stage"
, "service support"
- , "deps-transition"
, "public-fieldnames"
, "private-fieldnames"
]
, "imports":
{ "stage": ["", "stage_singleton_field"]
, "result": ["./", "..", "lib result"]
- , "artifacts": ["./", "../..", "field_artifacts"]
+ , "runfiles": ["./", "../..", "field_runfiles"]
, "artifacts_list": ["./", "../..", "field_artifacts_list"]
, "protoc-deps": "protoc-deps"
+ , "default-PROTOC": "default-PROTOC"
+ , "default-LDFLAGS": "default-LDFLAGS"
+ , "default-GRPC_PLUGIN": "default-GRPC_PLUGIN"
+ , "default-ENV": "default-ENV"
+ , "default-TOOLCHAIN": "default-TOOLCHAIN"
}
, "expression":
{ "type": "let*"
, "bindings":
[ ["pure C", false]
- , [ "protoc"
- , { "type": "let*"
- , "bindings":
- [ ["fieldname", "protoc"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
- , ["location", "protoc"]
- ]
- , "body": {"type": "CALL_EXPRESSION", "name": "stage"}
- }
- ]
- , [ "grpc_cpp_plugin"
+ , ["TOOLCHAIN_DIR", "toolchain"]
+ , ["TOOLCHAIN", {"type": "CALL_EXPRESSION", "name": "default-TOOLCHAIN"}]
+ , [ "TOOLCHAIN"
, { "type": "if"
- , "cond": {"type": "var", "name": "service support"}
+ , "cond": {"type": "var", "name": "TOOLCHAIN"}
, "then":
- { "type": "let*"
- , "bindings":
- [ ["fieldname", "grpc_cpp_plugin"]
- , ["transition", {"type": "var", "name": "deps-transition"}]
- , ["location", "grpc_cpp_plugin"]
+ { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "TOOLCHAIN_DIR"}
+ , "$1": {"type": "var", "name": "TOOLCHAIN"}
+ }
+ }
+ ]
+ , [ "PROTOC"
+ , { "type": "join"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "TOOLCHAIN"}
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "default-PROTOC"}
]
- , "body": {"type": "CALL_EXPRESSION", "name": "stage"}
}
- , "else": {"type": "empty_map"}
}
]
- , ["protoc-deps", {"type": "CALL_EXPRESSION", "name": "protoc-deps"}]
- , [ "proto deps"
- , { "type": "to_subdir"
- , "subdir": "work"
+ , [ "GRPC_PLUGIN"
+ , { "type": "join"
, "$1":
- { "type": "let*"
- , "bindings": [["fieldname", "well_known_protos"]]
- , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "TOOLCHAIN"}
+ , "then": ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"]
+ }
+ , {"type": "CALL_EXPRESSION", "name": "default-GRPC_PLUGIN"}
+ ]
}
}
]
+ , ["protoc-deps", {"type": "CALL_EXPRESSION", "name": "protoc-deps"}]
, [ "proto srcs"
, { "type": "disjoint_map_union"
, "msg": "Sources may not conflict"
@@ -139,12 +225,20 @@
, [ "cmd"
, { "type": "++"
, "$1":
- [ ["./protoc", "--proto_path=work", "--cpp_out=work"]
+ [ [ {"type": "var", "name": "PROTOC"}
+ , "--proto_path=work"
+ , "--cpp_out=work"
+ ]
, { "type": "if"
, "cond": {"type": "var", "name": "service support"}
, "then":
[ "--grpc_out=work"
- , "--plugin=protoc-gen-grpc=./grpc_cpp_plugin"
+ , { "type": "join"
+ , "$1":
+ [ "--plugin=protoc-gen-grpc="
+ , {"type": "var", "name": "GRPC_PLUGIN"}
+ ]
+ }
]
, "else": []
}
@@ -158,9 +252,7 @@
{ "type": "map_union"
, "$1":
[ {"type": "var", "name": "staged all proto srcs"}
- , {"type": "var", "name": "protoc"}
- , {"type": "var", "name": "grpc_cpp_plugin"}
- , {"type": "var", "name": "proto deps"}
+ , {"type": "var", "name": "TOOLCHAIN"}
]
}
, "outs": {"type": "var", "name": "outs"}
@@ -299,8 +391,10 @@
}
]
, ["cflags", []]
- , ["private-cflags", ["-Wno-sign-conversion", "-Wno-unused-function"]]
- , ["private-ldflags", []]
+ , ["private-cflags", []]
+ , [ "private-ldflags"
+ , {"type": "CALL_EXPRESSION", "name": "default-LDFLAGS"}
+ ]
]
, "body": {"type": "CALL_EXPRESSION", "name": "result"}
}
diff --git a/CC/proto/RULES b/CC/proto/RULES
index 39d342f..97b4367 100644
--- a/CC/proto/RULES
+++ b/CC/proto/RULES
@@ -1,4 +1,186 @@
-{ "library":
+{ "defaults":
+ { "doc":
+ [ "A rule to provide protoc/GRPC defaults."
+ , "Used to implement [\"CC/proto\", \"defaults\"] for CC proto libraries"
+ , "and [\"CC/proto\", \"service defaults\"] for CC proto service libraries"
+ , "(GRPC)."
+ ]
+ , "target_fields": ["base", "toolchain", "deps"]
+ , "string_fields":
+ ["PROTOC", "LDFLAGS", "ADD_LDFLAGS", "GRPC_PLUGIN", "PATH"]
+ , "config_vars": ["ARCH", "HOST_ARCH"]
+ , "field_doc":
+ { "base":
+ [ "Other targets (using the same rule) to inherit values from. If"
+ , "multiple targets are specified, for values that are overwritten (see"
+ , "documentation of other fields) the last specified value wins."
+ ]
+ , "toolchain":
+ [ "Optional toolchain directory. A collection of artifacts that provide"
+ , "the protobuf compiler and the GRPC plugin (if needed). Note that only"
+ , "artifacts of the specified targets are considered (no runfiles etc.)."
+ , "Specifying this field overlays artifacts from \"base\"."
+ ]
+ , "deps":
+ [ "Optional CC libraries the resulting CC proto libraries implicitly"
+ , "depend on. Those are typically \"libprotobuf\" for CC proto libraries"
+ , "and \"libgrpc++\" for CC proto service libraries. Specifying this"
+ , "field extends dependencies from \"base\"."
+ ]
+ , "PROTOC":
+ [ "The proto compiler. If \"toolchain\" is empty, this field's value is"
+ , "considered the proto compiler name that is looked up in \"PATH\". If"
+ , "\"toolchain\" is non-empty, this field's value is assumed to be the"
+ , "relative path to the proto compiler in \"toolchain\". Specifying this"
+ , "field overwrites values from \"base\"."
+ ]
+ , "GRPC_PLUGIN":
+ [ "The GRPC plugin for the proto compiler. If \"toolchain\" is empty,"
+ , "this field's value is considered to be the absolute system path to the"
+ , "plugin. If \"toolchain\" is non-empty, this field's value is assumed"
+ , "to be the relative path to the plugin in \"toolchain\". Specifying"
+ , "this field overwrites values from \"base\"."
+ ]
+ , "LDFLAGS":
+ [ "Linker flags for linking the final CC library. Specifying this field"
+ , "overwrites values from \"base\"."
+ ]
+ , "ADD_LDFLAGS":
+ [ "Additional linker flags for linking the final CC library. Specifying"
+ , "this field extends values from \"base\"."
+ ]
+ , "PATH":
+ [ "Path for looking up the proto compiler. Individual paths are joined"
+ , "with \":\"."
+ ]
+ }
+ , "imports":
+ { "base-provides": ["./", "..", "defaults-base-provides"]
+ , "artifacts": ["", "field_artifacts"]
+ , "compile-deps": ["CC", "compile-deps"]
+ , "compile-args-deps": ["CC", "compile-args-deps"]
+ , "link-deps": ["CC", "link-deps"]
+ , "link-args-deps": ["CC", "link-args-deps"]
+ , "cflags-files-deps": ["CC", "cflags-files-deps"]
+ , "ldflags-files-deps": ["CC", "ldflags-files-deps"]
+ , "for host": ["transitions", "for host"]
+ }
+ , "config_transitions":
+ {"toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]}
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ ["PROTOC", {"type": "FIELD", "name": "PROTOC"}]
+ , ["LDFLAGS", {"type": "FIELD", "name": "LDFLAGS"}]
+ , ["GRPC_PLUGIN", {"type": "FIELD", "name": "GRPC_PLUGIN"}]
+ , ["PATH", {"type": "FIELD", "name": "PATH"}]
+ , ["provider", "PROTOC"]
+ , [ "PROTOC"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "PROTOC"}
+ , "then": {"type": "var", "name": "PROTOC"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "LDFLAGS"]
+ , [ "LDFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "LDFLAGS"}
+ , "then": {"type": "var", "name": "LDFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "GRPC_PLUGIN"]
+ , [ "GRPC_PLUGIN"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "GRPC_PLUGIN"}
+ , "then": {"type": "var", "name": "GRPC_PLUGIN"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "ENV"]
+ , [ "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": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ , [ "TOOLCHAIN"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ , { "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"}
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ }
+ ]
+ , [ "LDFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "LDFLAGS"}
+ , {"type": "FIELD", "name": "ADD_LDFLAGS"}
+ ]
+ }
+ ]
+ , ["deps-fieldnames", ["base", "deps"]]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
+ , ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , [ "ldflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ ]
+ , ["package", {"type": "env", "vars": ["cflags-files", "ldflags-files"]}]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "provides":
+ { "type": "env"
+ , "vars":
+ [ "PROTOC"
+ , "LDFLAGS"
+ , "GRPC_PLUGIN"
+ , "ENV"
+ , "TOOLCHAIN"
+ , "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "package"
+ ]
+ }
+ }
+ }
+ }
+, "library":
{ "doc":
[ "A library C++ library, generated from proto files."
, ""
@@ -7,20 +189,10 @@
]
, "string_fields": ["name", "stage"]
, "target_fields": ["srcs", "deps"]
- , "config_vars":
- ["OS", "ARCH", "HOST_ARCH", "CXX", "CXXFLAGS", "ADD_CXXFLAGS", "AR", "ENV"]
+ , "config_vars": ["CXX", "CXXFLAGS", "ADD_CXXFLAGS", "AR", "ENV"]
, "implicit":
- { "protoc": [["@", "protoc", "", "protoc"]]
- , "defaults": [["./", "..", "defaults"]]
- , "proto-deps": [["@", "protoc", "", "C++ runtime"]]
- , "well_known_protos": [["@", "protoc", "", "well_known_protos"]]
- }
- , "imports":
- { "protoc-compile": "protoc-compile"
- , "host transition": ["transitions", "for host"]
- }
- , "config_transitions":
- {"protoc": [{"type": "CALL_EXPRESSION", "name": "host transition"}]}
+ {"defaults": [["./", "..", "defaults"]], "proto-defaults": ["defaults"]}
+ , "imports": {"protoc-compile": "protoc-compile"}
, "expression":
{ "type": "let*"
, "bindings":
@@ -31,11 +203,8 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
- , [ "deps-transition"
- , {"type": "CALL_EXPRESSION", "name": "host transition"}
- ]
- , ["public-fieldnames", ["deps", "proto-deps"]]
- , ["private-fieldnames", ["deps", "proto-deps"]]
+ , ["public-fieldnames", ["deps"]]
+ , ["private-fieldnames", ["deps", "proto-defaults"]]
]
, "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"}
}
@@ -49,28 +218,12 @@
]
, "string_fields": ["name", "stage"]
, "target_fields": ["srcs", "deps"]
- , "config_vars":
- ["OS", "ARCH", "HOST_ARCH", "CXX", "CXXFLAGS", "ADD_CXXFLAGS", "AR", "ENV"]
+ , "config_vars": ["CXX", "CXXFLAGS", "ADD_CXXFLAGS", "AR", "ENV"]
, "implicit":
- { "protoc": [["@", "protoc", "", "protoc"]]
- , "grpc_cpp_plugin": [["@", "grpc", "src/compiler", "grpc_cpp_plugin"]]
- , "defaults": [["./", "..", "defaults"]]
- , "proto-deps":
- [ ["@", "grpc", "", "grpc++_codegen_proto"]
- , ["@", "grpc", "", "grpc++_codegen_base_src"]
- , ["@", "protoc", "", "C++ runtime"]
- ]
- , "well_known_protos": [["@", "protoc", "", "well_known_protos"]]
- }
- , "imports":
- { "protoc-compile": "protoc-compile"
- , "host transition": ["transitions", "for host"]
- }
- , "config_transitions":
- { "protoc": [{"type": "CALL_EXPRESSION", "name": "host transition"}]
- , "grpc_cpp_plugin":
- [{"type": "CALL_EXPRESSION", "name": "host transition"}]
+ { "defaults": [["./", "..", "defaults"]]
+ , "proto-defaults": ["service defaults"]
}
+ , "imports": {"protoc-compile": "protoc-compile"}
, "expression":
{ "type": "let*"
, "bindings":
@@ -82,11 +235,8 @@
, "$1": {"type": "FIELD", "name": "stage"}
}
]
- , [ "deps-transition"
- , {"type": "CALL_EXPRESSION", "name": "host transition"}
- ]
- , ["public-fieldnames", ["deps", "proto-deps"]]
- , ["private-fieldnames", ["deps", "proto-deps"]]
+ , ["public-fieldnames", ["deps", "proto-defaults"]]
+ , ["private-fieldnames", ["deps", "proto-defaults"]]
]
, "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"}
}
diff --git a/CC/proto/TARGETS b/CC/proto/TARGETS
new file mode 100644
index 0000000..45ef759
--- /dev/null
+++ b/CC/proto/TARGETS
@@ -0,0 +1,13 @@
+{ "defaults":
+ { "type": ["CC/proto", "defaults"]
+ , "PROTOC": ["protoc"]
+ , "LDFLAGS": ["-lprotobuf"]
+ , "PATH": ["/bin", "/usr/bin"]
+ }
+, "service defaults":
+ { "type": ["CC/proto", "defaults"]
+ , "base": ["defaults"]
+ , "GRPC_PLUGIN": ["/usr/bin/grpc_cpp_plugin"]
+ , "ADD_LDFLAGS": ["-lgrpc++", "-lgrpc", "-lgpr"]
+ }
+}