diff options
author | 2016-05-24 21:10:27 +0000 | |
---|---|---|
committer | 2016-05-25 08:35:36 +0000 | |
commit | f945a0c70f46588ce1203d39824377f5c399358e (patch) | |
tree | 13fe9d1626787d8850fc66c5a994e7690f90952a /src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java | |
parent | 1164a4f9db8d2b66d005bfa340ed76fd5f89fb00 (diff) |
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java | 33 |
1 files changed, 32 insertions, 1 deletions
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 @@ -808,9 +808,24 @@ 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)) /* <!-- #BLAZE_RULE($objc_linking_rule).ATTRIBUTE(linkopts) --> - Extra flags to pass to the linker. + Extra flags to pass to the linker. <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/ .add(attr("linkopts", STRING_LIST)) .build(); |