diff options
author | 2016-08-11 14:44:40 +0000 | |
---|---|---|
committer | 2016-08-12 08:50:54 +0000 | |
commit | f8a1ae63ed616c4579db724a4d97effb8c216ceb (patch) | |
tree | 0843a158162c246f49d10058e57427f13754c6de /src/test/java/com/google/devtools/build/lib/analysis/util | |
parent | 153e5586a0a09237119f613ce591f892adc7efe4 (diff) |
Add the repository name as a parameter to the output path functions
This doesn't do anything yet, it's in preparation for the execroot rearranging
change. The execroot will have one bazel-out per repo, so it'll look like:
execroot/
repo1/
bazel-out/
local-fastbuild/
bin/
repo2/
bazel-out/
local-fastbuild/
bin/
genfiles/
repo3/
bazel-out/
local-fastbuild/
testlogs/
and so on. Thus, any output path (getBinDirectory() & friends) needs to know
what the repo name is. This changes so many places in the code I thought it
would be good to do separately, then just flip the functionality in the
execroot-rearranging commit.
While I was poking around, I changed all of the refs I could from getPackageRelativeArtifact() to getBin/GenfilesArtifact(), so that 1) rule implementation don't have to know as much about roots and 2) they'll be more isolated from other output dir changes.
`bazel info` and similar just return roots for the main repository.
The only "change" is passing around a target label in the Java rules.
Continues work on #1262.
--
MOS_MIGRATED_REVID=129985336
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/util')
4 files changed, 46 insertions, 27 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index f7ffb7083a..030fee3edd 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -66,13 +66,11 @@ import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; - -import org.junit.Before; - import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import org.junit.Before; /** * Testing framework for tests of the analysis phase that uses the BuildView and LoadingPhaseRunner @@ -388,7 +386,7 @@ public abstract class AnalysisTestCase extends FoundationTestCase { Label label = owner.getLabel(); return buildView.getArtifactFactory().getDerivedArtifact( label.getPackageFragment().getRelative(packageRelativePath), - getTargetConfiguration().getBinDirectory(), + getTargetConfiguration().getBinDirectory(label.getPackageIdentifier().getRepository()), new ConfiguredTargetKey(owner)); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java index 1087e8c7e7..304d964fdf 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java @@ -45,6 +45,7 @@ import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Key; import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; +import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.testutil.TestConstants; @@ -408,14 +409,26 @@ public final class AnalysisTestUtil { Map<String, String> rootMap = new HashMap<>(); BuildConfiguration targetConfiguration = Iterables.getOnlyElement(configurations.getTargetConfigurations()); - rootMap.put(targetConfiguration.getBinDirectory().getPath().toString(), "bin"); - rootMap.put(targetConfiguration.getGenfilesDirectory().getPath().toString(), "genfiles"); - rootMap.put(targetConfiguration.getMiddlemanDirectory().getPath().toString(), "internal"); + rootMap.put( + targetConfiguration.getBinDirectory(RepositoryName.MAIN).getPath().toString(), + "bin"); + rootMap.put( + targetConfiguration.getGenfilesDirectory(RepositoryName.MAIN).getPath().toString(), + "genfiles"); + rootMap.put( + targetConfiguration.getMiddlemanDirectory(RepositoryName.MAIN).getPath().toString(), + "internal"); BuildConfiguration hostConfiguration = configurations.getHostConfiguration(); - rootMap.put(hostConfiguration.getBinDirectory().getPath().toString(), "bin(host)"); - rootMap.put(hostConfiguration.getGenfilesDirectory().getPath().toString(), "genfiles(host)"); - rootMap.put(hostConfiguration.getMiddlemanDirectory().getPath().toString(), "internal(host)"); + rootMap.put( + hostConfiguration.getBinDirectory(RepositoryName.MAIN).getPath().toString(), + "bin(host)"); + rootMap.put( + hostConfiguration.getGenfilesDirectory(RepositoryName.MAIN).getPath().toString(), + "genfiles(host)"); + rootMap.put( + hostConfiguration.getMiddlemanDirectory(RepositoryName.MAIN).getPath().toString(), + "internal(host)"); if (targetConfiguration.useDynamicConfigurations()) { // With dynamic configurations, the output paths that bin, genfiles, etc. refer to may diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 0197e985ba..ad82d32dfe 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -84,6 +84,7 @@ import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.PackageIdentifier; +import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -963,7 +964,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * used instead. */ protected Artifact getBinArtifactWithNoOwner(String rootRelativePath) { - return getDerivedArtifact(new PathFragment(rootRelativePath), targetConfig.getBinDirectory(), + return getDerivedArtifact(new PathFragment(rootRelativePath), + targetConfig.getBinDirectory(RepositoryName.MAIN), ActionsTestUtil.NULL_ARTIFACT_OWNER); } @@ -985,7 +987,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ protected Artifact getBinArtifact(String packageRelativePath, ConfiguredTarget owner) { return getPackageRelativeDerivedArtifact(packageRelativePath, - owner.getConfiguration().getBinDirectory(), new ConfiguredTargetKey(owner)); + owner.getConfiguration().getBinDirectory(RepositoryName.MAIN), + new ConfiguredTargetKey(owner)); } /** @@ -1019,7 +1022,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { AspectParameters parameters) { return getPackageRelativeDerivedArtifact( packageRelativePath, - owner.getConfiguration().getBinDirectory(), + owner.getConfiguration().getBinDirectory(RepositoryName.MAIN), (AspectValue.AspectKey) AspectValue.key( owner.getLabel(), @@ -1037,7 +1040,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * be "foo.o". */ private Artifact getBinArtifact(String packageRelativePath, ArtifactOwner owner) { - return getPackageRelativeDerivedArtifact(packageRelativePath, targetConfig.getBinDirectory(), + return getPackageRelativeDerivedArtifact(packageRelativePath, + targetConfig.getBinDirectory(RepositoryName.MAIN), owner); } @@ -1049,7 +1053,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ protected Artifact getGenfilesArtifactWithNoOwner(String rootRelativePath) { return getDerivedArtifact(new PathFragment(rootRelativePath), - targetConfig.getGenfilesDirectory(), ActionsTestUtil.NULL_ARTIFACT_OWNER); + targetConfig.getGenfilesDirectory(RepositoryName.MAIN), + ActionsTestUtil.NULL_ARTIFACT_OWNER); } /** @@ -1094,7 +1099,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { AspectParameters params) { return getPackageRelativeDerivedArtifact( packageRelativePath, - owner.getConfiguration().getGenfilesDirectory(), + owner.getConfiguration().getGenfilesDirectory( + owner.getTarget().getLabel().getPackageIdentifier().getRepository()), (AspectValue.AspectKey) AspectValue.key( owner.getLabel(), @@ -1125,7 +1131,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ private Artifact getGenfilesArtifact(String packageRelativePath, ArtifactOwner owner) { return getPackageRelativeDerivedArtifact(packageRelativePath, - targetConfig.getGenfilesDirectory(), + targetConfig.getGenfilesDirectory(RepositoryName.MAIN), owner); } @@ -1147,7 +1153,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ private Artifact getIncludeArtifact(String packageRelativePath, ArtifactOwner owner) { return getPackageRelativeDerivedArtifact(packageRelativePath, - targetConfig.getIncludeDirectory(), + targetConfig.getIncludeDirectory(owner.getLabel().getPackageIdentifier().getRepository()), owner); } @@ -1159,7 +1165,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * @param owner the artifact's owner. */ protected Artifact getSharedArtifact(String rootRelativePath, ConfiguredTarget owner) { - return getDerivedArtifact(new PathFragment(rootRelativePath), targetConfig.getBinDirectory(), + return getDerivedArtifact(new PathFragment(rootRelativePath), + targetConfig.getBinDirectory(RepositoryName.MAIN), new ConfiguredTargetKey(owner)); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java index 4bead55dfd..15e4e6887b 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java @@ -29,6 +29,7 @@ import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.ConfigurationFactory; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; +import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.flags.InvocationPolicyEnforcer; import com.google.devtools.build.lib.packages.PackageFactory; import com.google.devtools.build.lib.packages.Preprocessor; @@ -49,16 +50,14 @@ import com.google.devtools.common.options.Option; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParser; - -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Testing framework for tests which check ConfigurationFactory. @@ -179,12 +178,14 @@ public abstract class ConfigurationTestCase extends FoundationTestCase { Map<Root, BuildConfiguration> outputPaths = new HashMap<>(); for (BuildConfiguration config : allConfigs) { if (config.isActionsEnabled()) { - BuildConfiguration otherConfig = outputPaths.get(config.getOutputDirectory()); + BuildConfiguration otherConfig = outputPaths.get( + config.getOutputDirectory(RepositoryName.MAIN)); if (otherConfig != null) { - throw new IllegalStateException("The output path '" + config.getOutputDirectory() + throw new IllegalStateException("The output path '" + + config.getOutputDirectory(RepositoryName.MAIN) + "' is the same for configurations '" + config + "' and '" + otherConfig + "'"); } else { - outputPaths.put(config.getOutputDirectory(), config); + outputPaths.put(config.getOutputDirectory(RepositoryName.MAIN), config); } } } |