Skip to content
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 @@ -103,7 +103,7 @@ public class ObjcCommandLineOptions extends FragmentOptions {

@Option(
name = "incompatible_avoid_hardcoded_objc_compilation_flags",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,14 @@ public void testPopulatesCompilationArtifacts() throws Exception {
checkPopulatesCompilationArtifacts(RULE_TYPE);
}

@Test
public void testCompilationActionsForDebugLegacyFlags() throws Exception {
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, true);
}

@Test
public void testCompilationActionsForDebug() throws Exception {
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG);
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, false);
}

@Test
Expand Down Expand Up @@ -1169,9 +1174,14 @@ public void testClangCoptsForDebugModeWithoutGlibOrHardcoding() throws Exception
.containsNoneOf("-D_GLIBCXX_DEBUG", "-DDEBUG=1");
}

@Test
public void testCompilationActionsForOptimizedLegacyFlags() throws Exception {
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, true);
}

@Test
public void testCompilationActionsForOptimized() throws Exception {
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT);
checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ private static String compilationModeFlag(CompilationMode mode) {
throw new AssertionError();
}

protected static ImmutableList<String> compilationModeCopts(CompilationMode mode) {
protected static ImmutableList<String> legacyCompilationModeCopts(CompilationMode mode) {
switch (mode) {
case DBG:
return ImmutableList.copyOf(ObjcConfiguration.DBG_COPTS);
case OPT:
return ObjcConfiguration.OPT_COPTS;
case FASTBUILD:
return FASTBUILD_COPTS;
}
throw new AssertionError();
}
Expand Down Expand Up @@ -890,13 +888,18 @@ protected List<String> rootedIncludePaths(String... unrootedPaths) {
return rootedPaths.build();
}

protected void checkClangCoptsForCompilationMode(RuleType ruleType, CompilationMode mode)
protected void checkClangCoptsForCompilationMode(RuleType ruleType, CompilationMode mode, boolean includeLegacyFlags)
throws Exception {
ImmutableList.Builder<String> allExpectedCoptsBuilder =
ImmutableList.<String>builder()
.addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS)
.addAll(compilationModeCopts(mode));
.addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS);

if (includeLegacyFlags) {
allExpectedCoptsBuilder.addAll(legacyCompilationModeCopts(mode));
}

useConfiguration(
"--incompatible_avoid_hardcoded_objc_compilation_flags=" + !includeLegacyFlags,
"--platforms=" + MockObjcSupport.IOS_X86_64,
"--apple_platform_type=ios",
"--compilation_mode=" + compilationModeFlag(mode));
Expand All @@ -913,8 +916,7 @@ protected void checkClangCoptsForCompilationMode(RuleType ruleType, CompilationM
protected void checkClangCoptsForDebugModeWithoutGlib(RuleType ruleType) throws Exception {
ImmutableList.Builder<String> allExpectedCoptsBuilder =
ImmutableList.<String>builder()
.addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS)
.addAll(ObjcConfiguration.DBG_COPTS);
.addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS);

useConfiguration(
"--platforms=" + MockObjcSupport.IOS_X86_64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ def swift_binary_impl(ctx):
""");

useConfiguration(
"--incompatible_avoid_hardcoded_objc_compilation_flags=false",
"--compilation_mode=opt",
"--ios_simulator_device='iPhone 6'",
"--ios_simulator_version=8.4",
Expand Down
Loading