Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cpp assembly file extensions case sensitive again #14131

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,46 @@ 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");
// FileType is extended to use case-sensitive comparison also on Windows
public static final FileType ASSEMBLER_WITH_C_PREPROCESSOR =
Gormo marked this conversation as resolved.
Show resolved Hide resolved
new FileType() {
final String ext = ".S";

@Override
public boolean apply(String path) {
return path.endsWith(ext);
}

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

// FileType is extended to use case-sensitive comparison also on Windows
public static final FileType PIC_ASSEMBLER =
Gormo marked this conversation as resolved.
Show resolved Hide resolved
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);
}
};

// FileType is extended to use case-sensitive comparison also on Windows
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))
Gormo marked this conversation as resolved.
Show resolved Hide resolved
|| 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();
}
}