diff --git a/Package.swift b/Package.swift index 59c23fe321c..58c20deac1f 100644 --- a/Package.swift +++ b/Package.swift @@ -45,18 +45,18 @@ let package = Package( .macCatalyst(.v13), ], products: [ - .library(name: "SwiftCompilerPlugin", type: .static, targets: ["SwiftCompilerPlugin"]), - .library(name: "SwiftCompilerPluginMessageHandling", type: .static, targets: ["SwiftCompilerPluginMessageHandling"]), - .library(name: "SwiftDiagnostics", type: .static, targets: ["SwiftDiagnostics"]), - .library(name: "SwiftIDEUtils", type: .static, targets: ["SwiftIDEUtils"]), - .library(name: "SwiftOperators", type: .static, targets: ["SwiftOperators"]), - .library(name: "SwiftParser", type: .static, targets: ["SwiftParser"]), - .library(name: "SwiftParserDiagnostics", type: .static, targets: ["SwiftParserDiagnostics"]), - .library(name: "SwiftRefactor", type: .static, targets: ["SwiftRefactor"]), - .library(name: "SwiftSyntax", type: .static, targets: ["SwiftSyntax"]), - .library(name: "SwiftSyntaxBuilder", type: .static, targets: ["SwiftSyntaxBuilder"]), - .library(name: "SwiftSyntaxMacros", type: .static, targets: ["SwiftSyntaxMacros"]), - .library(name: "SwiftSyntaxMacrosTestSupport", type: .static, targets: ["SwiftSyntaxMacrosTestSupport"]), + .library(name: "SwiftCompilerPlugin", targets: ["SwiftCompilerPlugin"]), + .library(name: "SwiftCompilerPluginMessageHandling", targets: ["SwiftCompilerPluginMessageHandling"]), + .library(name: "SwiftDiagnostics", targets: ["SwiftDiagnostics"]), + .library(name: "SwiftIDEUtils", targets: ["SwiftIDEUtils"]), + .library(name: "SwiftOperators", targets: ["SwiftOperators"]), + .library(name: "SwiftParser", targets: ["SwiftParser"]), + .library(name: "SwiftParserDiagnostics", targets: ["SwiftParserDiagnostics"]), + .library(name: "SwiftRefactor", targets: ["SwiftRefactor"]), + .library(name: "SwiftSyntax", targets: ["SwiftSyntax"]), + .library(name: "SwiftSyntaxBuilder", targets: ["SwiftSyntaxBuilder"]), + .library(name: "SwiftSyntaxMacros", targets: ["SwiftSyntaxMacros"]), + .library(name: "SwiftSyntaxMacrosTestSupport", targets: ["SwiftSyntaxMacrosTestSupport"]), ], targets: [ // MARK: - Internal helper targets @@ -277,6 +277,22 @@ let package = Package( ] ) +// This is a fake target that depends on all targets in the package. +// We need to define it manually because the `SwiftSyntax-Package` target doesn't exist for `swift build`. + +package.targets.append( + .target( + name: "SwiftSyntax-all", + dependencies: package.targets.compactMap { + if $0.type == .test { + return nil + } else { + return .byName(name: $0.name) + } + } + ) +) + if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { // Building standalone. package.dependencies += [ diff --git a/Sources/SwiftSyntax-all/empty.swift b/Sources/SwiftSyntax-all/empty.swift new file mode 100644 index 00000000000..f98a8033888 --- /dev/null +++ b/Sources/SwiftSyntax-all/empty.swift @@ -0,0 +1,2 @@ +// This is a fake target that depends on all targets in the package. +// We need to define it manually because the `SwiftSyntax-Package` target doesn't exist for `swift build`. diff --git a/build-script.py b/build-script.py index 2b0dce497ca..3322b9e84ea 100755 --- a/build-script.py +++ b/build-script.py @@ -215,15 +215,19 @@ def __get_swiftpm_invocation(self, package_dir: str) -> List[str]: def buildProduct(self, product_name: str) -> None: print("** Building product " + product_name + " **") - self.__build(PACKAGE_DIR, product_name) + self.__build(PACKAGE_DIR, product_name, is_product=True) + + def buildTarget(self, target_name: str) -> None: + print("** Building target " + target_name + " **") + self.__build(PACKAGE_DIR, target_name, is_product=False) def buildExample(self, example_name: str) -> None: print("** Building example " + example_name + " **") - self.__build(EXAMPLES_DIR, example_name) + self.__build(EXAMPLES_DIR, example_name, is_product=True) - def __build(self, package_dir: str, product_name: str) -> None: + def __build(self, package_dir: str, name: str, is_product: bool) -> None: command = list(self.__get_swiftpm_invocation(package_dir)) - command.extend(["--product", product_name]) + command.extend(["--product" if is_product else "--target", name]) env = dict(os.environ) env["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] = "1" @@ -499,10 +503,7 @@ def build_command(args: argparse.Namespace) -> None: verbose=args.verbose, disable_sandbox=args.disable_sandbox, ) - # Until rdar://53881101 is implemented, we cannot request a build of multiple - # targets simultaneously. For now, just build one product after the other. - builder.buildProduct("SwiftSyntax") - builder.buildProduct("SwiftSyntaxBuilder") + builder.buildTarget("SwiftSyntax-all") # Build examples builder.buildExample("AddOneToIntegerLiterals")