|
| 1 | +// swift-tools-version:5.3 |
| 2 | +//===--- Package.swift.in - SwiftCompiler SwiftPM package -----------------===// |
| 3 | +// |
| 4 | +// This source file is part of the Swift.org open source project |
| 5 | +// |
| 6 | +// Copyright (c) 2021 - 2022 Apple Inc. and the Swift project authors |
| 7 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 8 | +// |
| 9 | +// See https://swift.org/LICENSE.txt for license information |
| 10 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 11 | +// |
| 12 | +//===----------------------------------------------------------------------===// |
| 13 | + |
| 14 | +// NOTE: This 'Package.swift.in' file is for CMake configure_file(). |
| 15 | +// Generated 'Package.swift' can be found in |
| 16 | +// '${swift_build_dir}/SwiftCompilerSources/Package.swift'. |
| 17 | + |
| 18 | +import PackageDescription |
| 19 | + |
| 20 | +private extension Target { |
| 21 | + static let defaultSwiftSettings: [SwiftSetting] = [ |
| 22 | + .unsafeFlags([ |
| 23 | + "-Xfrontend", "-validate-tbd-against-ir=none", |
| 24 | + "-Xfrontend", "-enable-cxx-interop", |
| 25 | + // Bridging modules and headers |
| 26 | + "-Xcc", "-I", "-Xcc", "@SWIFT_SOURCE_DIR@/include", |
| 27 | + // Generated C headers |
| 28 | + "-Xcc", "-I", "-Xcc", "@CMAKE_BINARY_DIR@/include", |
| 29 | + "-cross-module-optimization" |
| 30 | + ]), |
| 31 | + ] |
| 32 | + |
| 33 | + static func compilerModuleTarget( |
| 34 | + name: String, |
| 35 | + dependencies: [Dependency], |
| 36 | + path: String? = nil, |
| 37 | + sources: [String]? = nil, |
| 38 | + swiftSettings: [SwiftSetting] = []) -> Target { |
| 39 | + .target( |
| 40 | + name: name, |
| 41 | + dependencies: dependencies, |
| 42 | + path: path ?? "@swiftcompiler_source_dir_name@/\(name)", |
| 43 | + exclude: ["CMakeLists.txt"], |
| 44 | + sources: sources, |
| 45 | + swiftSettings: defaultSwiftSettings + swiftSettings) |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +let package = Package( |
| 50 | + name: "SwiftCompilerSources", |
| 51 | + platforms: [ |
| 52 | + .macOS("10.9"), |
| 53 | + ], |
| 54 | + products: [ |
| 55 | + .library( |
| 56 | + name: "swiftCompilerModules", |
| 57 | + type: .static, |
| 58 | + targets: ["Basic", "AST", "Parse", "SIL", "Optimizer", "_CompilerRegexParser"]), |
| 59 | + ], |
| 60 | + dependencies: [ |
| 61 | + ], |
| 62 | + // Note that targets and their dependencies must align with |
| 63 | + // 'SwiftCompilerSources/Sources/CMakeLists.txt' |
| 64 | + targets: [ |
| 65 | + .compilerModuleTarget( |
| 66 | + name: "_CompilerRegexParser", |
| 67 | + dependencies: [], |
| 68 | + path: "_RegexParser_Sources", |
| 69 | + swiftSettings: [ |
| 70 | + // Workaround until `_CompilerRegexParser` is imported as implementation-only |
| 71 | + // by `_StringProcessing`. |
| 72 | + .unsafeFlags([ |
| 73 | + "-Xfrontend", |
| 74 | + "-disable-implicit-string-processing-module-import" |
| 75 | + ])]), |
| 76 | + .compilerModuleTarget( |
| 77 | + name: "Basic", |
| 78 | + dependencies: []), |
| 79 | + .compilerModuleTarget( |
| 80 | + name: "AST", |
| 81 | + dependencies: ["Basic"]), |
| 82 | + .compilerModuleTarget( |
| 83 | + name: "Parse", |
| 84 | + dependencies: ["Basic", "AST", "_CompilerRegexParser"]), |
| 85 | + .compilerModuleTarget( |
| 86 | + name: "SIL", |
| 87 | + dependencies: ["Basic"]), |
| 88 | + .compilerModuleTarget( |
| 89 | + name: "Optimizer", |
| 90 | + dependencies: ["Basic", "SIL", "Parse"]), |
| 91 | + ] |
| 92 | +) |
0 commit comments