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

Build and install swift-testing in toolchains #74582

Closed
wants to merge 6 commits into from
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
10 changes: 8 additions & 2 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ mixin-preset=
llbuild
swiftpm
swift-driver
swift-testing
xctest
libicu
swiftdocc
Expand All @@ -853,6 +854,7 @@ install-llbuild
install-swiftpm
install-swift-driver
install-swiftsyntax
install-swift-testing
install-xctest
install-libicu
install-prefix=/usr
Expand All @@ -867,7 +869,8 @@ build-embedded-stdlib-cross-compiling
# Executes the lit tests for the installable package that is created
# Assumes the swift-integration-tests repo is checked out

test-installable-package
# TODO: Re-enable this before landing!
#test-installable-package

# Build the benchmarks against the toolchain.
toolchain-benchmarks
Expand Down Expand Up @@ -1324,6 +1327,7 @@ swift-driver
# Failing to build in CI: rdar://78408440
# swift-inspect
swiftsyntax
swift-testing
swiftformat
playgroundsupport
indexstore-db
Expand Down Expand Up @@ -1368,6 +1372,7 @@ install-llbuild
install-swiftpm
install-swift-driver
install-swiftsyntax
install-swift-testing
install-playgroundsupport
install-sourcekit-lsp
install-swiftformat
Expand All @@ -1387,7 +1392,8 @@ install-prefix=%(install_toolchain_dir)s/usr
# Executes the lit tests for the installable package that is created
# Assumes the swift-integration-tests repo is checked out

test-installable-package
# TODO: Re-enable this before landing!
#test-installable-package

# Make sure that we can build the benchmarks with swiftpm against the toolchain
toolchain-benchmarks
Expand Down
5 changes: 5 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ def create_argument_parser():
option(['--wasmkit'], toggle_true('build_wasmkit'),
help='build WasmKit')

option('--swift-testing', toggle_true('build_swift_testing'),
help='build Swift Testing')
option('--install-swift-testing', toggle_true('install_swift_testing'),
help='install Swift Testing')

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

Expand Down
1 change: 1 addition & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
'build_swiftpm': False,
'build_swift_driver': False,
'build_swift_libexec': True,
'build_swift_testing': False,
'build_early_swift_driver': True,
'build_early_swiftsyntax': True,
'build_swiftsyntax': False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ def compute_product_pipelines(self):
is_enabled=self.args.build_swiftpm)
builder.add_product(products.SwiftSyntax,
is_enabled=self.args.build_swiftsyntax)
builder.add_product(products.SwiftTesting,
is_enabled=self.args.build_swift_testing)
builder.add_product(products.SwiftFormat,
is_enabled=self.args.build_swiftformat)
builder.add_product(products.SKStressTester,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def add_product(self, product_cls, is_enabled):
self.current_pipeline.append(product_cls, is_enabled)

def add_impl_product(self, product_cls, is_enabled):
"""Add a non-impl product to the current pipeline begin constructed"""
"""Add an impl product to the current pipeline begin constructed"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

assert self.current_pipeline is not None
assert self.is_current_pipeline_impl
assert product_cls.is_build_script_impl_product()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .sourcekitlsp import SourceKitLSP
from .staticswiftlinux import StaticSwiftLinuxConfig
from .swift import Swift
from .swift_testing import SwiftTesting
from .swiftdocc import SwiftDocC
from .swiftdoccrender import SwiftDocCRender
from .swiftdriver import SwiftDriver
Expand Down Expand Up @@ -66,6 +67,7 @@
'SwiftInspect',
'SwiftPM',
'SwiftDriver',
'SwiftTesting',
'EarlySwiftDriver',
'XCTest',
'SwiftSyntax',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# swift_build_support/products/swift_testing.py -----------------*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2024 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ----------------------------------------------------------------------------

import os

from . import cmake_product
from . import swift
from . import swiftsyntax

class SwiftTesting(cmake_product.CMakeProduct):
@classmethod
def is_build_script_impl_product(cls):
return False

@classmethod
def is_before_build_script_impl_product(cls):
return False

@classmethod
def product_source_name(cls):
return "swift-testing"

@classmethod
def get_dependencies(cls):
return [swift.Swift,
swiftsyntax.SwiftSyntax]
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to wait for SwiftSyntax -- in the build we are using the swift syntax libraries that we build in the Swift compiler for plugins

Suggested change
return [swift.Swift,
swiftsyntax.SwiftSyntax]
return [swift.Swift]


def should_build(self, host_target):
return True

def build(self, host_target):
self.cmake_options.define('BUILD_SHARED_LIBS', 'YES')

# Use empty CMake install prefix, since the `DESTDIR` env var is set by
# `install_with_cmake` later which already has the same prefix.
self.cmake_options.define('CMAKE_INSTALL_PREFIX', '')

build_root = os.path.dirname(self.build_dir)
swift_build_dir = os.path.join(
'..', build_root, '%s-%s' % ('swift', host_target))
swift_cmake_dir = os.path.join(swift_build_dir, 'cmake', 'modules')
self.cmake_options.define('SwiftSyntax_DIR:PATH', swift_cmake_dir)

self.build_with_cmake([], self.args.build_variant, [],
prefer_native_toolchain=True)

def should_test(self, host_target):
# TODO
return False

def should_install(self, host_target):
return self.args.install_swift_testing

def install(self, host_target):
install_destdir = self.host_install_destdir(host_target)
install_prefix = install_destdir + self.args.install_prefix

self.install_with_cmake(['install'], install_prefix)
3 changes: 3 additions & 0 deletions utils/update_checkout/update-checkout-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"remote": { "id": "apple/swift-system" } },
"swift-stress-tester": {
"remote": { "id": "swiftlang/swift-stress-tester" } },
"swift-testing": {
"remote": { "id": "apple/swift-testing" } },
"swift-corelibs-xctest": {
"remote": { "id": "apple/swift-corelibs-xctest" } },
"swift-corelibs-foundation": {
Expand Down Expand Up @@ -138,6 +140,7 @@
"swift-syntax": "main",
"swift-system": "1.3.0",
"swift-stress-tester": "main",
"swift-testing": "main",
"swift-corelibs-xctest": "main",
"swift-corelibs-foundation": "main",
"swift-corelibs-foundation-windows": "windows/main",
Expand Down