aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
diff options
context:
space:
mode:
authorGravatar pcloudy <pcloudy@google.com>2018-03-23 07:05:17 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-23 07:07:18 -0700
commitbb9ae6a174b8cd255a62249f01919426f1d817f8 (patch)
treef21cc2f6ff0f6ca6937eefa585bfb5ca8b4e6678 /src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
parent8f5327af7940dc46f04acfe07448256dca164006 (diff)
Shorten object file path
Closes #4781. Fix https://github.com/bazelbuild/bazel/issues/4149 RELNOTES: Users can now pass --experimental_shortened_obj_file_path=true to have a shorter object file path, the object file paths (and all other related paths) will be constructed as following: If there's no two or more source files with the same base name: <bazel-bin>/<target_package_path>/_objs/<target_name>/<source_base_name>.<extension> otherwise: <bazel-bin>/<target_package_path>/_objs/<target_name>/N/<source_base_name>.<extension> N = the file?s order among the source files with the same basename, starts from 0. Examples: 1. Output names for ["lib1/foo.cc", "lib2/bar.cc"] are ["foo", "bar"] 2. Output names for ["foo.cc", "bar.cc", "foo.cpp", "lib/foo.cc"] are ["0/foo", "bar", "1/foo", "2/foo"] The default value of --experimental_shortened_obj_file_path option is false, but we plan to flip it to true and eventually remove this option. You shouldn't depend on the format of generated object file path, but if you do and this change breaks you, please use --experimental_shortened_obj_file_path=false to work around it. PiperOrigin-RevId: 190214375
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java52
1 files changed, 52 insertions, 0 deletions
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 8bb93d66f8..8226bc1bc8 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
@@ -123,6 +123,58 @@ public class ObjcLibraryTest extends ObjcRuleTestCase {
}
@Test
+ public void testCompilesSourcesWithSameBaseNameWithNewObjPath() throws Exception {
+ useConfiguration("--experimental_shortened_obj_file_path=true");
+ createLibraryTargetWriter("//foo:lib")
+ .setAndCreateFiles("srcs", "a.m", "pkg1/a.m", "b.m")
+ .setAndCreateFiles("non_arc_srcs", "pkg2/a.m")
+ .write();
+
+ getConfiguredTarget("//foo:lib");
+
+ Artifact a0 = getBinArtifact("_objs/lib/arc/0/a.o", "//foo:lib");
+ Artifact a1 = getBinArtifact("_objs/lib/arc/1/a.o", "//foo:lib");
+ Artifact a2 = getBinArtifact("_objs/lib/non_arc/a.o", "//foo:lib");
+ Artifact b = getBinArtifact("_objs/lib/arc/b.o", "//foo:lib");
+
+ assertThat(getGeneratingAction(a0)).isNotNull();
+ assertThat(getGeneratingAction(a1)).isNotNull();
+ assertThat(getGeneratingAction(a2)).isNotNull();
+ assertThat(getGeneratingAction(b)).isNotNull();
+
+ assertThat(getGeneratingAction(a0).getInputs()).contains(getSourceArtifact("foo/a.m"));
+ assertThat(getGeneratingAction(a1).getInputs()).contains(getSourceArtifact("foo/pkg1/a.m"));
+ assertThat(getGeneratingAction(a2).getInputs()).contains(getSourceArtifact("foo/pkg2/a.m"));
+ assertThat(getGeneratingAction(b).getInputs()).contains(getSourceArtifact("foo/b.m"));
+ }
+
+ @Test
+ public void testCompilesSourcesWithSameBaseNameWithLegacyObjPath() throws Exception {
+ useConfiguration("--experimental_shortened_obj_file_path=false");
+ createLibraryTargetWriter("//foo:lib")
+ .setAndCreateFiles("srcs", "a.m", "pkg1/a.m", "b.m")
+ .setAndCreateFiles("non_arc_srcs", "pkg2/a.m")
+ .write();
+
+ getConfiguredTarget("//foo:lib");
+
+ Artifact a0 = getBinArtifact("_objs/lib/foo/a.o", "//foo:lib");
+ Artifact a1 = getBinArtifact("_objs/lib/foo/pkg1/a.o", "//foo:lib");
+ Artifact a2 = getBinArtifact("_objs/lib/foo/pkg2/a.o", "//foo:lib");
+ Artifact b = getBinArtifact("_objs/lib/foo/b.o", "//foo:lib");
+
+ assertThat(getGeneratingAction(a0)).isNotNull();
+ assertThat(getGeneratingAction(a1)).isNotNull();
+ assertThat(getGeneratingAction(a2)).isNotNull();
+ assertThat(getGeneratingAction(b)).isNotNull();
+
+ assertThat(getGeneratingAction(a0).getInputs()).contains(getSourceArtifact("foo/a.m"));
+ assertThat(getGeneratingAction(a1).getInputs()).contains(getSourceArtifact("foo/pkg1/a.m"));
+ assertThat(getGeneratingAction(a2).getInputs()).contains(getSourceArtifact("foo/pkg2/a.m"));
+ assertThat(getGeneratingAction(b).getInputs()).contains(getSourceArtifact("foo/b.m"));
+ }
+
+ @Test
public void testObjcPlusPlusCompile() throws Exception {
useConfiguration(
"--cpu=ios_i386",