Skip to content

Refactored build-script-impl for cross-compiling support #2497

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

Merged
merged 2 commits into from
May 30, 2016
Merged
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
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,11 @@ function(is_sdk_requested name result_var_name)
if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${name}")
set("${result_var_name}" "TRUE" PARENT_SCOPE)
else()
if("${SWIFT_SDKS}" STREQUAL "")
set("${result_var_name}" "TRUE" PARENT_SCOPE)
list(FIND SWIFT_SDKS "${name}" sdk_index)
if(${sdk_index} EQUAL -1)
set("${result_var_name}" "FALSE" PARENT_SCOPE)
else()
list(FIND SWIFT_SDKS "${name}" sdk_index)
if(${sdk_index} EQUAL -1)
set("${result_var_name}" "FALSE" PARENT_SCOPE)
else()
set("${result_var_name}" "TRUE" PARENT_SCOPE)
endif()
set("${result_var_name}" "TRUE" PARENT_SCOPE)
endif()
endif()
endfunction()
Expand Down
29 changes: 29 additions & 0 deletions utils/SwiftBuildSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,35 @@ def get_preset_options(substitutions, preset_file_names, preset_name):
"': " + ", ".join(missing_opts))
sys.exit(1)

# Migrate 'swift-sdks' parameter to 'stdlib-deployment-targets'
for opt in build_script_impl_opts:
if opt.startswith("--swift-sdks"):
sdksToConfigure = opt.split("=")[1].split(";")
tgts = []
# Expand SDKs in to their deployment targets
from swift_build_support.targets import StdlibDeploymentTarget
for sdk in sdksToConfigure:
if sdk == "OSX":
tgts += StdlibDeploymentTarget.OSX.allArchs
elif sdk == "IOS":
tgts += StdlibDeploymentTarget.iOS.allArchs
elif sdk == "IOS_SIMULATOR":
tgts += StdlibDeploymentTarget.iOSSimulator.allArchs
elif sdk == "TVOS":
tgts += StdlibDeploymentTarget.AppleTV.allArchs
elif sdk == "TVOS_SIMULATOR":
tgts += StdlibDeploymentTarget.AppleTVSimulator.allArchs
elif sdk == "WATCHOS":
tgts += StdlibDeploymentTarget.AppleWatch.allArchs
elif sdk == "WATCHOS_SIMULATOR":
tgts += StdlibDeploymentTarget.AppleWatchSimulator.allArchs

build_script_opts.append("--stdlib-deployment-targets=" +
" ".join(tgts))
# Filter the swift-sdks parameter
build_script_impl_opts = [opt for opt in build_script_impl_opts
if not opt.startswith("--swift-sdks")]

return build_script_opts + ["--"] + build_script_impl_opts


Expand Down
7 changes: 2 additions & 5 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ dash-dash
verbose-build
build-ninja

swift-sdks=OSX;IOS;IOS_SIMULATOR;TVOS;TVOS_SIMULATOR;WATCHOS;WATCHOS_SIMULATOR

# Build static standard library because it is used
# to build external projects.
build-swift-static-stdlib
Expand Down Expand Up @@ -76,7 +74,7 @@ skip-build-tvos
skip-test-tvos
skip-build-watchos
skip-test-watchos
swift-sdks=OSX
stdlib-deployment-targets=macosx-x86_64
swift-primary-variant-sdk=OSX
swift-primary-variant-arch=x86_64

Expand Down Expand Up @@ -406,7 +404,7 @@ skip-build-tvos
skip-test-tvos
skip-build-watchos
skip-test-watchos
swift-sdks=OSX
stdlib-deployment-targets=macosx-x86_64
swift-primary-variant-sdk=OSX
swift-primary-variant-arch=x86_64

Expand Down Expand Up @@ -671,7 +669,6 @@ build-ninja
build-swift-static-stdlib
build-swift-stdlib-unittest-extra
compiler-vendor=apple
swift-sdks=OSX;IOS;IOS_SIMULATOR;TVOS;TVOS_SIMULATOR;WATCHOS;WATCHOS_SIMULATOR

install-swift
install-lldb
Expand Down
12 changes: 9 additions & 3 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ from swift_build_support import products # noqa (E402)
from swift_build_support import shell # noqa (E402)
import swift_build_support.tar # noqa (E402)
import swift_build_support.targets # noqa (E402)
from swift_build_support.targets import StdlibDeploymentTarget # noqa (E402)
from swift_build_support.cmake import CMake # noqa (E402)
from swift_build_support.workspace import Workspace # noqa(E402)
from swift_build_support.workspace import compute_build_subdir # noqa(E402)
Expand Down Expand Up @@ -353,13 +354,13 @@ details of the setups of other systems or automated environments.""")
help="The host target. LLVM, Clang, and Swift will be built for this "
"target. The built LLVM and Clang will be used to compile Swift "
"for the cross-compilation targets.",
default=swift_build_support.targets.host_target())
default=StdlibDeploymentTarget.host_target())
targets_group.add_argument(
"--stdlib-deployment-targets",
help="list of targets to compile or cross-compile the Swift standard "
"library for. %(default)s by default.",
nargs="*",
default=swift_build_support.targets.stdlib_deployment_targets())
default=StdlibDeploymentTarget.default_stdlib_deployment_targets())

projects_group = parser.add_argument_group(
title="Options to select projects")
Expand Down Expand Up @@ -1226,6 +1227,11 @@ details of the setups of other systems or automated environments.""")
if args.build_subdir is None:
args.build_subdir = compute_build_subdir(args)

# Add optional stdlib-deployment-targets
if args.android:
args.stdlib_deployment_targets.append(
StdlibDeploymentTarget.Android.armv7)

workspace = Workspace(
source_root=SWIFT_SOURCE_ROOT,
build_root=os.path.join(SWIFT_BUILD_ROOT, args.build_subdir))
Expand Down Expand Up @@ -1274,7 +1280,7 @@ details of the setups of other systems or automated environments.""")
build_script_impl_args = [
"--workspace", workspace.source_root,
"--build-dir", workspace.build_root,
"--install-prefix", os.path.abspath(args.install_prefix),
"--install-prefix", args.install_prefix,
"--host-target", args.host_target,
"--stdlib-deployment-targets",
" ".join(args.stdlib_deployment_targets),
Expand Down
Loading