Support sources in nested dirs

pull/2291/head
Jorge Canizales 10 years ago
parent 4bc49051ba
commit fc5fb879a6
  1. 34
      grpc.bzl

@ -6,7 +6,9 @@ def _lower_underscore_to_upper_camel(str):
return "".join(humps) return "".join(humps)
def objc_grpc_library(name, srcs, visibility=None): def objc_grpc_library(name, srcs, visibility=None):
basename = srcs[0].split('/')[-1] src_path_elements = srcs[0].split('/')
src_dir = '/'.join(src_path_elements[:-1])
basename = src_path_elements[-1]
filename = basename[:-6] # remove .proto suffix filename = basename[:-6] # remove .proto suffix
filename = _lower_underscore_to_upper_camel(filename) filename = _lower_underscore_to_upper_camel(filename)
@ -17,24 +19,19 @@ def objc_grpc_library(name, srcs, visibility=None):
# Messages # Messages
protoc_messages_flags = "--objc_out=$(GENDIR)" protoc_messages_flags = "--objc_out=$(GENDIR)"
message_header = src_dir + '/' + filename + ".pbobjc.h"
message_implementation = src_dir + '/' + filename + ".pbobjc.m"
native.genrule( native.genrule(
name = name + "_mesages_codegen", name = name + "_mesages_codegen",
srcs = srcs, srcs = srcs,
outs = [ outs = [message_header, message_implementation],
filename + ".pbobjc.h",
filename + ".pbobjc.m",
],
cmd = protoc_command + protoc_messages_flags + srcs_params, cmd = protoc_command + protoc_messages_flags + srcs_params,
) )
native.objc_library( native.objc_library(
name = name + "_messages", name = name + "_messages",
hdrs = [ hdrs = [message_header],
":" + filename + ".pbobjc.h",
],
includes = ["."], includes = ["."],
non_arc_srcs = [ non_arc_srcs = [message_implementation],
":" + filename + ".pbobjc.m",
],
deps = [ deps = [
"//external:protobuf_objc", "//external:protobuf_objc",
], ],
@ -42,24 +39,19 @@ def objc_grpc_library(name, srcs, visibility=None):
# Services # Services
protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)" protoc_services_flags = "--grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(location //external:grpc_protoc_plugin_objc)"
service_header = src_dir + '/' + filename + ".pbrpc.h"
service_implementation = src_dir + '/' + filename + ".pbrpc.m"
native.genrule( native.genrule(
name = name + "_codegen", name = name + "_codegen",
srcs = srcs + ["//external:grpc_protoc_plugin_objc"], srcs = srcs + ["//external:grpc_protoc_plugin_objc"],
outs = [ outs = [service_header, service_implementation],
filename + ".pbrpc.h",
filename + ".pbrpc.m",
],
cmd = protoc_command + protoc_services_flags + srcs_params, cmd = protoc_command + protoc_services_flags + srcs_params,
) )
native.objc_library( native.objc_library(
name = name, name = name,
hdrs = [ hdrs = [service_header],
":" + filename + ".pbrpc.h",
],
includes = ["."], includes = ["."],
srcs = [ srcs = [service_implementation],
":" + filename + ".pbrpc.m",
],
deps = [ deps = [
":" + name + "_messages", ":" + name + "_messages",
"//external:proto_objc_rpc", "//external:proto_objc_rpc",

Loading…
Cancel
Save