From f945a0c70f46588ce1203d39824377f5c399358e Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Tue, 24 May 2016 21:10:27 +0000 Subject: Support for gathering all the protos seen in the transitive closure of dependencies through the ObjcProtoAspect, compiling and linking the generated protos at the final linking target. This is only enabled for objc_proto_libraries using the portable_proto_filters attribute, and guarded with the "--experimental_auto_top_level_union_objc_protos" flag. This prevents duplicate symbol errors as the generated sources are only linked once. -- MOS_MIGRATED_REVID=123144532 --- .../build/lib/rules/objc/ObjcRuleClasses.java | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index 48981fbbe0..4c089de70c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -807,10 +807,25 @@ public class ObjcRuleClasses { } } + /** + * Protocol buffer related implicit attributes. + */ + static final String PROTO_COMPILER_ATTR = "$googlemac_proto_compiler"; + static final String PROTO_COMPILER_SUPPORT_ATTR = "$googlemac_proto_compiler_support"; + static final String PROTO_LIB_ATTR = "$lib_protobuf"; + static final String PROTOBUF_WELL_KNOWN_TYPES = "$protobuf_well_known_types"; + /** * Common attributes for {@code objc_*} rules that link sources and dependencies. */ public static class LinkingRule implements RuleDefinition { + + private final ObjcProtoAspect objcProtoAspect; + + public LinkingRule(ObjcProtoAspect objcProtoAspect) { + this.objcProtoAspect = objcProtoAspect; + } + @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder @@ -827,8 +842,24 @@ public class ObjcRuleClasses { .singleArtifact() .value(env.getToolsLabel("//tools/objc:j2objc_dead_code_pruner"))) .add(attr("$dummy_lib", LABEL).value(env.getToolsLabel("//tools/objc:dummy_lib"))) + .add( + attr(PROTO_COMPILER_ATTR, LABEL) + .allowedFileTypes(FileType.of(".py")) + .cfg(HOST) + .singleArtifact() + .value(env.getToolsLabel("//tools/objc:protobuf_compiler"))) + .add( + attr(PROTO_COMPILER_SUPPORT_ATTR, LABEL) + .legacyAllowAnyFileType() + .cfg(HOST) + .value(env.getToolsLabel("//tools/objc:protobuf_compiler_support"))) + .add( + attr(PROTOBUF_WELL_KNOWN_TYPES, LABEL) + .cfg(HOST) + .value(env.getToolsLabel("//tools/objc:protobuf_well_known_types"))) + .override(builder.copy("deps").aspect(objcProtoAspect)) /* - Extra flags to pass to the linker. + Extra flags to pass to the linker. */ .add(attr("linkopts", STRING_LIST)) .build(); -- cgit v1.2.3