Skip to content

rewrite swiftSettings to avoid causing SPM build failures #358

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

Merged
merged 5 commits into from
Mar 2, 2022
Merged
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
20 changes: 11 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
import PackageDescription
import Foundation

var swiftSyntaxUnsafeSwiftFlags: [String] = []

/// If we are in a controlled CI environment, we can use internal compiler flags
/// to speed up the build or improve it.
let swiftSyntaxSwiftSettings: [SwiftSetting]
if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil {
let groupFile = URL(fileURLWithPath: #file)
.deletingLastPathComponent()
.appendingPathComponent("utils")
.appendingPathComponent("group.json")

swiftSyntaxUnsafeSwiftFlags += ["-Xfrontend", "-group-info-path",
"-Xfrontend", groupFile.path]
// Enforcing exclusivity increases compile time of release builds by 2 minutes.
// Disable it when we're in a controlled CI environment.
swiftSyntaxUnsafeSwiftFlags += ["-enforce-exclusivity=unchecked"]
swiftSyntaxSwiftSettings = [.unsafeFlags([
"-Xfrontend", "-group-info-path",
"-Xfrontend", groupFile.path,
// Enforcing exclusivity increases compile time of release builds by 2 minutes.
// Disable it when we're in a controlled CI environment.
"-enforce-exclusivity=unchecked",
])]
} else {
swiftSyntaxSwiftSettings = []
}

let package = Package(
Expand Down Expand Up @@ -54,7 +56,7 @@ let package = Package(
"SyntaxNodes.swift.gyb.template",
"SyntaxKind.swift.gyb",
],
swiftSettings: [.unsafeFlags(swiftSyntaxUnsafeSwiftFlags)]
swiftSettings: swiftSyntaxSwiftSettings
),
.target(
name: "SwiftSyntaxBuilder",
Expand Down