Skip to content

Commit

Permalink
Make --cxxopt apply to ObjC++ files
Browse files Browse the repository at this point in the history
Fixes #12716

Closes #23858.

PiperOrigin-RevId: 683271198
Change-Id: I14d8c85e56e8a1069d4fe925d4eb78db8d8ff757
  • Loading branch information
keith authored and copybara-github committed Oct 7, 2024
1 parent 07668e6 commit 6e9de20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ public static ImmutableList<String> getCoptsFromOptions(
if (CppFileTypes.CPP_SOURCE.matches(sourceFilename)
|| CppFileTypes.CPP_HEADER.matches(sourceFilename)
|| CppFileTypes.CPP_MODULE_MAP.matches(sourceFilename)
|| CppFileTypes.OBJCPP_SOURCE.matches(sourceFilename)
|| CppFileTypes.CLIF_INPUT_PROTO.matches(sourceFilename)) {
flagsBuilder.addAll(config.getCxxopts());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,20 @@ public void testObjcCopts_argumentOrdering() throws Exception {
assertThat(args).containsAtLeast("-fobjc-arc", "-foo", "-bar").inOrder();
}

@Test
public void testObjcCxxopts_argumentOrdering() throws Exception {
useConfiguration("--objccopt=-foo", "--cxxopt=-cxxfoo");
createLibraryTargetWriter("//lib:lib")
.setAndCreateFiles("srcs", "a.mm", "b.m", "private.h")
.setList("copts", "-bar")
.write();
List<String> aArgs = compileAction("//lib:lib", "a.o").getArguments();
assertThat(aArgs).containsAtLeast("-fobjc-arc", "-cxxfoo", "-foo", "-bar").inOrder();
List<String> bArgs = compileAction("//lib:lib", "b.o").getArguments();
assertThat(bArgs).containsAtLeast("-fobjc-arc", "-foo", "-bar").inOrder();
assertThat(bArgs).doesNotContain("-cxxfoo");
}

@Test
public void testBothModuleNameAndModuleMapGivesError() throws Exception {
checkError(
Expand Down

0 comments on commit 6e9de20

Please sign in to comment.