aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java55
1 files changed, 18 insertions, 37 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
index ad3c3e8c62..1ff60eb73f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.lib.rules.objc;
-import com.google.common.base.Optional;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
@@ -41,21 +40,8 @@ public final class IntermediateArtifacts {
private final RuleContext ruleContext;
private final String archiveFileNameSuffix;
- /**
- * Label to scope the output paths of generated artifacts, in addition to label of the rule that
- * is being analyzed.
- */
- private final Optional<Label> scopingLabel;
-
IntermediateArtifacts(RuleContext ruleContext, String archiveFileNameSuffix) {
this.ruleContext = ruleContext;
- this.scopingLabel = Optional.<Label>absent();
- this.archiveFileNameSuffix = Preconditions.checkNotNull(archiveFileNameSuffix);
- }
-
- IntermediateArtifacts(RuleContext ruleContext, Label scopingLabel, String archiveFileNameSuffix) {
- this.ruleContext = ruleContext;
- this.scopingLabel = Optional.of(Preconditions.checkNotNull(scopingLabel));
this.archiveFileNameSuffix = Preconditions.checkNotNull(archiveFileNameSuffix);
}
@@ -178,23 +164,9 @@ public final class IntermediateArtifacts {
inGenfiles
? ruleContext.getConfiguration().getGenfilesDirectory()
: ruleContext.getConfiguration().getBinDirectory();
- if (scopingLabel.isPresent()) {
- // The path of this artifact will be
- // RULE_PACKAGE/_intermediate_scoped/RULE_LABEL/SCOPING_PACKAGE/SCOPING_LABEL/SCOPERELATIVE
- return ruleContext.getUniqueDirectoryArtifact(
- "_intermediate_scoped",
- scopingLabel
- .get()
- .getPackageIdentifier()
- .getPathFragment()
- .getRelative(scopingLabel.get().getName())
- .getRelative(scopeRelative),
- root);
- } else {
- // The path of this artifact will be
- // RULE_PACKAGE/SCOPERELATIVE
- return ruleContext.getPackageRelativeArtifact(scopeRelative, root);
- }
+
+ // The path of this artifact will be RULE_PACKAGE/SCOPERELATIVE
+ return ruleContext.getPackageRelativeArtifact(scopeRelative, root);
}
private Artifact scopedArtifact(PathFragment scopeRelative) {
@@ -205,12 +177,8 @@ public final class IntermediateArtifacts {
* The {@code .a} file which contains all the compiled sources for a rule.
*/
public Artifact archive() {
- // If scopingLabel is present, the path will be
- // RULE_PACKAGE/_intermediate_scoped/RULE_LABEL/SCOPE_PACKAGE/SCOPE_LABEL/libRULEBASENAME.a
- //
- // If it's not, the path will be RULE_PACKAGE/libRULEBASENAME.a .
- String basename = new PathFragment(scopingLabel.isPresent()
- ? scopingLabel.get().getName() : ruleContext.getLabel().getName()).getBaseName();
+ // The path will be RULE_PACKAGE/libRULEBASENAME.a
+ String basename = new PathFragment(ruleContext.getLabel().getName()).getBaseName();
return scopedArtifact(new PathFragment(String.format(
"lib%s%s.a", basename, archiveFileNameSuffix)));
}
@@ -381,4 +349,17 @@ public final class IntermediateArtifacts {
// parent directory in the module map search paths.
return new CppModuleMap(appendExtensionInGenfiles(".modulemaps/module.modulemap"), moduleName);
}
+
+ /**
+ * Returns a static library archive with dead code/objects removed by J2ObjC dead code removal,
+ * given the original unpruned static library containing J2ObjC-translated code.
+ */
+ public Artifact j2objcPrunedArchive(Artifact unprunedArchive) {
+ PathFragment prunedSourceArtifactPath = FileSystemUtils.appendWithoutExtension(
+ unprunedArchive.getRootRelativePath(), "_pruned");
+ return ruleContext.getUniqueDirectoryArtifact(
+ "_j2objc_pruned",
+ prunedSourceArtifactPath,
+ ruleContext.getBinOrGenfilesDirectory());
+ }
}