Skip to content

Move swiftpm to swift_build_support infra #28035

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 1 commit into from
Nov 3, 2019
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
3 changes: 0 additions & 3 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ swift-primary-variant-sdk=OSX
swift-primary-variant-arch=x86_64
skip-build-llbuild
skip-test-llbuild
skip-build-swiftpm
skip-test-swiftpm
skip-build-playgroundsupport
skip-test-playgroundsupport
Expand Down Expand Up @@ -843,7 +842,6 @@ android-icu-data=%(arm_dir)s/libicudataswift.so
skip-test-linux
skip-build-lldb
skip-build-llbuild
skip-build-swiftpm
skip-build-libdispatch
skip-build-foundation
skip-build-xctest
Expand Down Expand Up @@ -1640,7 +1638,6 @@ darwin-install-extract-symbols=1
skip-build-cmark
skip-build-llvm
skip-build-llbuild
skip-build-swiftpm
skip-build-benchmarks
install-swift
install-prefix=%(install_toolchain_dir)s/usr
Expand Down
4 changes: 0 additions & 4 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ class BuildScriptInvocation(object):
"--libdispatch-build-type", args.libdispatch_build_variant,
"--libicu-build-type", args.libicu_build_variant,
"--xctest-build-type", args.build_variant,
"--swiftpm-build-type", args.build_variant,
"--llbuild-build-type", args.build_variant,
"--swift-enable-assertions", str(args.swift_assertions).lower(),
"--swift-stdlib-enable-assertions", str(
Expand Down Expand Up @@ -464,8 +463,6 @@ class BuildScriptInvocation(object):
impl_args += ["--skip-build-libdispatch"]
if not args.build_libicu:
impl_args += ["--skip-build-libicu"]
if not args.build_swiftpm:
impl_args += ["--skip-build-swiftpm"]
if not args.build_playgroundsupport:
impl_args += ["--skip-build-playgroundsupport"]
if args.build_swift_dynamic_stdlib:
Expand Down Expand Up @@ -508,7 +505,6 @@ class BuildScriptInvocation(object):
impl_args += ["--skip-test-cmark",
"--skip-test-lldb",
"--skip-test-llbuild",
"--skip-test-swiftpm",
"--skip-test-xctest",
"--skip-test-foundation",
"--skip-test-libdispatch",
Expand Down
137 changes: 2 additions & 135 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ KNOWN_SETTINGS=(
libicu-build-type "Debug" "the build variant for libicu"
playgroundsupport-build-type "Debug" "the build variant for PlaygroundSupport"
xctest-build-type "Debug" "the build variant for xctest"
swiftpm-build-type "Debug" "the build variant for swiftpm"
llbuild-enable-assertions "1" "enable assertions in llbuild"
enable-asan "" "enable Address Sanitizer"
enable-ubsan "" "enable Undefined Behavior Sanitizer"
Expand Down Expand Up @@ -119,7 +118,6 @@ KNOWN_SETTINGS=(
skip-build-lldb "" "set to skip building LLDB"
skip-build-llbuild "" "set to skip building llbuild"
skip-build-libcxx "" "set to skip building libcxx"
skip-build-swiftpm "" "set to skip building swiftpm"
skip-build-xctest "" "set to skip building xctest"
skip-build-foundation "" "set to skip building foundation"
skip-build-libdispatch "" "set to skip building libdispatch"
Expand All @@ -132,7 +130,6 @@ KNOWN_SETTINGS=(
skip-test-lldb "" "set to skip testing lldb"
skip-test-swift "" "set to skip testing Swift"
skip-test-llbuild "" "set to skip testing llbuild"
skip-test-swiftpm "" "set to skip testing swiftpm"
skip-test-xctest "" "set to skip testing xctest"
skip-test-foundation "" "set to skip testing foundation"
skip-test-libdispatch "" "set to skip testing libdispatch"
Expand Down Expand Up @@ -189,7 +186,6 @@ KNOWN_SETTINGS=(
install-swift "" "whether to install Swift"
install-lldb "" "whether to install LLDB"
install-llbuild "" "whether to install llbuild"
install-swiftpm "" "whether to install swiftpm"
install-xctest "" "whether to install xctest"
install-foundation "" "whether to install foundation"
install-libcxx "" "whether to install libc++"
Expand Down Expand Up @@ -248,7 +244,6 @@ KNOWN_SETTINGS=(
llvm-cmake-options "" "CMake options used for all llvm targets"
ninja-cmake-options "" "CMake options used for all ninja targets"
swift-cmake-options "" "CMake options used for all swift targets"
swiftpm-cmake-options "" "CMake options used for all swiftpm targets"
xctest-cmake-options "" "CMake options used for all xctest targets"
playgroundsupport-cmake-options "" "CMake options used for all playgroundsupport targets"
# TODO: Remove this some time later.
Expand Down Expand Up @@ -406,7 +401,6 @@ function set_build_options_for_host() {
swift_cmake_options=()
cmark_cmake_options=()
lldb_cmake_options=()
swiftpm_bootstrap_options=()
SWIFT_HOST_VARIANT=
SWIFT_HOST_VARIANT_SDK=
SWIFT_HOST_VARIANT_ARCH=
Expand Down Expand Up @@ -485,9 +479,6 @@ function set_build_options_for_host() {
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
-DCMAKE_OSX_DEPLOYMENT_TARGET="${cmake_osx_deployment_target}"
)
swiftpm_bootstrap_options=(
--sysroot="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
iphonesimulator-i386)
xcrun_sdk_name="iphonesimulator"
Expand Down Expand Up @@ -1179,7 +1170,6 @@ LLVM_SOURCE_DIR="${WORKSPACE}/llvm"
CMARK_SOURCE_DIR="${WORKSPACE}/cmark"
LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester"
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
Expand Down Expand Up @@ -1233,7 +1223,7 @@ PRODUCTS=("${PRODUCTS[@]}" swift)
if [[ ! "${SKIP_BUILD_LLDB}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" lldb)
fi
# LLBuild, SwiftPM and XCTest are dependent on Foundation, so Foundation must
# LLBuild and XCTest are dependent on Foundation, so Foundation must
# be added to the list of build products first.
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
Expand All @@ -1253,14 +1243,9 @@ fi
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
fi
# SwiftPM is dependent on XCTest, so XCTest must be added to the list of build
# products first.
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" xctest)
fi
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
fi

# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
function contains_product() {
Expand Down Expand Up @@ -1563,9 +1548,6 @@ function build_directory_bin() {
llbuild)
echo "${root}/${LLBUILD_BUILD_TYPE}/bin"
;;
swiftpm)
echo "${root}/${SWIFTPM_BUILD_TYPE}/bin"
;;
xctest)
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
;;
Expand All @@ -1586,12 +1568,7 @@ function build_directory_bin() {
;;
esac
else
if [[ "${product}" == "swiftpm" ]] ; then
set_swiftpm_bootstrap_command
echo "$(${swiftpm_bootstrap_command[@]} --show-bin-path)"
else
echo "${root}/bin"
fi
echo "${root}/bin"
fi
}

Expand Down Expand Up @@ -1705,9 +1682,6 @@ function cmake_config_opt() {
llbuild)
echo "--config ${LLBUILD_BUILD_TYPE}"
;;
swiftpm)
echo "--config ${SWIFTPM_BUILD_TYPE}"
;;
xctest)
echo "--config ${XCTEST_BUILD_TYPE}"
;;
Expand All @@ -1730,81 +1704,6 @@ function cmake_config_opt() {
fi
}

function set_swiftpm_bootstrap_command() {
if [[ -n "${swiftpm_bootstrap_command[@]}" ]]; then
# Already set.
return
fi

SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
LLBUILD_BIN="$(build_directory_bin ${LOCAL_HOST} llbuild)/swift-build-tool"
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
FOUNDATION_BUILD_DIR=$(build_directory ${host} foundation)
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
LIBDISPATCH_BUILD_DIR="$(build_directory ${host} libdispatch)"
LIBDISPATCH_BUILD_ARGS="--libdispatch-source-dir=${LIBDISPATCH_SOURCE_DIR} --libdispatch-build-dir=${LIBDISPATCH_BUILD_DIR}"
fi
if [[ ! "${SKIP_BUILD_LIBICU}" ]] ; then
LIBICU_BUILD_DIR="$(build_directory ${host} libicu)"
fi
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
fi
fi
if [ "${SKIP_BUILD_LLBUILD}" ]; then
echo "Error: Cannot build swiftpm without llbuild (swift-build-tool)."
exit 1
fi
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then
echo "Error: Cannot build swiftpm when llbuild is built using Xcode."
exit 1
fi
swiftpm_bootstrap_command=("${SWIFTPM_SOURCE_DIR}/Utilities/bootstrap" "${swiftpm_bootstrap_options[@]}")
# Add --release if we have to build in release mode.
if [[ "${SWIFTPM_BUILD_TYPE}" == "Release" ]] ; then
swiftpm_bootstrap_command+=(--release)
fi
if [[ "${VERBOSE_BUILD}" ]] ; then
swiftpm_bootstrap_command+=(-v)
fi
# FIXME CROSSCOMPILING:
# SwiftPM needs to be told about the target, sysroot and linker to use
# when cross-compiling
swiftpm_bootstrap_command+=(
--swiftc="${SWIFTC_BIN}"
--sbt="${LLBUILD_BIN}"
--build="$(build_directory ${host} swiftpm)")

# Add flags to link llbuild.
LLBUILD_BUILD_DIR="$(build_directory ${host} llbuild)"
swiftpm_bootstrap_command+=(
--link-llbuild
--llbuild-source-dir="${LLBUILD_SOURCE_DIR}"
--llbuild-build-dir="${LLBUILD_BUILD_DIR}"
)

if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
swiftpm_bootstrap_command+=( --foundation="${FOUNDATION_BUILD_DIR}" )
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
swiftpm_bootstrap_command+=(
$LIBDISPATCH_BUILD_ARGS)
fi
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
swiftpm_bootstrap_command+=(
--xctest="${XCTEST_BUILD_DIR}")
fi
fi
}

function swiftpm_find_tool() {
tool=$1
if [[ "${SKIP_BUILD_SWIFTPM}" ]]; then
echo "$(xcrun_find_tool ${tool})"
else
echo "$(build_directory_bin ${LOCAL_HOST} swiftpm)/${tool}"
fi
}

#
# Configure and build each product
#
Expand Down Expand Up @@ -2436,13 +2335,6 @@ for host in "${ALL_HOSTS[@]}"; do
-DLIBDISPATCH_SOURCE_DIR:PATH="${LIBDISPATCH_SOURCE_DIR}"
)
;;
swiftpm)
set_swiftpm_bootstrap_command
call "${swiftpm_bootstrap_command[@]}"

# swiftpm installs itself with a bootstrap method. No further cmake building is performed.
continue
;;
xctest)
SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
Expand Down Expand Up @@ -2935,16 +2827,6 @@ for host in "${ALL_HOSTS[@]}"; do
results_targets=("test")
executable_target=""
;;
swiftpm)
if [[ "${SKIP_TEST_SWIFTPM}" ]]; then
continue
fi
echo "--- Running tests for ${product} ---"
set_swiftpm_bootstrap_command
call "${swiftpm_bootstrap_command[@]}" test --test-parallel
# As swiftpm tests itself, we break early here.
continue
;;
xctest)
if [[ "${SKIP_TEST_XCTEST}" ]]; then
continue
Expand Down Expand Up @@ -3246,21 +3128,6 @@ for host in "${ALL_HOSTS[@]}"; do
exit 1
fi
;;
swiftpm)
if [[ -z "${INSTALL_SWIFTPM}" ]] ; then
continue
fi
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
echo "--install-destdir is required to install products."
exit 1
fi

