Skip to content

[build-script] Add an option to build the Foundation tests in another mode #78390

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ indexstore-db
sourcekit-lsp
swiftdocc
lit-args=-v --time-tests
foundation-tests-build-type=Debug

# rdar://problem/31454823
lldb-test-swift-only
Expand All @@ -935,6 +936,11 @@ mixin-preset=

skip-test-swiftdocc

[preset: buildbot_linux,release_foundation_tests]
mixin-preset=buildbot_linux

foundation-tests-build-type=Release

[preset: buildbot_linux_crosscompile_wasm]
mixin-preset=buildbot_linux

Expand Down Expand Up @@ -1095,6 +1101,7 @@ reconfigure
test-optimized
skip-test-swiftdocc
lldb-test-swift-only
foundation-tests-build-type=Debug

# gcc version on amazon linux 2 is too old to configure and build tablegen.
# Use the clang that we install in the path for macros
Expand Down Expand Up @@ -1203,6 +1210,7 @@ swiftsyntax
swiftformat
indexstore-db
sourcekit-lsp
foundation-tests-build-type=Debug

install-llvm
install-static-linux-config
Expand Down
9 changes: 9 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def _apply_default_arguments(args):
if args.foundation_build_variant is None:
args.foundation_build_variant = args.build_variant

if args.foundation_tests_build_variant is None:
args.foundation_tests_build_variant = args.build_variant

if args.libdispatch_build_variant is None:
args.libdispatch_build_variant = args.build_variant

Expand Down Expand Up @@ -955,6 +958,12 @@ def create_argument_parser():
const='Debug',
help='build the Debug variant of Foundation')

option('--foundation-tests-build-type', store('foundation_tests_build_variant'),
choices=['Debug', 'Release'],
default=None,
help='build the Foundation tests in a certain variant '
'(Debug builds much faster)')

option('--debug-libdispatch', store('libdispatch_build_variant'),
const='Debug',
help='build the Debug variant of libdispatch')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def test_implied_defaults_build_variant(self):

self.assertEqual(namespace.cmark_build_variant, 'Debug')
self.assertEqual(namespace.foundation_build_variant, 'Debug')
self.assertEqual(namespace.foundation_tests_build_variant, 'Debug')
self.assertEqual(namespace.libdispatch_build_variant, 'Debug')
self.assertEqual(namespace.lldb_build_variant, 'Debug')
self.assertEqual(namespace.llvm_build_variant, 'Debug')
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
'swift_debuginfo_non_lto_args': None,
'force_optimized_typechecker': False,
'foundation_build_variant': 'Debug',
'foundation_tests_build_variant': 'Debug',
'host_cc': None,
'host_cxx': None,
'host_libtool': None,
Expand Down Expand Up @@ -783,6 +784,8 @@ class BuildScriptImplOption(_BaseOption):
choices=['false', 'not-merged', 'merged']),
ChoicesOption('--android-arch',
choices=['armv7', 'aarch64', 'x86_64']),
ChoicesOption('--foundation-tests-build-type',
dest='foundation_tests_build_variant', choices=['Debug', 'Release']),

StrOption('--android-api-level'),
StrOption('--build-args'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def should_test(self, host_target):
return self.args.test_foundation

def configuration(self):
return 'release' if self.is_release() else 'debug'
if self.args.foundation_tests_build_variant in ['Release', 'RelWithDebInfo']:
return 'release'
else:
return 'debug'

def test(self, host_target):
swift_exec = os.path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def should_test(self, host_target):
return self.args.test_foundation

def configuration(self):
return 'release' if self.is_release() else 'debug'
if self.args.foundation_tests_build_variant in ['Release', 'RelWithDebInfo']:
return 'release'
else:
return 'debug'

def test(self, host_target):
swift_exec = os.path.join(
Expand Down