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

Add --host_macos_minimum_os flag #13001

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 @@ -163,6 +163,17 @@ public class AppleCommandLineOptions extends FragmentOptions {
+ "If unspecified, uses 'macos_sdk_version'.")
public DottedVersion.Option macosMinimumOs;

@Option(
name = "host_macos_minimum_os",
defaultValue = "null",
converter = DottedVersionConverter.class,
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE},
help =
"Minimum compatible macOS version for host targets. "
+ "If unspecified, uses 'macos_sdk_version'.")
public DottedVersion.Option hostMacosMinimumOs;

@Option(
name = "experimental_prefer_mutual_xcode",
defaultValue = "true",
Expand Down Expand Up @@ -488,6 +499,7 @@ public FragmentOptions getHost() {
host.watchOsSdkVersion = watchOsSdkVersion;
host.tvOsSdkVersion = tvOsSdkVersion;
host.macOsSdkVersion = macOsSdkVersion;
host.macosMinimumOs = hostMacosMinimumOs;
// The host apple platform type will always be MACOS, as no other apple platform type can
// currently execute build actions. If that were the case, a host_apple_platform_type flag might
// be needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,45 @@ public void testAppleBuildVariablesMacos() throws Exception {
.contains(dummyMinimumOsValue);
}

@Test
public void testAppleBuildVariablesMacosHost() throws Exception {
MockObjcSupport.setup(mockToolsConfig);
String dummyMinimumOsValue = "13.579";
useConfiguration(
"--crosstool_top=//tools/osx/crosstool",
"--cpu=darwin_x86_64",
"--host_cpu=darwin_x86_64",
"--macos_minimum_os=10.11",
"--host_macos_minimum_os=" + dummyMinimumOsValue);
scratch.file(
"x/BUILD",
"apple_binary(",
" name = 'bin',",
" deps = [':a'],",
" platform_type = 'macos',",
")",
"cc_library(",
" name = 'a',",
" srcs = ['a.cc'],",
")");
scratch.file("x/a.cc");

ConfiguredTarget target = getHostConfiguredTarget("//x:bin");
Artifact lipoBin =
getBinArtifact(
Label.parseAbsolute("//x:bin", ImmutableMap.of()).getName() + "_lipobin", target);
Action lipoAction = getGeneratingAction(lipoBin);
Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin");
CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin);
Artifact archive =
ActionsTestUtil.getFirstArtifactEndingWith(appleBinLinkAction.getInputs(), "liba.a");
CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(archive);

CcToolchainVariables variables = ccArchiveAction.getLinkCommandLine().getBuildVariables();
assertThat(getVariableValue(getRuleContext(), variables, AppleCcToolchain.VERSION_MIN_KEY))
.contains(dummyMinimumOsValue);
}

@Test
public void testDefaultBuildVariablesIos() throws Exception {
MockObjcSupport.setup(mockToolsConfig);
Expand Down