From 16444baf21780c4bff00b9736b268e97157e6bc2 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Fri, 22 Jan 2016 11:35:15 +0000 Subject: Do not compile source files mentioned in 'hdrs'. Currently for a library: cc_library(name='a', hdrs=['a.cc']) we compile a.cc into a.pic.o and link that into its reverse dependencies. With this change, a .cc file in hdrs will be treated like a .inc file or a file in textual_hdrs. -- MOS_MIGRATED_REVID=112770625 --- .../devtools/build/lib/rules/cpp/CcBinary.java | 23 ++--- .../devtools/build/lib/rules/cpp/CcCommon.java | 88 +++++++++--------- .../devtools/build/lib/rules/cpp/CcLibrary.java | 11 +-- .../build/lib/rules/cpp/CcLibraryHelper.java | 100 +++++++++++++++++---- .../devtools/build/lib/rules/cpp/CppModel.java | 10 +-- .../build/lib/rules/objc/IosFramework.java | 11 ++- .../devtools/build/lib/rules/objc/ObjcCommon.java | 8 +- 7 files changed, 158 insertions(+), 93 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index ff5feff2bc..3afa030e1c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -45,7 +45,6 @@ import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType; import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; import com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider; import com.google.devtools.build.lib.syntax.Type; -import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.FileTypeSet; import com.google.devtools.build.lib.util.OsUtils; import com.google.devtools.build.lib.util.Pair; @@ -153,7 +152,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { boolean useTestOnlyFlags) throws InterruptedException { ruleContext.checkSrcsSamePackage(true); FeatureConfiguration featureConfiguration = CcCommon.configureFeatures(ruleContext); - CcCommon common = new CcCommon(ruleContext, featureConfiguration); + CcCommon common = new CcCommon(ruleContext); CppConfiguration cppConfiguration = ruleContext.getFragment(CppConfiguration.class); PrecompiledFiles precompiledFiles = new PrecompiledFiles(ruleContext); @@ -162,16 +161,11 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { List linkopts = common.getLinkopts(); LinkStaticness linkStaticness = getLinkStaticness(ruleContext, linkopts, cppConfiguration); - ImmutableList> cAndCppSources = common.getCAndCppSources(); CcLibraryHelper helper = new CcLibraryHelper(ruleContext, semantics, featureConfiguration) .fromCommon(common) - .addSources(cAndCppSources) + .addSources(common.getSources()) .addDeps(ImmutableList.of(CppHelper.mallocForTarget(ruleContext))) - .addPrivateHeaders( - FileType.filter( - ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list(), - CppFileTypes.CPP_HEADER)) .setFake(fake) .setLinkType(linkType) .addPrecompiledFiles(precompiledFiles); @@ -284,9 +278,16 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { // logical since all symlinked libraries will be linked anyway and would // not require manual loading but if we do, then we would need to collect // their names and use a different constructor below. - Runfiles runfiles = collectRunfiles( - ruleContext, linkingOutputs, cppCompilationContext, linkStaticness, filesToBuild, - fakeLinkerInputs, fake, cAndCppSources); + Runfiles runfiles = + collectRunfiles( + ruleContext, + linkingOutputs, + cppCompilationContext, + linkStaticness, + filesToBuild, + fakeLinkerInputs, + fake, + helper.getCompilationUnitSources()); RunfilesSupport runfilesSupport = RunfilesSupport.withExecutable( ruleContext, runfiles, executable, ruleContext.getConfiguration().buildRunfiles()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index 1825742e82..2ede292346 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -41,7 +41,6 @@ import com.google.devtools.build.lib.rules.test.InstrumentedFilesProviderImpl; import com.google.devtools.build.lib.shell.ShellUtils; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.FileType; -import com.google.devtools.build.lib.util.FileTypeSet; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; @@ -60,13 +59,6 @@ public final class CcCommon { private static final String NO_COPTS_ATTRIBUTE = "nocopts"; - private static final FileTypeSet SOURCE_TYPES = FileTypeSet.of( - CppFileTypes.CPP_SOURCE, - CppFileTypes.CPP_HEADER, - CppFileTypes.C_SOURCE, - CppFileTypes.ASSEMBLER, - CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR); - /** * Collects all metadata files generated by C++ compilation actions that output the .o files * on the input. @@ -97,15 +89,11 @@ public final class CcCommon { /** C++ configuration */ private final CppConfiguration cppConfiguration; - /** Active toolchain features. */ - private final FeatureConfiguration featureConfiguration; - private final RuleContext ruleContext; - public CcCommon(RuleContext ruleContext, FeatureConfiguration featureConfiguration) { + public CcCommon(RuleContext ruleContext) { this.ruleContext = ruleContext; this.cppConfiguration = ruleContext.getFragment(CppConfiguration.class); - this.featureConfiguration = featureConfiguration; } /** @@ -201,39 +189,23 @@ public final class CcCommon { return new TransitiveLipoInfoProvider(scannableBuilder.build()); } - private boolean shouldProcessHeaders() { - return featureConfiguration.isEnabled(CppRuleClasses.PREPROCESS_HEADERS) - || featureConfiguration.isEnabled(CppRuleClasses.PARSE_HEADERS); - } - /** * Returns a list of ({@link Artifact}, {@link Label}) pairs. Each pair represents an input * source file and the label of the rule that generates it (or the label of the source file - * itself if it is an input file) + * itself if it is an input file). */ - ImmutableList> getCAndCppSources() { + List> getSources() { Map map = Maps.newLinkedHashMap(); Iterable providers = ruleContext.getPrerequisites("srcs", Mode.TARGET, FileProvider.class); - // TODO(bazel-team): Move header processing logic down in the stack (to CcLibraryHelper or - // such). - boolean processHeaders = shouldProcessHeaders(); - if (processHeaders && hasAttribute("hdrs", BuildType.LABEL_LIST)) { - providers = Iterables.concat(providers, - ruleContext.getPrerequisites("hdrs", Mode.TARGET, FileProvider.class)); - } for (FileProvider provider : providers) { - for (Artifact artifact : FileType.filter(provider.getFilesToBuild(), SOURCE_TYPES)) { - boolean isHeader = CppFileTypes.CPP_HEADER.matches(artifact.getExecPath()); - if ((isHeader && !processHeaders) - || CppFileTypes.CPP_TEXTUAL_INCLUDE.matches(artifact.getExecPath())) { - continue; - } - Label oldLabel = map.put(artifact, provider.getLabel()); + for (Artifact artifact : provider.getFilesToBuild()) { // TODO(bazel-team): We currently do not warn for duplicate headers with // different labels, as that would require cleaning up the code base // without significant benefit; we should eventually make this // consistent one way or the other. + Label oldLabel = map.put(artifact, provider.getLabel()); + boolean isHeader = CppFileTypes.CPP_HEADER.matches(artifact.getExecPath()); if (!isHeader && oldLabel != null && !oldLabel.equals(provider.getLabel())) { ruleContext.attributeError("srcs", String.format( "Artifact '%s' is duplicated (through '%s' and '%s')", @@ -246,7 +218,6 @@ public final class CcCommon { for (Map.Entry entry : map.entrySet()) { result.add(Pair.of(entry.getKey(), entry.getValue())); } - return result.build(); } @@ -255,21 +226,44 @@ public final class CcCommon { * warnings to the {@link RuleContext} as a side effect, and so should only be called once for any * given rule. */ - public static List getHeaders(RuleContext ruleContext) { - List hdrs = new ArrayList<>(); + public static List> getHeaders(RuleContext ruleContext) { + Map map = Maps.newLinkedHashMap(); for (TransitiveInfoCollection target : ruleContext.getPrerequisitesIf("hdrs", Mode.TARGET, FileProvider.class)) { FileProvider provider = target.getProvider(FileProvider.class); for (Artifact artifact : provider.getFilesToBuild()) { - if (!CppRuleClasses.DISALLOWED_HDRS_FILES.matches(artifact.getFilename())) { - hdrs.add(artifact); - } else { + if (CppRuleClasses.DISALLOWED_HDRS_FILES.matches(artifact.getFilename())) { ruleContext.attributeWarning("hdrs", "file '" + artifact.getFilename() + "' from target '" + target.getLabel() + "' is not allowed in hdrs"); + continue; + } + Label oldLabel = map.put(artifact, provider.getLabel()); + if (oldLabel != null && !oldLabel.equals(provider.getLabel())) { + ruleContext.attributeWarning( + "hdrs", + String.format( + "Artifact '%s' is duplicated (through '%s' and '%s')", + artifact.getExecPathString(), + oldLabel, + provider.getLabel())); } } } - return hdrs; + + ImmutableList.Builder> result = ImmutableList.builder(); + for (Map.Entry entry : map.entrySet()) { + result.add(Pair.of(entry.getKey(), entry.getValue())); + } + return result.build(); + } + + /** + * Returns the files from headers and does some sanity checks. Note that this method reports + * warnings to the {@link RuleContext} as a side effect, and so should only be called once for any + * given rule. + */ + public List> getHeaders() { + return getHeaders(ruleContext); } private static ImmutableList getPackageCopts(RuleContext ruleContext) { @@ -423,12 +417,16 @@ public final class CcCommon { */ static NestedSet collectCompilationPrerequisites( RuleContext ruleContext, CppCompilationContext context) { - // TODO(bazel-team): Use context.getCompilationPrerequisites() instead. + // TODO(bazel-team): Use context.getCompilationPrerequisites() instead; note that this will + // need cleaning up the prerequisites, as the compilation context currently collects them + // transitively (to get transitive headers), but source files are not transitive compilation + // prerequisites. NestedSetBuilder prerequisites = NestedSetBuilder.stableOrder(); if (ruleContext.attributes().has("srcs", BuildType.LABEL_LIST)) { - for (FileProvider provider : ruleContext - .getPrerequisites("srcs", Mode.TARGET, FileProvider.class)) { - prerequisites.addAll(FileType.filter(provider.getFilesToBuild(), SOURCE_TYPES)); + for (FileProvider provider : + ruleContext.getPrerequisites("srcs", Mode.TARGET, FileProvider.class)) { + prerequisites.addAll( + FileType.filter(provider.getFilesToBuild(), CcLibraryHelper.SOURCE_TYPES)); } } prerequisites.addTransitive(context.getDeclaredIncludeSrcs()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java index a8c9f4d827..764b7f4441 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java @@ -40,7 +40,6 @@ import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType; import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; import com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider; import com.google.devtools.build.lib.syntax.Type; -import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.FileTypeSet; import com.google.devtools.build.lib.vfs.PathFragment; @@ -112,16 +111,15 @@ public abstract class CcLibrary implements RuleConfiguredTargetFactory { boolean collectLinkstamp, boolean addDynamicRuntimeInputArtifactsToRunfiles) { FeatureConfiguration featureConfiguration = CcCommon.configureFeatures(ruleContext); - final CcCommon common = new CcCommon(ruleContext, featureConfiguration); + final CcCommon common = new CcCommon(ruleContext); PrecompiledFiles precompiledFiles = new PrecompiledFiles(ruleContext); CcLibraryHelper helper = new CcLibraryHelper(ruleContext, semantics, featureConfiguration) .fromCommon(common) - .addLinkopts(common.getLinkopts()) - .addSources(common.getCAndCppSources()) - .addPublicHeaders(CcCommon.getHeaders(ruleContext)) + .addSources(common.getSources()) + .addPublicHeaders(common.getHeaders()) .enableCcNativeLibrariesProvider() .enableCompileProviders() .enableInterfaceSharedObjects() @@ -165,9 +163,6 @@ public abstract class CcLibrary implements RuleConfiguredTargetFactory { } if (ruleContext.getRule().isAttrDefined("srcs", BuildType.LABEL_LIST)) { - helper.addPrivateHeaders(FileType.filter( - ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list(), - CppFileTypes.CPP_HEADER)); ruleContext.checkSrcsSamePackage(true); } if (ruleContext.getRule().isAttrDefined("textual_hdrs", BuildType.LABEL_LIST)) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java index 200edc4913..6fd24c9659 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.cpp; import com.google.common.base.Function; import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; @@ -39,6 +40,7 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfig import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode; import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType; import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; +import com.google.devtools.build.lib.util.FileTypeSet; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; @@ -67,6 +69,14 @@ import javax.annotation.Nullable; * methods. */ public final class CcLibraryHelper { + static final FileTypeSet SOURCE_TYPES = + FileTypeSet.of( + CppFileTypes.CPP_SOURCE, + CppFileTypes.CPP_HEADER, + CppFileTypes.C_SOURCE, + CppFileTypes.ASSEMBLER, + CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR); + /** Function for extracting module maps from CppCompilationDependencies. */ public static final Function CPP_DEPS_TO_MODULES = new Function() { @@ -155,7 +165,7 @@ public final class CcLibraryHelper { private final List publicTextualHeaders = new ArrayList<>(); private final List privateHeaders = new ArrayList<>(); private final List additionalExportedHeaders = new ArrayList<>(); - private final List> sources = new ArrayList<>(); + private final List> compilationUnitSources = new ArrayList<>(); private final List objectFiles = new ArrayList<>(); private final List picObjectFiles = new ArrayList<>(); private final List copts = new ArrayList<>(); @@ -214,31 +224,39 @@ public final class CcLibraryHelper { } /** - * Add the corresponding files as header files, i.e., these files will not be compiled, but are - * made visible as includes to dependent rules. + * Adds {@code headers} as public header files. These files will be made visible to dependent + * rules. They may be parsed/preprocessed or compiled into a header module depending on the + * configuration. */ public CcLibraryHelper addPublicHeaders(Collection headers) { - this.publicHeaders.addAll(headers); + for (Artifact header : headers) { + addHeader(header, ruleContext.getLabel()); + } return this; } - + /** - * Add the corresponding files as public header files, i.e., these files will not be compiled, but - * are made visible as includes to dependent rules in module maps. + * Adds {@code headers} as public header files. These files will be made visible to dependent + * rules. They may be parsed/preprocessed or compiled into a header module depending on the + * configuration. */ public CcLibraryHelper addPublicHeaders(Artifact... headers) { - return addPublicHeaders(Arrays.asList(headers)); + addPublicHeaders(Arrays.asList(headers)); + return this; } - + /** - * Add the corresponding files as private header files, i.e., these files will not be compiled, - * but are not made visible as includes to dependent rules in module maps. + * Adds {@code headers} as public header files. These files will be made visible to dependent + * rules. They may be parsed/preprocessed or compiled into a header module depending on the + * configuration. */ - public CcLibraryHelper addPrivateHeaders(Iterable privateHeaders) { - Iterables.addAll(this.privateHeaders, privateHeaders); + public CcLibraryHelper addPublicHeaders(Iterable> headers) { + for (Pair header : headers) { + addHeader(header.first, header.second); + } return this; } - + /** * Add the corresponding files as public header files, i.e., these files will not be compiled, but * are made visible as includes to dependent rules in module maps. @@ -265,10 +283,9 @@ public final class CcLibraryHelper { * Add the corresponding files as source files. These may also be header files, in which case * they will not be compiled, but also not made visible as includes to dependent rules. */ - // TODO(bazel-team): This is inconsistent with the documentation on CppModel. public CcLibraryHelper addSources(Collection sources) { for (Artifact source : sources) { - this.sources.add(Pair.of(source, ruleContext.getLabel())); + addSource(source, ruleContext.getLabel()); } return this; } @@ -277,9 +294,10 @@ public final class CcLibraryHelper { * Add the corresponding files as source files. These may also be header files, in which case * they will not be compiled, but also not made visible as includes to dependent rules. */ - // TODO(bazel-team): This is inconsistent with the documentation on CppModel. public CcLibraryHelper addSources(Iterable> sources) { - Iterables.addAll(this.sources, sources); + for (Pair source : sources) { + addSource(source.first, source.second); + } return this; } @@ -290,6 +308,50 @@ public final class CcLibraryHelper { public CcLibraryHelper addSources(Artifact... sources) { return addSources(Arrays.asList(sources)); } + + /** + * Adds a header to {@code publicHeaders} and in case header processing is switched on for the + * file type also to compilationUnitSources. + */ + private void addHeader(Artifact header, Label label) { + boolean isHeader = CppFileTypes.CPP_HEADER.matches(header.getExecPath()); + boolean isTextualInclude = CppFileTypes.CPP_TEXTUAL_INCLUDE.matches(header.getExecPath()); + publicHeaders.add(header); + if (isTextualInclude || !isHeader || !shouldProcessHeaders()) { + return; + } + compilationUnitSources.add(Pair.of(header, label)); + } + + /** + * Adds a source to {@code compilationUnitSources} if it is a compiled file type (including + * parsed/preprocessed header) and to {@code privateHeaders} if it is a header. + */ + private void addSource(Artifact source, Label label) { + boolean isHeader = CppFileTypes.CPP_HEADER.matches(source.getExecPath()); + boolean isTextualInclude = CppFileTypes.CPP_TEXTUAL_INCLUDE.matches(source.getExecPath()); + boolean isCompiledSource = SOURCE_TYPES.matches(source.getExecPathString()); + if (isHeader || isTextualInclude) { + privateHeaders.add(source); + } + if (isTextualInclude || !isCompiledSource || (isHeader && !shouldProcessHeaders())) { + return; + } + compilationUnitSources.add(Pair.of(source, label)); + } + + private boolean shouldProcessHeaders() { + return featureConfiguration.isEnabled(CppRuleClasses.PREPROCESS_HEADERS) + || featureConfiguration.isEnabled(CppRuleClasses.PARSE_HEADERS); + } + + /** + * Returns the compilation unit sources. That includes all compiled source files as well + * as headers that will be parsed or preprocessed. + */ + public ImmutableList> getCompilationUnitSources() { + return ImmutableList.copyOf(this.compilationUnitSources); + } /** * Add the corresponding files as linker inputs for non-PIC links. If the corresponding files are @@ -713,7 +775,7 @@ public final class CcLibraryHelper { */ private CppModel initializeCppModel() { return new CppModel(ruleContext, semantics) - .addSources(sources) + .addCompilationUnitSources(compilationUnitSources) .addCopts(copts) .setLinkTargetType(linkType) .setNeverLink(neverlink) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java index 1ddbff3789..91ab7d89f1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java @@ -124,9 +124,9 @@ public final class CppModel { /** * Adds a single source file to be compiled. Note that this should only be called for primary - * compilation units, not for header files or files that are otherwise included. + * compilation units, including module files or headers to be parsed or preprocessed. */ - public CppModel addSources(Iterable sourceFiles, Label sourceLabel) { + public CppModel addCompilationUnitSources(Iterable sourceFiles, Label sourceLabel) { for (Artifact sourceFile : sourceFiles) { this.sourceFiles.add(Pair.of(sourceFile, sourceLabel)); } @@ -134,10 +134,10 @@ public final class CppModel { } /** - * Adds all the source files. Note that this should only be called for primary compilation units, - * not for header files or files that are otherwise included. + * Adds all the source files. Note that this should only be called for primary + * compilation units, including module files or headers to be parsed or preprocessed. */ - public CppModel addSources(Iterable> sources) { + public CppModel addCompilationUnitSources(Iterable> sources) { Iterables.addAll(this.sourceFiles, sources); return this; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java index 0c553b2bfb..d60a62f4d9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java @@ -32,9 +32,11 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.actions.SymlinkAction; +import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.apple.DottedVersion; import com.google.devtools.build.lib.rules.cpp.CcCommon; import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.SplitArchTransition.ConfigurationDistinguisher; +import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.vfs.PathFragment; /** @@ -84,7 +86,8 @@ public class IosFramework extends ReleaseBundlingTargetFactory { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); - ImmutableList headers = ImmutableList.copyOf(CcCommon.getHeaders(ruleContext)); + ImmutableList> headers = + ImmutableList.copyOf(CcCommon.getHeaders(ruleContext)); ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); @@ -94,11 +97,11 @@ public class IosFramework extends ReleaseBundlingTargetFactory { builder.put(intermediateArtifacts.combinedArchitectureBinary(), frameworkBinary); // Create framework headers - for (Artifact header : headers) { + for (Pair header : headers) { Artifact frameworkHeader = - outputArtifact(ruleContext, new PathFragment("Headers/" + header.getFilename())); + outputArtifact(ruleContext, new PathFragment("Headers/" + header.first.getFilename())); - builder.put(header, frameworkHeader); + builder.put(header.first, frameworkHeader); } return builder.build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java index b469b22c5c..4b8412ee36 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java @@ -61,6 +61,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.cpp.CcCommon; @@ -71,6 +72,7 @@ import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.rules.cpp.CppRunfilesProvider; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.FileType; +import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; @@ -106,7 +108,11 @@ public final class ObjcCommon { if (!ruleContext.attributes().has("hdrs", BuildType.LABEL_LIST)) { return ImmutableList.of(); } - return ImmutableList.copyOf(CcCommon.getHeaders(ruleContext)); + ImmutableList.Builder headers = ImmutableList.builder(); + for (Pair header : CcCommon.getHeaders(ruleContext)) { + headers.add(header.first); + } + return headers.build(); } /** -- cgit v1.2.3