diff options
author | 2015-08-21 14:04:40 +0000 | |
---|---|---|
committer | 2015-08-24 14:01:50 +0000 | |
commit | 98317a35a4c005386cb7f4595cf0917281d0c312 (patch) | |
tree | fc6aeed6a7ae7153e71b5c21b80c45c136423191 /src/main/java/com/google/devtools/build/lib/rules/nativedeps | |
parent | b336aa30f6fe575b54b0bc156f45e5734a56c4b5 (diff) |
Abstract away artifact creation in CppLinkAction so that we can create most of the artifacts in a way that checks that they are under the package directory.
The exception is nativedeps, whose link actions are shared, and thus they cannot be at a package-specific location.
--
MOS_MIGRATED_REVID=101216949
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/nativedeps')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java index e808eb538b..0a509cd722 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java @@ -52,6 +52,21 @@ import java.util.Map; * that some rules are implicitly neverlink. */ public abstract class NativeDepsHelper { + /** + * An implementation of {@link CppLinkAction.LinkArtifactFactory} that can create artifacts + * anywhere. + * + * <p>Necessary because the actions of nativedeps libraries should be shareable, and thus cannot + * be under the package directory. + */ + private static final CppLinkAction.LinkArtifactFactory SHAREABLE_LINK_ARTIFACT_FACTORY = + new CppLinkAction.LinkArtifactFactory() { + @Override + public Artifact create(RuleContext ruleContext, PathFragment rootRelativePath) { + return ruleContext.getShareableArtifact(rootRelativePath, + ruleContext.getConfiguration().getBinDirectory()); + } + }; private NativeDepsHelper() {} @@ -157,6 +172,7 @@ public abstract class NativeDepsHelper { linkerOutputPath, configuration.getBinDirectory()); CppLinkAction.Builder builder = new CppLinkAction.Builder( ruleContext, sharedLibrary, configuration, toolchain); + builder.setLinkArtifactFactory(SHAREABLE_LINK_ARTIFACT_FACTORY); CppLinkAction linkAction = builder .setCrosstoolInputs(toolchain.getLink()) .addLibraries(linkerInputs) |