1 2# copybara:insert_for_google3_begin 3# load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", _cc_proto_library="cc_proto_library") 4# copybara:insert_end 5 6# copybara:strip_for_google3_begin 7_cc_proto_library = native.cc_proto_library 8# copybara:strip_end 9 10def proto_library(**kwargs): 11 native.proto_library( 12 # copybara:insert_for_google3_begin 13 # cc_api_version = 2, 14 # copybara:insert_end 15 **kwargs, 16 ) 17 18def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs): 19 srcs = [name + ".cc"] 20 native.genrule( 21 name = name + "_gen_srcs", 22 tools = [gen], 23 outs = srcs, 24 cmd = "$(location " + gen + ") " + " ".join(args) + " > $@", 25 ) 26 27 native.cc_binary( 28 # copybara:insert_for_google3_begin 29 # malloc="//base:system_malloc", 30 # features = ["-static_linking_mode"], 31 # copybara:insert_end 32 name = name, 33 srcs = srcs, 34 **kwargs, 35 ) 36 37def cc_optimizefor_proto_library(name, srcs, outs, optimize_for): 38 if len(srcs) != 1: 39 fail("Currently srcs must have exactly 1 element") 40 41 native.genrule( 42 name = name + "_gen_proto", 43 srcs = srcs, 44 outs = outs, 45 cmd = "cp $< $@ && chmod a+w $@ && echo 'option optimize_for = " + optimize_for + ";' >> $@", 46 ) 47 48 proto_library( 49 name = name + "_proto", 50 srcs = outs, 51 ) 52 53 _cc_proto_library( 54 name = name, 55 deps = [":" + name + "_proto"], 56 ) 57 58def expand_suffixes(vals, suffixes): 59 ret = [] 60 for val in vals: 61 for suffix in suffixes: 62 ret.append(val + suffix) 63 return ret 64