aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-08-24 09:42:38 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-08-24 14:03:00 +0000
commit7dbc083c7852c9cb51c91ad1f867d3e89b7c3da1 (patch)
treee13f699e192f4249495b6708b15c5fb6269b389a
parentb742f1844ec837f9feeec7b5a9e4bfa2a86f1301 (diff)
ctx.new_file(Artifact, String) now replaces the basename of the base artifact with the given name instead of appending a suffix
-- MOS_MIGRATED_REVID=101348273
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
index 4650e91873..93ff5aa416 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
@@ -399,17 +399,19 @@ public final class SkylarkRuleContext {
}
@SkylarkCallable(doc =
- "Creates a new file object, derived from the given file and suffix. " + DOC_NEW_FILE_TAIL)
+ "Creates a new file object, derived from the given file and suffix. " + DOC_NEW_FILE_TAIL
+ + " Deprecated.")
public Artifact newFileSuffix(Artifact baseArtifact, String suffix) {
- return newFile(baseArtifact, suffix);
+ return newFile(baseArtifact, baseArtifact.getRootRelativePath().getBaseName() + suffix);
}
@SkylarkCallable(doc =
- "Creates a new file object, derived from the given file and suffix. " + DOC_NEW_FILE_TAIL
- + " Deprecated: Please use ctx.new_file_suffix() instead.")
- public Artifact newFile(Artifact baseArtifact, String suffix) {
+ "Creates a new file object in the same directory as the original file. "
+ + DOC_NEW_FILE_TAIL)
+
+ public Artifact newFile(Artifact baseArtifact, String newBaseName) {
PathFragment original = baseArtifact.getRootRelativePath();
- PathFragment fragment = original.replaceName(original.getBaseName() + suffix);
+ PathFragment fragment = original.replaceName(newBaseName);
Root root = ruleContext.getBinOrGenfilesDirectory();
return ruleContext.getDerivedArtifact(fragment, root);
}