echo "--- Installing ${product} ---"
set_swiftpm_bootstrap_command
call "${swiftpm_bootstrap_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
# As swiftpm bootstraps the installation itself, we break early here.
continue
;;
xctest)
if [[ -z "${INSTALL_XCTEST}" ]] ; then
continue
Expand Down
6 changes: 6 additions & 0 deletions utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def _apply_default_arguments(args):
args.test_tvos = False
args.test_watchos = False
args.test_android = False
args.test_swiftpm = False
args.test_swiftsyntax = False
args.test_indexstoredb = False
args.test_sourcekitlsp = False
Expand Down Expand Up @@ -557,6 +558,9 @@ def create_argument_parser():
option(['-p', '--swiftpm'], store_true('build_swiftpm'),
help='build swiftpm')

option(['--install-swiftpm'], toggle_true('install_swiftpm'),
help='install swiftpm')

option(['--swiftsyntax'], store_true('build_swiftsyntax'),
help='build swiftSyntax')

Expand Down Expand Up @@ -968,6 +972,8 @@ def create_argument_parser():
help='skip testing Android device targets on the host machine (the '
'phone itself)')

option('--skip-test-swiftpm', toggle_false('test_swiftpm'),
help='skip testing swiftpm')
option('--skip-test-swiftsyntax', toggle_false('test_swiftsyntax'),
help='skip testing SwiftSyntax')
option('--skip-test-indexstore-db', toggle_false('test_indexstoredb'),
Expand Down
4 changes: 4 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
'build_swiftevolve': False,
'build_indexstoredb': False,
'build_sourcekitlsp': False,
'install_swiftpm': False,
'install_swiftsyntax': False,
'skip_install_swiftsyntax_module': False,
'swiftsyntax_verify_generated_files': False,
Expand Down Expand Up @@ -208,6 +209,7 @@
'test_watchos': False,
'test_watchos_host': False,
'test_watchos_simulator': False,
'test_swiftpm': False,
'test_swiftsyntax': False,
'test_indexstoredb': False,
'test_sourcekitlsp': False,
Expand Down Expand Up @@ -485,6 +487,7 @@ class BuildScriptImplOption(_BaseOption):
dest='skip_install_swiftsyntax_module'),
EnableOption('--swiftsyntax-verify-generated-files',
dest='swiftsyntax_verify_generated_files'),
EnableOption('--install-swiftpm', dest='install_swiftpm'),
EnableOption('--install-sourcekit-lsp', dest='install_sourcekitlsp'),
EnableOption('--install-skstresstester', dest='install_skstresstester'),
EnableOption('--install-swiftevolve', dest='install_swiftevolve'),
Expand Down Expand Up @@ -542,6 +545,7 @@ class BuildScriptImplOption(_BaseOption):
DisableOption('--skip-test-watchos-host', dest='test_watchos_host'),
DisableOption('--skip-test-watchos-simulator',
dest='test_watchos_simulator'),
DisableOption('--skip-test-swiftpm', dest='test_swiftpm'),
DisableOption('--skip-test-swiftsyntax', dest='test_swiftsyntax'),
DisableOption('--skip-test-indexstore-db', dest='test_indexstoredb'),
DisableOption('--skip-test-sourcekit-lsp', dest='test_sourcekitlsp'),
Expand Down
Loading