From b7b8d05f25974c1cf14718d23ca67192f63d41c0 Mon Sep 17 00:00:00 2001 From: Rob Earhart Date: Tue, 29 Mar 2016 11:35:29 -0700 Subject: Fix the Bazel build re/nanopb This change modifies the BUILD rule dependencies used for nanopb, switching them from third_party to //external -- the former uses submodules, which don't work well with Bazel (since Bazel removes submodules from repositories as it fetches them, preferring instead to unify submodule versions across the workspace via the top-level WORKSPACE configuration). --- templates/BUILD.template | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/templates/BUILD.template b/templates/BUILD.template index 54dc697125..ebf7ffbf9a 100644 --- a/templates/BUILD.template +++ b/templates/BUILD.template @@ -60,7 +60,7 @@ deps.append(':%s' % (d)) return deps %> - + % for lib in libs: % if lib.build in ("all", "protoc"): ${cc_library(lib)} @@ -80,13 +80,19 @@ % endfor <%def name="cc_library(lib)"> + <% + lib_hdrs = lib.get("headers", []) + hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')] + srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')] + uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src) + %> cc_library( name = "${lib.name}", srcs = [ - % for hdr in lib.get("headers", []): + % for hdr in hdrs: "${hdr}", % endfor - % for src in lib.src: + % for src in srcs: "${src}", % endfor ], @@ -103,6 +109,9 @@ % for dep in get_deps(lib): "${dep}", % endfor + % if uses_nanopb: + "//external:nanopb", + % endif ], % if lib.name in ("grpc", "grpc_unsecure"): copts = [ @@ -113,10 +122,16 @@ <%def name="objc_library(lib)"> + <% + lib_hdrs = lib.get("headers", []) + hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')] + srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')] + uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src) + %> objc_library( name = "${lib.name}_objc", srcs = [ - % for src in lib.src: + % for src in srcs: "${src}", % endfor ], @@ -124,7 +139,7 @@ % for hdr in lib.get("public_headers", []): "${hdr}", % endfor - % for hdr in lib.get("headers", []): + % for hdr in hdrs: "${hdr}", % endfor ], @@ -138,6 +153,9 @@ % endfor % if lib.get('secure', False): "//external:libssl_objc", + % endif + % if uses_nanopb: + "//external:nanopb", % endif ], % if lib.get("baselib", false): -- cgit v1.2.3 From ff20c2b46cbe967f73ba02caa87bcdb57417229c Mon Sep 17 00:00:00 2001 From: Rob Earhart Date: Tue, 29 Mar 2016 11:39:04 -0700 Subject: Add protobuf_clib to deps of grpc++_codegen_lib This is required in order to compile grpc++_codegen_lib. --- BUILD | 1 + templates/BUILD.template | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/BUILD b/BUILD index 025878d82a..fc4dfe8d9a 100644 --- a/BUILD +++ b/BUILD @@ -1041,6 +1041,7 @@ cc_library( ".", ], deps = [ + "//external:protobuf_clib", ], ) diff --git a/templates/BUILD.template b/templates/BUILD.template index ebf7ffbf9a..23a656c360 100644 --- a/templates/BUILD.template +++ b/templates/BUILD.template @@ -49,7 +49,9 @@ ] if target_dict.get('build', None) == 'protoc': deps.append("//external:protobuf_compiler") - if target_dict['name'] == 'grpc++_unsecure' or target_dict['name'] == 'grpc++': + if (target_dict['name'] == 'grpc++_unsecure' or + target_dict['name'] == 'grpc++' or + target_dict['name'] == 'grpc++_codegen_lib'): deps.append("//external:protobuf_clib") elif target_dict['name'] == 'grpc': deps.append("//external:zlib") -- cgit v1.2.3