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

Change default apple_platform_type to macOS #6366

Closed
wants to merge 3 commits into from
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 @@ -221,7 +221,7 @@ public class AppleCommandLineOptions extends FragmentOptions {

@Option(
name = "apple_platform_type",
defaultValue = "IOS",
defaultValue = "MACOS",
converter = PlatformTypeConverter.class,
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ public void testInvalidBitcodeVersion() throws Exception {
" version = '5.1.2',",
")");

useConfiguration("--apple_bitcode=embedded", "--apple_split_cpu=arm64");
useConfiguration("--apple_platform_type=ios", "--apple_bitcode=embedded",
"--apple_split_cpu=arm64");

reporter.removeHandler(failFastHandler);
getConfiguredTarget("//xcode:foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void testAppleSdkDefaultPlatformEnv() throws Exception {
@Test
public void testAppleSdkIphoneosPlatformEnv() throws Exception {
RULE_TYPE.scratchTarget(scratch, "platform_type", "'ios'");
useConfiguration("--cpu=ios_arm64");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_arm64");

CommandAction action = linkLibAction("//x:x");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public void testToolchainSelectionDefault() throws Exception {

assertThat(cppConfig.getRuleProvidingCcToolchainProvider().toString())
.isEqualTo("//tools/osx/crosstool:crosstool");
assertThat(cppConfig.getTransformedCpuFromOptions()).isEqualTo("ios_x86_64");
assertThat(cppConfig.getTransformedCpuFromOptions()).isEqualTo("darwin_x86_64");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only test I intentionally changed the behavior of, I believe that we want to now test the default is macOS (and therefore is this default arch)

}

@Test
public void testToolchainSelectionIosDevice() throws Exception {
useConfiguration("--cpu=ios_armv7");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_armv7");
createLibraryTargetWriter("//a:lib").write();
CppConfiguration cppConfig =
getAppleCrosstoolConfiguration().getFragment(CppConfiguration.class);
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testToolchainSelectionCcDepDefault() throws Exception {

@Test
public void testToolchainSelectionCcDepDevice() throws Exception {
useConfiguration("--cpu=ios_armv7");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_armv7");
ScratchAttributeWriter
.fromLabelString(this, "cc_library", "//b:lib")
.setList("srcs", "b.cc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ protected Iterable<CommandAction> getActionsForInputsOfGeneratingActionTemplate(

@Test
public void testCompileActionTemplateFromGenJar() throws Exception {
useConfiguration("--cpu=ios_i386", "--ios_minimum_os=1.0");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386", "--ios_minimum_os=1.0");
addSimpleJ2ObjcLibraryWithJavaPlugin();
Artifact archive = j2objcArchive("//java/com/google/app/test:transpile", "test");
CommandAction archiveAction = (CommandAction) getGeneratingAction(archive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testAppleBuildVariablesIos() throws Exception {
useConfiguration(
"--crosstool_top=//tools/osx/crosstool", "--xcode_version=5.8",
"--ios_minimum_os=12.345", "--watchos_minimum_os=11.111",
"--cpu=ios_x86_64");
"--cpu=ios_x86_64", "--apple_platform_type=ios");
scratch.file(
"x/BUILD",
"cc_binary(",
Expand Down Expand Up @@ -202,6 +202,7 @@ public void testAppleBuildVariablesMacos() throws Exception {
public void testDefaultBuildVariablesIos() throws Exception {
MockObjcSupport.setup(mockToolsConfig);
useConfiguration(
"--apple_platform_type=ios",
"--crosstool_top=//tools/osx/crosstool", "--cpu=ios_x86_64");
scratch.file(
"x/BUILD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testConfigTransitionWithTopLevelAppleConfiguration() throws Exceptio
")");

useConfiguration(
"--cpu=ios_x86_64",
"--apple_platform_type=ios", "--cpu=ios_x86_64",
"--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL);

ConfiguredTarget cc = getConfiguredTarget("//bin:cc");
Expand Down Expand Up @@ -176,6 +176,7 @@ public void testCompilesSourcesWithSameBaseName() throws Exception {
@Test
public void testObjcPlusPlusCompile() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_i386",
"--ios_cpu=i386",
"--ios_minimum_os=9.10.11");
Expand Down Expand Up @@ -406,6 +407,7 @@ static Iterable<String> iquoteArgs(ObjcProvider provider, BuildConfiguration con
@Test
public void testCompilationActions_simulator() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_i386",
"--ios_cpu=i386");

Expand Down Expand Up @@ -458,6 +460,7 @@ public void testCompilationActions_simulator() throws Exception {
@Test
public void testCompilationActions_device() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_armv7",
"--ios_cpu=armv7");

Expand Down Expand Up @@ -552,7 +555,7 @@ public void testPrecompiledHeaders() throws Exception {

@Test
public void testCompilationActionsWithCopts() throws Exception {
useConfiguration("--cpu=ios_i386", "--ios_cpu=i386");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386", "--ios_cpu=i386");
createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.setAndCreateFiles("hdrs", "c.h")
Expand Down Expand Up @@ -619,6 +622,7 @@ public void testCompilationActionsWithModuleMapsEnabled() throws Exception {
@Test
public void testCompilationActionsWithEmbeddedBitcode() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--ios_multi_cpus=arm64",
"--apple_bitcode=embedded");
createLibraryTargetWriter("//objc:lib")
Expand All @@ -634,6 +638,7 @@ public void testCompilationActionsWithEmbeddedBitcode() throws Exception {
@Test
public void testCompilationActionsWithEmbeddedBitcodeMarkers() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--ios_multi_cpus=arm64",
"--apple_bitcode=embedded_markers");

Expand Down Expand Up @@ -750,6 +755,7 @@ public void testCompilationActionsWithCoptFmodulesCachePath() throws Exception {
@Test
public void testArchiveAction_simulator() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_i386",
"--ios_cpu=i386");
createLibraryTargetWriter("//objc:lib")
Expand Down Expand Up @@ -781,6 +787,7 @@ public void testArchiveAction_simulator() throws Exception {
@Test
public void testArchiveAction_device() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_armv7",
"--ios_cpu=armv7");
createLibraryTargetWriter("//objc:lib")
Expand Down Expand Up @@ -812,6 +819,7 @@ public void testArchiveAction_device() throws Exception {
@Test
public void testFullyLinkArchiveAction_simulator() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_i386",
"--ios_cpu=i386");
createLibraryTargetWriter("//objc:lib_dep")
Expand Down Expand Up @@ -851,6 +859,7 @@ public void testFullyLinkArchiveAction_simulator() throws Exception {
@Test
public void testFullyLinkArchiveAction_device() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_armv7",
"--ios_cpu=armv7");
createLibraryTargetWriter("//objc:lib_dep")
Expand Down Expand Up @@ -921,6 +930,7 @@ public void testIncludesDirsGetPassedToCompileAction() throws Exception {
@Test
public void testPropagatesDefinesToDependersTransitively() throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--cpu=ios_x86_64",
"--ios_cpu=x86_64");
createLibraryTargetWriter("//lib1:lib1")
Expand Down Expand Up @@ -1241,6 +1251,7 @@ public void testWarningForBlacklistedTypesInHeaders() throws Exception {

@Test
public void testAppleSdkVersionEnv() throws Exception {
useConfiguration("--apple_platform_type=ios");
createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.setAndCreateFiles("hdrs", "c.h")
Expand All @@ -1252,7 +1263,7 @@ public void testAppleSdkVersionEnv() throws Exception {

@Test
public void testNonDefaultAppleSdkVersionEnv() throws Exception {
useConfiguration("--ios_sdk_version=8.1");
useConfiguration("--apple_platform_type=ios", "--ios_sdk_version=8.1");

createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
Expand Down Expand Up @@ -1403,6 +1414,7 @@ public void testCompilationActions_deviceSdk9() throws Exception {

@Test
public void testCompilationActionsWithPch() throws Exception {
useConfiguration("--apple_platform_type=ios");
ApplePlatform platform = ApplePlatform.IOS_SIMULATOR;
scratch.file("objc/foo.pch");
createLibraryTargetWriter("//objc:lib")
Expand Down Expand Up @@ -1720,6 +1732,7 @@ public void testUsesDotdPruning() throws Exception {

@Test
public void testAppleSdkDefaultPlatformEnv() throws Exception {
useConfiguration("--apple_platform_type=ios");
createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.setAndCreateFiles("hdrs", "c.h")
Expand All @@ -1731,7 +1744,7 @@ public void testAppleSdkDefaultPlatformEnv() throws Exception {

@Test
public void testAppleSdkDevicePlatformEnv() throws Exception {
useConfiguration("--cpu=ios_arm64");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_arm64");

createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public void testModuleMapActionFiltersHeaders() throws Exception {

@Test
public void testCompilationAction() throws Exception {
useConfiguration("--cpu=ios_i386");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386");
ApplePlatform platform = ApplePlatform.IOS_SIMULATOR;

// Because protos are linked/compiled within the apple_binary context, we need to traverse the
Expand Down Expand Up @@ -537,7 +537,7 @@ public void testCompilationAction() throws Exception {

@Test
public void testLibraryLinkAction() throws Exception {
useConfiguration("--cpu=ios_armv7");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_armv7");

// Because protos are linked within the apple_binary context, we need to traverse the action
// graph to find the linked protos (.a).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,16 +1127,18 @@ protected void checkClangCoptsForCompilationMode(RuleType ruleType, CompilationM

switch (codeCoverageMode) {
case NONE:
useConfiguration("--compilation_mode=" + compilationModeFlag(mode));
useConfiguration("--apple_platform_type=ios",
"--compilation_mode=" + compilationModeFlag(mode));
break;
case GCOV:
allExpectedCoptsBuilder.addAll(CompilationSupport.CLANG_GCOV_COVERAGE_FLAGS);
useConfiguration("--collect_code_coverage",
useConfiguration("--apple_platform_type=ios", "--collect_code_coverage",
"--compilation_mode=" + compilationModeFlag(mode));
break;
case LLVMCOV:
allExpectedCoptsBuilder.addAll(CompilationSupport.CLANG_LLVM_COVERAGE_FLAGS);
useConfiguration("--collect_code_coverage", "--experimental_use_llvm_covmap",
useConfiguration("--apple_platform_type=ios",
"--collect_code_coverage", "--experimental_use_llvm_covmap",
"--compilation_mode=" + compilationModeFlag(mode));
break;
}
Expand All @@ -1155,7 +1157,8 @@ protected void checkClangCoptsForDebugModeWithoutGlib(RuleType ruleType) throws
.addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS)
.addAll(ObjcConfiguration.DBG_COPTS);

useConfiguration("--compilation_mode=dbg", "--objc_debug_with_GLIBCXX=false");
useConfiguration("--apple_platform_type=ios", "--compilation_mode=dbg",
"--objc_debug_with_GLIBCXX=false");
scratch.file("x/a.m");
ruleType.scratchTarget(scratch,
"srcs", "['a.m']");
Expand Down Expand Up @@ -1754,8 +1757,7 @@ protected void checkAppleSdkDefaultPlatformEnv(RuleType ruleType) throws Excepti

protected void checkAppleSdkIphoneosPlatformEnv(RuleType ruleType) throws Exception {
ruleType.scratchTarget(scratch);
useConfiguration(
"--cpu=ios_arm64");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_arm64");

CommandAction action = linkAction("//x:x");

Expand Down Expand Up @@ -2113,6 +2115,7 @@ protected void checkCustomModuleMapPropagatedByTargetUnderTest(
private void checkCustomModuleMap(RuleType ruleType, boolean targetUnderTestShouldPropagate)
throws Exception {
useConfiguration(
"--apple_platform_type=ios",
"--experimental_objc_enable_module_maps",
"--incompatible_strict_objc_module_maps");
ruleType.scratchTarget(scratch, "deps", "['//z:a']");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void testSkylarkCanAccessAppleConfiguration() throws Exception {
" name='my_target',",
")");

useConfiguration("--cpu=ios_i386", "--xcode_version=7.3");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386", "--xcode_version=7.3");
ConfiguredTarget skylarkTarget = getConfiguredTarget("//examples/apple_skylark:my_target");


Expand Down Expand Up @@ -496,7 +496,7 @@ public void testSkylarkCanAccessAppleToolchain() throws Exception {
" name='my_target',",
")");

useConfiguration("--cpu=ios_i386");
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386");
ConfiguredTarget skylarkTarget = getConfiguredTarget("//examples/apple_skylark:my_target");

String platformDevFrameworksDir =
Expand Down
8 changes: 5 additions & 3 deletions src/test/shell/bazel/apple/bazel_objc_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function test_build_app() {
setup_objc_test_support
make_lib

bazel build --verbose_failures \
bazel build --verbose_failures --apple_platform_type=ios \
--ios_sdk_version=$IOS_SDK_VERSION \
//ios:lib >$TEST_log 2>&1 || fail "should pass"
ls bazel-out/apl-ios_x86_64-fastbuild/bin/ios/liblib.a \
Expand All @@ -60,7 +60,8 @@ function test_invalid_ios_sdk_version() {
setup_objc_test_support
make_lib

! bazel build --verbose_failures --ios_sdk_version=2.34 \
! bazel build --verbose_failures --apple_platform_type=ios \
--ios_sdk_version=2.34 \
//ios:lib >$TEST_log 2>&1 || fail "should fail"
expect_log "SDK \"iphonesimulator2.34\" cannot be located."
}
Expand Down Expand Up @@ -102,7 +103,7 @@ int aFunction() {
}
EOF

bazel build --verbose_failures \
bazel build --verbose_failures --apple_platform_type=ios \
--ios_sdk_version=$IOS_SDK_VERSION //objclib:objclib >"$TEST_log" 2>&1 \
|| fail "Should build objc_library"

Expand Down Expand Up @@ -147,6 +148,7 @@ objc_library(name = 'main',
EOF

bazel build --verbose_failures \
--apple_platform_type=ios \
--ios_sdk_version=$IOS_SDK_VERSION \
--objc_enable_binary_stripping=true \
--compilation_mode=opt \
Expand Down