diff --git a/src/com/facebook/buck/parser/BuiltTargetVerifier.java b/src/com/facebook/buck/parser/BuiltTargetVerifier.java index ae4c07c4efc..fb5e119ba0a 100644 --- a/src/com/facebook/buck/parser/BuiltTargetVerifier.java +++ b/src/com/facebook/buck/parser/BuiltTargetVerifier.java @@ -36,6 +36,7 @@ class BuiltTargetVerifier { private static final Logger LOG = Logger.get(BuiltTargetVerifier.class); + /** @param buildFile Absolute path to build file that contains build target being verified */ void verifyBuildTarget( Cell cell, RuleType buildRuleType, diff --git a/src/com/facebook/buck/parser/RawTargetNodeFactory.java b/src/com/facebook/buck/parser/RawTargetNodeFactory.java index 0953793cbed..3fa6dee7854 100644 --- a/src/com/facebook/buck/parser/RawTargetNodeFactory.java +++ b/src/com/facebook/buck/parser/RawTargetNodeFactory.java @@ -28,8 +28,7 @@ public interface RawTargetNodeFactory { * Create new {@link RawTargetNode} * * @param cell {@Cell} object that current build target belongs to - * @param buildFile A path to a build file that has the corresponding build target; can be either - * absolute or relative, only used for displaying errors + * @param buildFile An absolute path to a build file that has the corresponding build target * @param buildTarget A build target that uniquely identifies created {@link RawTargetNode} * @param rawNode Raw attributes that forms the node, usually a Map where a key is attribute name * as string and value is attribute value as object. diff --git a/src/com/facebook/buck/parser/UnflavoredBuildTargetFactory.java b/src/com/facebook/buck/parser/UnflavoredBuildTargetFactory.java index 5b50bc83a8a..d5948c59a5d 100644 --- a/src/com/facebook/buck/parser/UnflavoredBuildTargetFactory.java +++ b/src/com/facebook/buck/parser/UnflavoredBuildTargetFactory.java @@ -29,22 +29,22 @@ public class UnflavoredBuildTargetFactory { private UnflavoredBuildTargetFactory() {} /** - * @param cellRoot root path to the cell the rule is defined in. + * @param cellRoot Absolute path to the root of the cell the rule is defined in. * @param map the map of values that define the rule. - * @param rulePathForDebug path to the build file the rule is defined in, only used for debugging. + * @param buildFilePath Absolute path to the build file the rule is defined in * @return the build target defined by the rule. */ public static UnflavoredBuildTargetView createFromRawNode( - Path cellRoot, Optional cellName, Map map, Path rulePathForDebug) { + Path cellRoot, Optional cellName, Map map, Path buildFilePath) { @Nullable String basePath = (String) map.get(InternalTargetAttributeNames.BASE_PATH); @Nullable String name = (String) map.get("name"); if (basePath == null || name == null) { throw new IllegalStateException( String.format( "Attempting to parse build target from malformed raw data in %s: %s.", - rulePathForDebug, Joiner.on(",").withKeyValueSeparator("->").join(map))); + buildFilePath, Joiner.on(",").withKeyValueSeparator("->").join(map))); } - Path otherBasePath = cellRoot.relativize(MorePaths.getParentOrEmpty(rulePathForDebug)); + Path otherBasePath = cellRoot.relativize(MorePaths.getParentOrEmpty(buildFilePath)); if (!otherBasePath.equals(otherBasePath.getFileSystem().getPath(basePath))) { throw new IllegalStateException( String.format( diff --git a/src/com/facebook/buck/parser/targetnode/BuildTargetToRawTargetNodeComputation.java b/src/com/facebook/buck/parser/targetnode/BuildTargetToRawTargetNodeComputation.java index 0910e7508ae..d537dd7344e 100644 --- a/src/com/facebook/buck/parser/targetnode/BuildTargetToRawTargetNodeComputation.java +++ b/src/com/facebook/buck/parser/targetnode/BuildTargetToRawTargetNodeComputation.java @@ -26,12 +26,14 @@ import com.facebook.buck.core.model.UnconfiguredBuildTargetView; import com.facebook.buck.core.model.impl.ImmutableUnconfiguredBuildTargetView; import com.facebook.buck.core.model.targetgraph.raw.RawTargetNode; +import com.facebook.buck.parser.ParserConfig; import com.facebook.buck.parser.RawTargetNodeFactory; import com.facebook.buck.parser.api.BuildFileManifest; import com.facebook.buck.parser.exceptions.NoSuchBuildTargetException; import com.facebook.buck.parser.manifest.BuildPackagePathToBuildFileManifestKey; import com.facebook.buck.parser.manifest.ImmutableBuildPackagePathToBuildFileManifestKey; import com.google.common.collect.ImmutableSet; +import java.nio.file.Path; import java.util.Map; import javax.annotation.Nullable; @@ -41,11 +43,16 @@ public class BuildTargetToRawTargetNodeComputation private final RawTargetNodeFactory> rawTargetNodeFactory; private final Cell cell; + private final Path buildFileName; private BuildTargetToRawTargetNodeComputation( RawTargetNodeFactory> rawTargetNodeFactory, Cell cell) { this.rawTargetNodeFactory = rawTargetNodeFactory; this.cell = cell; + buildFileName = + cell.getRoot() + .getFileSystem() + .getPath(cell.getBuckConfigView(ParserConfig.class).getBuildFileName()); } /** @@ -83,7 +90,7 @@ public RawTargetNode transform(BuildTargetToRawTargetNodeKey key, ComputationEnv return rawTargetNodeFactory.create( cell, - unconfiguredBuildTargetView.getBasePath(), + cell.getRoot().resolve(unconfiguredBuildTargetView.getBasePath()).resolve(buildFileName), unconfiguredBuildTargetView, rawAttributes); }