diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 6083793a90ba22..c6cd8a3dfdb1f6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -403,18 +403,17 @@ public LipoModeConverter() { public Label customMalloc; @Option( - name = "experimental_shortened_obj_file_path", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, - effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.AFFECTS_OUTPUTS}, - help = - "When off, object files are generated at _objs///" - + ".o, otherwise they are shortened to _objs//" - + ".o. If there are multiple source files with the same base name, " - + "to avoid conflict, the object file path is _objs//" - + "/.o, where N = the source file's order among all source files " - + "with the same base name, N starts with 0." - ) + name = "experimental_shortened_obj_file_path", + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, + effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.AFFECTS_OUTPUTS}, + help = + "When off, object files are generated at _objs///" + + ".o, otherwise they are shortened to _objs//" + + ".o. If there are multiple source files with the same base name, " + + "to avoid conflict, the object file path is _objs//" + + "/.o, where N = the source file's order among all source files " + + "with the same base name, N starts with 0.") public boolean shortenObjFilePath; @Option( diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java index bca66c2e49c5af..41968ff2404d3d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisCachingTest.java @@ -139,13 +139,14 @@ public void testActionConflictInDependencyImpliesTopLevelTargetFailure() throws return; } useConfiguration("--cpu=k8"); - scratch.file("conflict/BUILD", + scratch.file( + "conflict/BUILD", "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])", - "cc_binary(name='foo', deps=['x'], data=['_objs/x/conflict/foo.pic.o'])"); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])", + "cc_binary(name='foo', deps=['x'], data=['_objs/x/foo.pic.o'])"); reporter.removeHandler(failFastHandler); // expect errors update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:foo"); - assertContainsEvent("file 'conflict/_objs/x/conflict/foo.pic.o' " + CONFLICT_MSG); + assertContainsEvent("file 'conflict/_objs/x/foo.pic.o' " + CONFLICT_MSG); assertThat(getAnalysisResult().getTargetsToBuild()).isEmpty(); } @@ -161,22 +162,23 @@ public void testActionConflictInDependencyImpliesTopLevelTargetFailure() throws @Test public void testNoActionConflictWithInvalidatedTarget() throws Exception { useConfiguration("--cpu=k8"); - scratch.file("conflict/BUILD", + scratch.file( + "conflict/BUILD", "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.o', srcs=['bar.cc'])"); + "cc_binary(name='_objs/x/foo.o', srcs=['bar.cc'])"); update("//conflict:x"); ConfiguredTarget conflict = getConfiguredTarget("//conflict:x"); - Action oldAction = getGeneratingAction(getBinArtifact("_objs/x/conflict/foo.pic.o", conflict)); + Action oldAction = getGeneratingAction(getBinArtifact("_objs/x/foo.pic.o", conflict)); assertThat(oldAction.getOwner().getLabel().toString()).isEqualTo("//conflict:x"); - scratch.overwriteFile("conflict/BUILD", + scratch.overwriteFile( + "conflict/BUILD", "cc_library(name='newx', srcs=['foo.cc'])", // Rename target. - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); - update(defaultFlags(), "//conflict:_objs/x/conflict/foo.pic.o"); - ConfiguredTarget objsConflict = getConfiguredTarget("//conflict:_objs/x/conflict/foo.pic.o"); - Action newAction = - getGeneratingAction(getBinArtifact("_objs/x/conflict/foo.pic.o", objsConflict)); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); + update(defaultFlags(), "//conflict:_objs/x/foo.pic.o"); + ConfiguredTarget objsConflict = getConfiguredTarget("//conflict:_objs/x/foo.pic.o"); + Action newAction = getGeneratingAction(getBinArtifact("_objs/x/foo.pic.o", objsConflict)); assertThat(newAction.getOwner().getLabel().toString()) - .isEqualTo("//conflict:_objs/x/conflict/foo.pic.o"); + .isEqualTo("//conflict:_objs/x/foo.pic.o"); } /** @@ -189,13 +191,13 @@ public void testActionConflictCausesError() throws Exception { return; } useConfiguration("--cpu=k8"); - scratch.file("conflict/BUILD", + scratch.file( + "conflict/BUILD", "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); reporter.removeHandler(failFastHandler); // expect errors - update(defaultFlags().with(Flag.KEEP_GOING), - "//conflict:x", "//conflict:_objs/x/conflict/foo.pic.o"); - assertContainsEvent("file 'conflict/_objs/x/conflict/foo.pic.o' " + CONFLICT_MSG); + update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:_objs/x/foo.pic.o"); + assertContainsEvent("file 'conflict/_objs/x/foo.pic.o' " + CONFLICT_MSG); } @Test @@ -205,23 +207,23 @@ public void testNoActionConflictErrorAfterClearedAnalysis() throws Exception { return; } useConfiguration("--cpu=k8"); - scratch.file("conflict/BUILD", - "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); + scratch.file( + "conflict/BUILD", + "cc_library(name='x', srcs=['foo.cc'])", + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); reporter.removeHandler(failFastHandler); // expect errors - update(defaultFlags().with(Flag.KEEP_GOING), - "//conflict:x", "//conflict:_objs/x/conflict/foo.pic.o"); + update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:_objs/x/foo.pic.o"); // We want to force a "dropConfiguredTargetsNow" operation, which won't inform the // invalidation receiver about the dropped configured targets. skyframeExecutor.clearAnalysisCache( ImmutableList.of(), ImmutableSet.of()); - assertContainsEvent("file 'conflict/_objs/x/conflict/foo.pic.o' " + CONFLICT_MSG); + assertContainsEvent("file 'conflict/_objs/x/foo.pic.o' " + CONFLICT_MSG); eventCollector.clear(); - scratch.overwriteFile("conflict/BUILD", + scratch.overwriteFile( + "conflict/BUILD", "cc_library(name='x', srcs=['baz.cc'])", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); - update(defaultFlags().with(Flag.KEEP_GOING), - "//conflict:x", "//conflict:_objs/x/conflict/foo.pic.o"); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); + update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:_objs/x/foo.pic.o"); assertNoEvents(); } @@ -239,14 +241,11 @@ public void testConflictingArtifactsErrorWithNoListDetail() throws Exception { scratch.file( "conflict/BUILD", "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); reporter.removeHandler(failFastHandler); // expect errors - update( - defaultFlags().with(Flag.KEEP_GOING), - "//conflict:x", - "//conflict:_objs/x/conflict/foo.pic.o"); + update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:_objs/x/foo.pic.o"); - assertContainsEvent("file 'conflict/_objs/x/conflict/foo.pic.o' " + CONFLICT_MSG); + assertContainsEvent("file 'conflict/_objs/x/foo.pic.o' " + CONFLICT_MSG); assertDoesNotContainEvent("MandatoryInputs"); assertDoesNotContainEvent("Outputs"); } @@ -266,13 +265,12 @@ public void testConflictingArtifactsWithListDetail() throws Exception { "conflict/BUILD", "cc_library(name='x', srcs=['foo1.cc', 'foo2.cc', 'foo3.cc', 'foo4.cc', 'foo5.cc'" + ", 'foo6.cc'])", - "genrule(name = 'foo', outs=['_objs/x/conflict/foo1.pic.o'], srcs=['foo1.cc', 'foo2.cc', " + "genrule(name = 'foo', outs=['_objs/x/foo1.pic.o'], srcs=['foo1.cc', 'foo2.cc', " + "'foo3.cc', 'foo4.cc', 'foo5.cc', 'foo6.cc'], cmd='', output_to_bindir=1)"); reporter.removeHandler(failFastHandler); // expect errors update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:foo"); - Event event = - assertContainsEvent("file 'conflict/_objs/x/conflict/foo1.pic.o' " + CONFLICT_MSG); + Event event = assertContainsEvent("file 'conflict/_objs/x/foo1.pic.o' " + CONFLICT_MSG); assertContainsEvent("MandatoryInputs"); assertContainsEvent("Outputs"); @@ -298,15 +296,13 @@ public void testActionConflictMarksTargetInvalid() throws Exception { return; } useConfiguration("--cpu=k8"); - scratch.file("conflict/BUILD", + scratch.file( + "conflict/BUILD", "cc_library(name='x', srcs=['foo.cc'])", - "cc_binary(name='_objs/x/conflict/foo.o', srcs=['bar.cc'])"); + "cc_binary(name='_objs/x/foo.o', srcs=['bar.cc'])"); reporter.removeHandler(failFastHandler); // expect errors int successfulAnalyses = - update( - defaultFlags().with(Flag.KEEP_GOING), - "//conflict:x", - "//conflict:_objs/x/conflict/foo.pic.o") + update(defaultFlags().with(Flag.KEEP_GOING), "//conflict:x", "//conflict:_objs/x/foo.pic.o") .getTargetsToBuild() .size(); assertThat(successfulAnalyses).isEqualTo(1); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java index 5ef5bf58f3ab2e..bcec2c7eb2f900 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java @@ -932,18 +932,18 @@ public void testPostProcessedConfigurableAttributes() throws Exception { } useConfiguration("--cpu=k8"); reporter.removeHandler(failFastHandler); // Expect errors from action conflicts. - scratch.file("conflict/BUILD", + scratch.file( + "conflict/BUILD", "config_setting(name = 'a', values = {'test_arg': 'a'})", "cc_library(name='x', srcs=select({':a': ['a.cc'], '//conditions:default': ['foo.cc']}))", - "cc_binary(name='_objs/x/conflict/foo.pic.o', srcs=['bar.cc'])"); - AnalysisResult result = update( - defaultFlags().with(Flag.KEEP_GOING), - "//conflict:_objs/x/conflict/foo.pic.o", - "//conflict:x"); + "cc_binary(name='_objs/x/foo.pic.o', srcs=['bar.cc'])"); + AnalysisResult result = + update( + defaultFlags().with(Flag.KEEP_GOING), "//conflict:_objs/x/foo.pic.o", "//conflict:x"); assertThat(result.hasError()).isTrue(); // Expect to reach this line without a Precondition-triggered NullPointerException. assertContainsEvent( - "file 'conflict/_objs/x/conflict/foo.pic.o' is generated by these conflicting actions"); + "file 'conflict/_objs/x/foo.pic.o' is generated by these conflicting actions"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/rules/ToolchainTypeTest.java b/src/test/java/com/google/devtools/build/lib/rules/ToolchainTypeTest.java index 2aef6469f84804..c602441cb4b3d3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/ToolchainTypeTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/ToolchainTypeTest.java @@ -101,7 +101,7 @@ public void testCcTargetsDependOnCcToolchainAutomatically() throws Exception { .setList("copts", "foobar-$(ABI)") .write(); CppCompileAction compileAction = - (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/cclib/cclib/a.o", cclibrary)); + (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/cclib/a.o", cclibrary)); assertThat(compileAction.getArguments()).contains("foobar-banana"); ConfiguredTarget ccbinary = @@ -110,7 +110,7 @@ public void testCcTargetsDependOnCcToolchainAutomatically() throws Exception { .setList("copts", "foobar-$(ABI)") .write(); compileAction = - (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/ccbin/ccbin/a.o", ccbinary)); + (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/ccbin/a.o", ccbinary)); assertThat(compileAction.getArguments()).contains("foobar-banana"); ConfiguredTarget cctest = @@ -119,7 +119,7 @@ public void testCcTargetsDependOnCcToolchainAutomatically() throws Exception { .setList("copts", "foobar-$(ABI)") .write(); compileAction = - (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/cctest/cctest/a.o", cctest)); + (CppCompileAction) getGeneratingAction(getBinArtifact("_objs/cctest/a.o", cctest)); assertThat(compileAction.getArguments()).contains("foobar-banana"); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index eaad85b72098b5..40aa189fa865a9 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -485,7 +485,7 @@ public void testWindowsFileNamePatternsCanBeSpecifiedInToolchain() throws Except useConfiguration(); ConfiguredTarget hello = getConfiguredTarget("//hello:hello"); - Artifact helloObj = getBinArtifact("_objs/hello/hello/hello.obj", "//hello:hello"); + Artifact helloObj = getBinArtifact("_objs/hello/hello.obj", "//hello:hello"); CppCompileAction helloObjAction = (CppCompileAction) getGeneratingAction(helloObj); assertThat(helloObjAction).isNotNull(); @@ -569,17 +569,15 @@ public void testArtifactsToAlwaysBuild() throws Exception { useConfiguration("--cpu=k8"); // ArtifactsToAlwaysBuild should apply both for static libraries. ConfiguredTarget helloStatic = getConfiguredTarget("//hello:hello_static"); - assertThat( - artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL))) - .containsExactly("bin hello/_objs/hello_static/hello/hello.pic.o"); + assertThat(artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL))) + .containsExactly("bin hello/_objs/hello_static/hello.pic.o"); Artifact implSharedObject = getBinArtifact("libhello_static.so", helloStatic); assertThat(getFilesToBuild(helloStatic)).doesNotContain(implSharedObject); // And for shared libraries. ConfiguredTarget hello = getConfiguredTarget("//hello:hello"); - assertThat( - artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL))) - .containsExactly("bin hello/_objs/hello_static/hello/hello.pic.o"); + assertThat(artifactsToStrings(getOutputGroup(helloStatic, OutputGroupInfo.HIDDEN_TOP_LEVEL))) + .containsExactly("bin hello/_objs/hello_static/hello.pic.o"); implSharedObject = getBinArtifact("libhello.so", hello); assertThat(getFilesToBuild(hello)).contains(implSharedObject); } @@ -594,9 +592,7 @@ public void testTransitiveArtifactsToAlwaysBuildStatic() throws Exception { "cc_library(name = 'z', srcs = ['z.cc'])"); assertThat(artifactsToStrings(getOutputGroup(x, OutputGroupInfo.HIDDEN_TOP_LEVEL))) .containsExactly( - "bin foo/_objs/x/foo/x.pic.o", - "bin foo/_objs/y/foo/y.pic.o", - "bin foo/_objs/z/foo/z.pic.o"); + "bin foo/_objs/x/x.pic.o", "bin foo/_objs/y/y.pic.o", "bin foo/_objs/z/z.pic.o"); } @Test @@ -725,7 +721,7 @@ public void testCompileHeaderModules() throws Exception { " textual_hdrs = ['t.h'],", ")"); getConfiguredTarget("//module:b"); - Artifact bModuleArtifact = getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b"); + Artifact bModuleArtifact = getBinArtifact("_objs/b/b.pic.pcm", "//module:b"); CppCompileAction bModuleAction = (CppCompileAction) getGeneratingAction(bModuleArtifact); assertThat(bModuleAction.getIncludeScannerSources()).containsExactly( getSourceArtifact("module/b.h"), getSourceArtifact("module/t.h")); @@ -733,12 +729,12 @@ public void testCompileHeaderModules() throws Exception { getGenfilesArtifactWithNoOwner("module/b.cppmap")); getConfiguredTarget("//module:a"); - Artifact aObjectArtifact = getBinArtifact("_objs/a/module/a.pic.o", "//module:a"); + Artifact aObjectArtifact = getBinArtifact("_objs/a/a.pic.o", "//module:a"); CppCompileAction aObjectAction = (CppCompileAction) getGeneratingAction(aObjectArtifact); assertThat(aObjectAction.getIncludeScannerSources()).containsExactly( getSourceArtifact("module/a.cc")); assertThat(aObjectAction.getCcCompilationContext().getTransitiveModules(true)) - .contains(getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b")); + .contains(getBinArtifact("_objs/b/b.pic.pcm", "//module:b")); assertThat(aObjectAction.getInputs()).contains( getGenfilesArtifactWithNoOwner("module/b.cppmap")); assertNoEvents(); @@ -883,9 +879,8 @@ public void testCompileHeaderModulesTransitively() throws Exception { // The //nomodule:f target only depends on non-module targets, thus it should be module-free. getConfiguredTarget("//nomodule:f"); - assertThat(getGeneratingAction(getBinArtifact("_objs/f/nomodule/f.pic.pcm", "//nomodule:f"))) - .isNull(); - Artifact fObjectArtifact = getBinArtifact("_objs/f/nomodule/f.pic.o", "//nomodule:f"); + assertThat(getGeneratingAction(getBinArtifact("_objs/f/f.pic.pcm", "//nomodule:f"))).isNull(); + Artifact fObjectArtifact = getBinArtifact("_objs/f/f.pic.o", "//nomodule:f"); CppCompileAction fObjectAction = (CppCompileAction) getGeneratingAction(fObjectArtifact); // Only the module map of f itself itself and the direct dependencies are needed. assertThat(getNonSystemModuleMaps(fObjectAction.getInputs())).containsExactly( @@ -899,9 +894,8 @@ public void testCompileHeaderModulesTransitively() throws Exception { // The //nomodule:c target will get the header module for //module:b, which is a direct // dependency. getConfiguredTarget("//nomodule:c"); - assertThat(getGeneratingAction(getBinArtifact("_objs/c/nomodule/c.pic.pcm", "//nomodule:c"))) - .isNull(); - Artifact cObjectArtifact = getBinArtifact("_objs/c/nomodule/c.pic.o", "//nomodule:c"); + assertThat(getGeneratingAction(getBinArtifact("_objs/c/c.pic.pcm", "//nomodule:c"))).isNull(); + Artifact cObjectArtifact = getBinArtifact("_objs/c/c.pic.o", "//nomodule:c"); CppCompileAction cObjectAction = (CppCompileAction) getGeneratingAction(cObjectArtifact); assertThat(getNonSystemModuleMaps(cObjectAction.getInputs())).containsExactly( getGenfilesArtifact("b.cppmap", "//module:b"), @@ -917,9 +911,8 @@ public void testCompileHeaderModulesTransitively() throws Exception { // The //nomodule:d target depends on //module:b via one indirection (//nomodule:c). getConfiguredTarget("//nomodule:d"); - assertThat(getGeneratingAction(getBinArtifact("_objs/d/nomodule/d.pic.pcm", "//nomodule:d"))) - .isNull(); - Artifact dObjectArtifact = getBinArtifact("_objs/d/nomodule/d.pic.o", "//nomodule:d"); + assertThat(getGeneratingAction(getBinArtifact("_objs/d/d.pic.pcm", "//nomodule:d"))).isNull(); + Artifact dObjectArtifact = getBinArtifact("_objs/d/d.pic.o", "//nomodule:d"); CppCompileAction dObjectAction = (CppCompileAction) getGeneratingAction(dObjectArtifact); // Module map 'c.cppmap' is needed because it is a direct dependency. assertThat(getNonSystemModuleMaps(dObjectAction.getInputs())).containsExactly( @@ -933,20 +926,20 @@ public void testCompileHeaderModulesTransitively() throws Exception { // The //module:j target depends on //module:g via //nomodule:h and on //module:b via // both //module:g and //nomodule:c. getConfiguredTarget("//module:j"); - Artifact jObjectArtifact = getBinArtifact("_objs/j/module/j.pic.o", "//module:j"); + Artifact jObjectArtifact = getBinArtifact("_objs/j/j.pic.o", "//module:j"); CppCompileAction jObjectAction = (CppCompileAction) getGeneratingAction(jObjectArtifact); assertThat(getHeaderModules(jObjectAction.getCcCompilationContext().getTransitiveModules(true))) .containsExactly( - getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b"), - getBinArtifact("_objs/g/module/g.pic.pcm", "//module:g")); + getBinArtifact("_objs/b/b.pic.pcm", "//module:b"), + getBinArtifact("_objs/g/g.pic.pcm", "//module:g")); assertThat(jObjectAction.getIncludeScannerSources()).containsExactly( getSourceArtifact("module/j.cc")); assertThat(jObjectAction.getMainIncludeScannerSource()).isEqualTo( getSourceArtifact("module/j.cc")); assertThat(getHeaderModules(jObjectAction.getCcCompilationContext().getTransitiveModules(true))) .containsExactly( - getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b"), - getBinArtifact("_objs/g/module/g.pic.pcm", "//module:g")); + getBinArtifact("_objs/b/b.pic.pcm", "//module:b"), + getBinArtifact("_objs/g/g.pic.pcm", "//module:g")); } @Test @@ -958,7 +951,7 @@ public void testCompileUsingHeaderModulesTransitively() throws Exception { setupPackagesForModuleTests( /*useHeaderModules=*/true); getConfiguredTarget("//nomodule:f"); - Artifact fObjectArtifact = getBinArtifact("_objs/f/nomodule/f.pic.o", "//nomodule:f"); + Artifact fObjectArtifact = getBinArtifact("_objs/f/f.pic.o", "//nomodule:f"); CppCompileAction fObjectAction = (CppCompileAction) getGeneratingAction(fObjectArtifact); // Only the module map of f itself itself and the direct dependencies are needed. assertThat(getNonSystemModuleMaps(fObjectAction.getInputs())) @@ -967,24 +960,24 @@ public void testCompileUsingHeaderModulesTransitively() throws Exception { getGenfilesArtifact("e.cppmap", "//nomodule:e")); getConfiguredTarget("//nomodule:c"); - Artifact cObjectArtifact = getBinArtifact("_objs/c/nomodule/c.pic.o", "//nomodule:c"); + Artifact cObjectArtifact = getBinArtifact("_objs/c/c.pic.o", "//nomodule:c"); CppCompileAction cObjectAction = (CppCompileAction) getGeneratingAction(cObjectArtifact); assertThat(getNonSystemModuleMaps(cObjectAction.getInputs())) .containsExactly( getGenfilesArtifact("b.cppmap", "//module:b"), getGenfilesArtifact("c.cppmap", "//nomodule:e")); assertThat(getHeaderModules(cObjectAction.getCcCompilationContext().getTransitiveModules(true))) - .containsExactly(getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b")); + .containsExactly(getBinArtifact("_objs/b/b.pic.pcm", "//module:b")); getConfiguredTarget("//nomodule:d"); - Artifact dObjectArtifact = getBinArtifact("_objs/d/nomodule/d.pic.o", "//nomodule:d"); + Artifact dObjectArtifact = getBinArtifact("_objs/d/d.pic.o", "//nomodule:d"); CppCompileAction dObjectAction = (CppCompileAction) getGeneratingAction(dObjectArtifact); assertThat(getNonSystemModuleMaps(dObjectAction.getInputs())) .containsExactly( getGenfilesArtifact("c.cppmap", "//nomodule:c"), getGenfilesArtifact("d.cppmap", "//nomodule:d")); assertThat(getHeaderModules(dObjectAction.getCcCompilationContext().getTransitiveModules(true))) - .containsExactly(getBinArtifact("_objs/b/module/b.pic.pcm", "//module:b")); + .containsExactly(getBinArtifact("_objs/b/b.pic.pcm", "//module:b")); } private void writeSimpleCcLibrary() throws Exception { @@ -1097,7 +1090,7 @@ public void testDoNotCompileSourceFilesInHeaders() throws Exception { useConfiguration("--features=parse_headers"); ConfiguredTarget x = scratchConfiguredTarget("x", "x", "cc_library(name = 'x', hdrs = ['x.cc'])"); - assertThat(getGeneratingAction(getBinArtifact("_objs/x/x/x.pic.o", x))).isNull(); + assertThat(getGeneratingAction(getBinArtifact("_objs/x/.pic.o", x))).isNull(); } @Test @@ -1259,7 +1252,7 @@ private List getCompilationModeFlags(String... flags) throws Exception { useConfiguration(flags); scratch.overwriteFile("mode/BUILD", "cc_library(name = 'a', srcs = ['a.cc'])"); getConfiguredTarget("//mode:a"); - Artifact objectArtifact = getBinArtifact("_objs/a/mode/a.pic.o", "//mode:a"); + Artifact objectArtifact = getBinArtifact("_objs/a/a.pic.o", "//mode:a"); CppCompileAction action = (CppCompileAction) getGeneratingAction(objectArtifact); return action.getCompilerOptions(); } @@ -1294,10 +1287,10 @@ private List getHostAndTargetFlags(boolean useHost) throws Exception { String objectPath; if (useHost) { target = getHostConfiguredTarget("//mode:a"); - objectPath = "_objs/a/mode/a.o"; + objectPath = "_objs/a/a.o"; } else { target = getConfiguredTarget("//mode:a"); - objectPath = "_objs/a/mode/a.pic.o"; + objectPath = "_objs/a/a.pic.o"; } Artifact objectArtifact = getBinArtifact(objectPath, target); CppCompileAction action = (CppCompileAction) getGeneratingAction(objectArtifact); diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java index 0c1db362c11fe8..8f299b1cd4506d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java @@ -62,7 +62,7 @@ public void testPresenceOfBasicVariables() throws Exception { assertThat(variables.getStringVariable(CompileBuildVariables.SOURCE_FILE.getVariableName())) .contains("x/bin.cc"); assertThat(variables.getStringVariable(CompileBuildVariables.OUTPUT_FILE.getVariableName())) - .contains("x/bin"); + .contains("_objs/bin/bin"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java index 3997a4dad6dec7..33ad7f4d013fa0 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java @@ -250,7 +250,7 @@ public void testCompilesTestSourcesIntoDynamicLibrary() throws Exception { configuredTarget = getConfiguredTarget("//x:b"); linkAction = (CppLinkAction) getGeneratingAction(configuredTarget, "x/b"); - assertThat(artifactsToStrings(linkAction.getInputs())).contains("bin x/_objs/b/x/a.pic.o"); + assertThat(artifactsToStrings(linkAction.getInputs())).contains("bin x/_objs/b/a.pic.o"); runfilesProvider = configuredTarget.getProvider(RunfilesProvider.class); assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts())) .containsExactly("bin x/b"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java index 874bf638a0c0c7..cabbb2da8251b2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java @@ -163,13 +163,13 @@ public void testNoIfsoBuildingWhenWhenThinLtoIndexing() throws Exception { LtoBackendAction backendAction = (LtoBackendAction) - getPredecessorByInputName(linkAction, "x/libfoo.so.lto/x/_objs/foo/x/a.pic.o"); + getPredecessorByInputName(linkAction, "x/libfoo.so.lto/x/_objs/foo/a.pic.o"); assertThat(backendAction.getMnemonic()).isEqualTo("CcLtoBackendCompile"); CppLinkAction indexAction = (CppLinkAction) getPredecessorByInputName( - backendAction, "x/libfoo.so.lto/x/_objs/foo/x/a.pic.o.thinlto.bc"); + backendAction, "x/libfoo.so.lto/x/_objs/foo/a.pic.o.thinlto.bc"); CcToolchainVariables variables = indexAction.getLinkCommandLine().getBuildVariables(); String interfaceLibraryBuilder = @@ -256,13 +256,13 @@ public void testOutputExecpathIsNotExposedWhenThinLtoIndexing() throws Exception LtoBackendAction backendAction = (LtoBackendAction) - getPredecessorByInputName(linkAction, "x/libfoo.so.lto/x/_objs/foo/x/a.pic.o"); + getPredecessorByInputName(linkAction, "x/libfoo.so.lto/x/_objs/foo/a.pic.o"); assertThat(backendAction.getMnemonic()).isEqualTo("CcLtoBackendCompile"); CppLinkAction indexAction = (CppLinkAction) getPredecessorByInputName( - backendAction, "x/libfoo.so.lto/x/_objs/foo/x/a.pic.o.thinlto.bc"); + backendAction, "x/libfoo.so.lto/x/_objs/foo/a.pic.o.thinlto.bc"); CcToolchainVariables variables = indexAction.getLinkCommandLine().getBuildVariables(); assertThat(variables.isAvailable(LinkBuildVariables.OUTPUT_EXECPATH.getVariableName())) diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java index 0120bfc260d64d..310129c862f0f3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java @@ -1169,9 +1169,7 @@ public void testCompileActionTemplateFromGenJar() throws Exception { assertThat(objectFilesFromGenJar.isTreeArtifact()).isTrue(); assertThat(objectFilesFromGenJar.getRootRelativePathString()) - .isEqualTo( - "java/com/google/app/test/_objs/test/java/com/google/app/test/_j2objc/" - + "src_jar_files/test/source_files"); + .isEqualTo("java/com/google/app/test/_objs/test/non_arc/source_files"); ActionAnalysisMetadata actionTemplate = getActionGraph().getGeneratingAction(objectFilesFromGenJar); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java index f8f21a33b2f37f..75153651bfbabd 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java @@ -118,7 +118,7 @@ public void testCompilesSources() throws Exception { assertThat(Artifact.toRootRelativePaths(compileA.getPossibleInputsForTesting())) .containsAllOf("objc/a.m", "objc/hdr.h", "objc/private.h"); assertThat(Artifact.toRootRelativePaths(compileA.getOutputs())) - .containsExactly("objc/_objs/x/objc/a.o", "objc/_objs/x/objc/a.d"); + .containsExactly("objc/_objs/x/arc/a.o", "objc/_objs/x/arc/a.d"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java index 9cd6af4362bda2..82d9906a7744ee 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java @@ -734,7 +734,7 @@ protected Iterable getExpandedActionInputs(Action action) { private void assertCoptsAndDefinesNotPropagatedToProtos(ConfiguredTarget topTarget) throws Exception { Artifact protoObject = - getBinArtifact("_objs/x/x/_generated_protos/x/protos/DataA.pbobjc.o", topTarget); + getBinArtifact("_objs/x/non_arc/DataA.pbobjc.o", topTarget); CommandAction protoObjectAction = (CommandAction) getGeneratingAction(protoObject); assertThat(protoObjectAction).isNotNull(); assertThat(protoObjectAction.getArguments())