Skip to content

Rework swift-stress-tester repo building #21523

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
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: 3 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ llbuild
swiftpm
swiftsyntax
skstresstester
swiftevolve
playgroundsupport

# Build with debug info, this allows us to symbolicate crashes from
Expand All @@ -1050,6 +1051,7 @@ install-swiftpm
install-swiftsyntax
skip-install-swiftsyntax-module
install-skstresstester
install-swiftevolve
install-playgroundsupport

install-destdir=%(install_destdir)s
Expand Down Expand Up @@ -1158,6 +1160,7 @@ skip-test-cmark
skip-test-playgroundsupport
skip-test-swiftsyntax
skip-test-skstresstester
skip-test-swiftevolve

#===------------------------------------------------------------------------===#
# LLDB build configurations
Expand Down
4 changes: 4 additions & 0 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ class BuildScriptInvocation(object):
"--swiftpm-build-type", args.build_variant,
"--swiftsyntax-build-type", args.build_variant,
"--skstresstester-build-type", args.build_variant,
"--swiftevolve-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 @@ -602,6 +603,8 @@ class BuildScriptInvocation(object):
impl_args += ["--skip-build-swiftsyntax"]
if not args.build_skstresstester:
impl_args += ["--skip-build-skstresstester"]
if not args.build_swiftevolve:
impl_args += ["--skip-build-swiftevolve"]
if not args.build_playgroundsupport:
impl_args += ["--skip-build-playgroundsupport"]
if args.build_swift_dynamic_stdlib:
Expand Down Expand Up @@ -647,6 +650,7 @@ class BuildScriptInvocation(object):
"--skip-test-swiftpm",
"--skip-test-swiftsyntax",
"--skip-test-skstresstester",
"--skip-test-swiftevolve",
"--skip-test-xctest",
"--skip-test-foundation",
"--skip-test-libdispatch",
Expand Down
82 changes: 73 additions & 9 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ KNOWN_SETTINGS=(
swiftpm-build-type "Debug" "the build variant for swiftpm"
swiftsyntax-build-type "Debug" "the build variant for swiftSyntax"
skstresstester-build-type "Debug" "the build variant for the SourceKit stress tester"
swiftevolve-build-type "Debug" "the build variant for the swift-evolve tool"
llbuild-enable-assertions "1" "enable assertions in llbuild"
enable-asan "" "enable Address Sanitizer"
enable-ubsan "" "enable Undefined Behavior Sanitizer"
Expand Down Expand Up @@ -126,6 +127,7 @@ KNOWN_SETTINGS=(
skip-build-swiftpm "" "set to skip building swiftpm"
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
skip-build-skstresstester "" "set to skip building the SourceKit stress tester"
skip-build-swiftevolve "" "set to skip building the swift-evolve tool"
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 @@ -140,6 +142,7 @@ KNOWN_SETTINGS=(
skip-test-swiftpm "" "set to skip testing swiftpm"
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
skip-test-skstresstester "" "set to skip testing the SourceKit stress tester"
skip-test-swiftevolve "" "set to skip testing the swift-evolve tool"
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 @@ -197,6 +200,7 @@ KNOWN_SETTINGS=(
install-swiftsyntax "" "whether to install swiftsyntax"
skip-install-swiftsyntax-module "" "set to skip installing swiftsyntax modules"
install-skstresstester "" "whether to install the SourceKit stress tester"
install-swiftevolve "" "whether to install the swift-evolve tool"
install-xctest "" "whether to install xctest"
install-foundation "" "whether to install foundation"
install-libdispatch "" "whether to install libdispatch"
Expand Down Expand Up @@ -1177,7 +1181,9 @@ LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
SKSTRESSTESTER_SOURCE_DIR="${WORKSPACE}/swift-stress-tester/SourceKitStressTester"
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester"
SKSTRESSTESTER_SOURCE_DIR="${STRESSTEST_PACKAGE_DIR}/SourceKitStressTester"
SWIFTEVOLVE_SOURCE_DIR="${STRESSTEST_PACKAGE_DIR}/SwiftEvolve"
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
FOUNDATION_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
Expand Down Expand Up @@ -1251,14 +1257,17 @@ fi
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
fi
# The SourceKit stress tester is dependent on SwiftSyntax, so it must be added
# to the list of build products first.
# The SourceKit stress tester and swift-evolve are dependent on SwiftSyntax, so
# it must be added to the list of build products first.
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
fi
if [[ ! "${SKIP_BUILD_SKSTRESSTESTER}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" skstresstester)
fi
if [[ ! "${SKIP_BUILD_SWIFTEVOLVE}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" swiftevolve)
fi

# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
function contains_product() {
Expand Down Expand Up @@ -1572,6 +1581,9 @@ function build_directory_bin() {
skstresstester)
echo "${root}/${SKSTRESSTESTER_BUILD_TYPE}/bin"
;;
swiftevolve)
echo "${root}/${SWIFTEVOLVE_BUILD_TYPE}/bin"
;;
xctest)
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
;;
Expand Down Expand Up @@ -1717,6 +1729,9 @@ function cmake_config_opt() {
skstresstester)
echo "--config ${SKSTRESSTESTER_BUILD_TYPE}"
;;
swiftevolve)
echo "--config ${SWIFTEVOLVE_BUILD_TYPE}"
;;
xctest)
echo "--config ${XCTEST_BUILD_TYPE}"
;;
Expand Down Expand Up @@ -1826,9 +1841,12 @@ function set_swiftsyntax_build_command() {
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
}

function set_skstresstester_build_command() {
function set_stresstester_build_script_helper_command() {
local package_name="$1"
local package_build_type="$2"

if [ "${SKIP_BUILD_SWIFTSYNTAX}" ]; then
echo "Error: Cannot build the SourceKit stress tester without SwiftSyntax."
echo "Error: Cannot build $package_name without SwiftSyntax."
exit 1
fi

Expand All @@ -1837,16 +1855,17 @@ function set_skstresstester_build_command() {
swiftsyntax_config="release"
fi
local config="debug"
if [[ $(is_cmake_release_build_type "${SKSTRESSTESTER_BUILD_TYPE}") ]] ; then
if [[ $(is_cmake_release_build_type "${package_build_type}") ]] ; then
config="release"
fi

skstresstester_build_command=("${SKSTRESSTESTER_SOURCE_DIR}/Utilities/build-script-helper.py")
stresstester_build_script_helper_command=("${STRESSTEST_PACKAGE_DIR}/build-script-helper.py")
if [[ "${VERBOSE_BUILD}" ]] ; then
skstresstester_build_command+=(-v)
stresstester_build_script_helper_command+=(-v)
fi

skstresstester_build_command+=(
stresstester_build_script_helper_command+=(
--package-dir="${package_name}"
--build-dir="${build_dir}"
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
--swift-build-exec="${SWIFT_BUILD}"
Expand All @@ -1856,6 +1875,16 @@ function set_skstresstester_build_command() {
--config="${config}")
}

function set_skstresstester_build_command() {
set_stresstester_build_script_helper_command SourceKitStressTester "${SKSTRESSTESTER_BUILD_TYPE}"
skstresstester_build_command=("${stresstester_build_script_helper_command[@]}")
}

function set_swiftevolve_build_command() {
set_stresstester_build_script_helper_command SwiftEvolve "${SWIFTEVOLVE_BUILD_TYPE}"
swiftevolve_build_command=("${stresstester_build_script_helper_command[@]}")
}

# Construct the appropriate options to pass to an Xcode
# build of any LLDB target.
function set_lldb_xcodebuild_options() {
Expand Down Expand Up @@ -2544,6 +2573,16 @@ for host in "${ALL_HOSTS[@]}"; do
set_skstresstester_build_command
call "${skstresstester_build_command[@]}"

continue
;;
swiftevolve)
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "error: unable to build swift-evolve on this platform"
continue
fi
set_swiftevolve_build_command
call "${swiftevolve_build_command[@]}"

continue
;;
xctest)
Expand Down Expand Up @@ -3173,6 +3212,14 @@ for host in "${ALL_HOSTS[@]}"; do
call "${skstresstester_build_command[@]}" test
continue
;;
swiftevolve)
if [[ "${SKIP_TEST_SWIFTEVOLVE}" ]]; then
continue
fi
echo "--- Running tests for ${product} ---"
call "${swiftevolve_build_command[@]}" test
continue
;;
xctest)
if [[ "${SKIP_TEST_XCTEST}" ]]; then
continue
Expand Down Expand Up @@ -3517,6 +3564,23 @@ for host in "${ALL_HOSTS[@]}"; do
call "${skstresstester_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
continue
;;
swiftevolve)
if [[ -z "${INSTALL_SWIFTEVOLVE}" ]] ; then
continue
fi
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
echo "--install-destdir is required to install products."
exit 1
fi
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
echo "--install-swiftsyntax is required to install swift-evolve"
exit 1
fi

echo "--- Installing ${product} ---"
call "${swiftevolve_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
continue
;;
xctest)
if [[ -z "${INSTALL_XCTEST}" ]] ; then
continue
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ def create_argument_parser():
option(['--skstresstester'], store_true('build_skstresstester'),
help='build the SourceKit stress tester')

option(['--swiftevolve'], store_true('build_swiftevolve'),
help='build the swift-evolve tool')

option('--xctest', toggle_true('build_xctest'),
help='build xctest')

Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
'build_swiftpm': False,
'build_swiftsyntax': False,
'build_skstresstester': False,
'build_swiftevolve': False,
'build_tvos': True,
'build_tvos_device': False,
'build_tvos_simulator': False,
Expand Down Expand Up @@ -400,6 +401,7 @@ class IgnoreOption(_BaseOption):
SetTrueOption('--swiftpm', dest='build_swiftpm'),
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
SetTrueOption('--skstresstester', dest='build_skstresstester'),
SetTrueOption('--swiftevolve', dest='build_swiftevolve'),
SetTrueOption('-B', dest='benchmark'),
SetTrueOption('-S', dest='skip_build'),
SetTrueOption('-b', dest='build_llbuild'),
Expand Down