I have a mixed C++/Swift package that I want to build in CI.
The C++ portion needs to include headers from the swiftlang/swift repo, specifically the C++ target has the similar configuration as in SwiftCompilerSources:
private extension Target {
static func compilerModuleTarget(
name: String,
dependencies: [Dependency],
path: String? = nil,
sources: [String]? = nil,
swiftSettings: [SwiftSetting] = []) -> Target {
.target(
name: name,
dependencies: dependencies,
path: path ?? "Sources/\(name)",
exclude: ["CMakeLists.txt"],
sources: sources,
swiftSettings: [
.interoperabilityMode(.Cxx),
.unsafeFlags([
"-static",
"-Xcc", "-DCOMPILED_WITH_SWIFT", "-Xcc", "-DPURE_BRIDGING_MODE",
"-Xcc", "-UIBOutlet", "-Xcc", "-UIBAction", "-Xcc", "-UIBInspectable",
"-Xcc", "-I../include",
"-Xcc", "-I../../llvm-project/llvm/include",
"-Xcc", "-I../../llvm-project/clang/include",
"-Xcc", "-I../../build/Default/swift/include",
"-Xcc", "-I../../build/Default/llvm/include",
"-Xcc", "-I../../build/Default/llvm/tools/clang/include",
"-cross-module-optimization",
]),
] + swiftSettings)
}
}
This works perfectly well locally. I simply follow the Getting Started guide in the swiftlang/swift repo, calling utils/build-script with the same configuration as in the guide:
utils/build-script --skip-build-benchmarks \
--swift-darwin-supported-archs "$(uname -m)" \
--release-debuginfo --swift-disable-dead-stripping \
--bootstrapping=hosttools
The problem is this takes over 3 hours, and I would rather not build the whole thing from scratch every CI trigger when I just need some header files.
I’ve searched these forums and found two possible approaches:
- Use some build preset instead of the Getting Started configuration.
- Pass
–-skip-buildtoutils/build-scriptand then call Ninja directly.
So my questions are:
Is there a suggested build preset that would just build the header files. Or at least a preset that would skip as much as possible? Maybe [preset: buildbot,tools=RA,stdlib=RD,test=no]?
What Ninja targets would be appropriate? The Ninja swift target suggested elsewhere on these forums doesn’t seem to exist anymore.
Many thanks!