summaryrefslogtreecommitdiff
path: root/build_defs.bzl
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-12-16 14:32:14 -0800
committerJoshua Haberman <jhaberman@gmail.com>2018-12-16 14:32:14 -0800
commit377871f10403c7b4e1cc6f769b9443b5197aecc8 (patch)
tree7c97aac20d9ecddf69d5a213d958c9bdfc123646 /build_defs.bzl
parent380558922b661499f4eb43b0463b5a73e5fe87b7 (diff)
Got test_decoder working!
Diffstat (limited to 'build_defs.bzl')
-rw-r--r--build_defs.bzl51
1 files changed, 46 insertions, 5 deletions
diff --git a/build_defs.bzl b/build_defs.bzl
index 8251014..3867976 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -217,7 +217,7 @@ def _remove_up(string):
return _remove_suffix(string, ".proto")
-def _upb_proto_library_srcs_impl(ctx):
+def _upb_proto_srcs_impl(ctx, suffix):
sources = []
outs = []
include_dirs = {}
@@ -225,14 +225,19 @@ def _upb_proto_library_srcs_impl(ctx):
if hasattr(dep, 'proto'):
for src in dep.proto.transitive_sources:
sources.append(src)
- include_dirs[_remove_suffix(src.path, _remove_up(src.short_path) + "." + src.extension)] = True
- outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + ".upb.h"))
- outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + ".upb.c"))
- outdir = _remove_suffix(outs[-1].path, _remove_up(src.short_path) + ".upb.c")
+ include_dir = _remove_suffix(src.path, _remove_up(src.short_path) + "." + src.extension)
+ if include_dir:
+ include_dirs[include_dir] = True
+ outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + suffix + ".h"))
+ outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + suffix + ".c"))
+ outdir = _remove_suffix(outs[-1].path, _remove_up(src.short_path) + suffix + ".c")
source_paths = [d.path for d in sources]
include_args = ["-I" + root for root in include_dirs.keys()]
+ print(source_paths)
+ print(include_args)
+
ctx.actions.run(
inputs = [ctx.executable.upbc] + sources,
outputs = outs,
@@ -243,6 +248,12 @@ def _upb_proto_library_srcs_impl(ctx):
return [DefaultInfo(files = depset(outs))]
+def _upb_proto_library_srcs_impl(ctx):
+ return _upb_proto_srcs_impl(ctx, ".upb")
+
+def _upb_proto_reflection_library_srcs_impl(ctx):
+ return _upb_proto_srcs_impl(ctx, ".upbdefs")
+
_upb_proto_library_srcs = rule(
implementation = _upb_proto_library_srcs_impl,
attrs = {
@@ -272,3 +283,33 @@ def upb_proto_library(name, deps, upbc):
deps = [":upb"],
copts = ["-Ibazel-out/k8-fastbuild/bin"],
)
+
+_upb_proto_reflection_library_srcs = rule(
+ implementation = _upb_proto_reflection_library_srcs_impl,
+ attrs = {
+ "upbc": attr.label(
+ executable = True,
+ cfg = "host",
+ ),
+ "protoc": attr.label(
+ executable = True,
+ cfg = "host",
+ default = "@com_google_protobuf//:protoc",
+ ),
+ "deps": attr.label_list(),
+ }
+)
+
+def upb_proto_reflection_library(name, deps, upbc):
+ srcs_rule = name + "_defsrcs.cc"
+ _upb_proto_reflection_library_srcs(
+ name = srcs_rule,
+ upbc = upbc,
+ deps = deps,
+ )
+ native.cc_library(
+ name = name,
+ srcs = [":" + srcs_rule],
+ deps = [":upb"],
+ copts = ["-Ibazel-out/k8-fastbuild/bin"],
+ )
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback