From 7463237970f82ace1864f461034d8570fba647f2 Mon Sep 17 00:00:00 2001 From: Rumou Duan Date: Tue, 21 Feb 2017 21:21:49 +0000 Subject: Crosstool compilation support for J2ObjcAspect. Note that I also have to make some changes to cpp files to add the ability to specify a suffix for linked artifacts. This helps to avoid an artifact conflict between proto_library and J2ObjcAspect acting on proto_library, where both will create an archive file. J2ObjcAspect will simply generate a "_j2objc.a" archive instead of ".a" archive. -- PiperOrigin-RevId: 148135630 MOS_MIGRATED_REVID=148135630 --- .../build/lib/rules/objc/IntermediateArtifacts.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java') 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 e9b795b4c1..620010edd4 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 @@ -21,6 +21,7 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.cpp.CppCompileAction.DotdFile; +import com.google.devtools.build.lib.rules.cpp.CppHelper; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.FileSystemUtils; @@ -79,6 +80,13 @@ public final class IntermediateArtifacts { return artifact; } + /** + * Returns the archive file name suffix. + */ + public String archiveFileNameSuffix() { + return archiveFileNameSuffix; + } + /** * Returns the location of this target's generated entitlements file. */ @@ -243,7 +251,7 @@ public final class IntermediateArtifacts { * The {@code .a} file which contains all the compiled sources for a rule. */ public Artifact archive() { - // The path will be RULE_PACKAGE/libRULEBASENAME.a + // The path will be {RULE_PACKAGE}/lib{RULEBASENAME}{SUFFIX}.a String basename = new PathFragment(ruleContext.getLabel().getName()).getBaseName(); return scopedArtifact(new PathFragment(String.format( "lib%s%s.a", basename, archiveFileNameSuffix))); @@ -263,8 +271,7 @@ public final class IntermediateArtifacts { */ public Artifact objFile(Artifact source) { if (source.isTreeArtifact()) { - PathFragment rootRelativePath = source.getRootRelativePath().replaceName("obj_files"); - return ruleContext.getTreeArtifact(rootRelativePath, ruleContext.getBinOrGenfilesDirectory()); + return CppHelper.getCompileOutputTreeArtifact(ruleContext, source); } else { return inUniqueObjsDir(source, ".o"); } -- cgit v1.2.3