Skip to content

Commit

Permalink
Make cpp assembly file extensions case sensitive again
Browse files Browse the repository at this point in the history
This fixes an issue introduced by PR bazelbuild#14005 where .s and .S
extensions were handled case-insensitive on Windows so the action
assemble was triggered instead of preprocess_assemble.
  • Loading branch information
Simon Bjorklen authored and Simon Bjorklen committed Nov 9, 2021
1 parent 5149408 commit 5e877f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,28 @@ public ImmutableList<String> getExtensions() {
};

public static final FileType ASSEMBLER_WITH_C_PREPROCESSOR = FileType.of(".S");
public static final FileType PIC_ASSEMBLER = FileType.of(".pic.s");
public static final FileType PIC_ASSEMBLER =
new FileType() {
final String ext = ".pic.s";

@Override
public boolean apply(String path) {
return OS.endsWith(path, ext) && path.endsWith(".s");
}

@Override
public ImmutableList<String> getExtensions() {
return ImmutableList.of(ext);
}
};

public static final FileType ASSEMBLER =
new FileType() {
final String ext = ".s";

@Override
public boolean apply(String path) {
return (OS.endsWith(path, ext) && !PIC_ASSEMBLER.matches(path))
return (path.endsWith(ext) && !PIC_ASSEMBLER.matches(path))
|| OS.endsWith(path, ".asm");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ public void testVersionedSharedLibraries() {
assertThat(CppFileTypes.VERSIONED_SHARED_LIBRARY.matches("libA.so.if.exp")).isFalse();
assertThat(CppFileTypes.VERSIONED_SHARED_LIBRARY.matches("libA.so.if.lib")).isFalse();
}

@Test
public void testCaseSensitiveAssemblyFiles() {
assertThat(CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR.matches("foo.S")).isTrue();
assertThat(CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR.matches("foo.s")).isFalse();
assertThat(CppFileTypes.PIC_ASSEMBLER.matches("foo.pic.s")).isTrue();
assertThat(CppFileTypes.PIC_ASSEMBLER.matches("foo.pic.S")).isFalse();
assertThat(CppFileTypes.ASSEMBLER.matches("foo.s")).isTrue();
assertThat(CppFileTypes.ASSEMBLER.matches("foo.asm")).isTrue();
assertThat(CppFileTypes.ASSEMBLER.matches("foo.pic.s")).isFalse();
assertThat(CppFileTypes.ASSEMBLER.matches("foo.S")).isFalse();
}
}

0 comments on commit 5e877f0

Please sign in to comment.