Skip to content

Commit

Permalink
Limit unsafe flags via environment (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Jan 22, 2024
1 parent 7d0a65e commit f478cb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
SWIFT_EMIT_EXTENSION_BLOCK_SYMBOLS: true

jobs:
pages:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
SWIFT_STRICT_CONCURRENCY: complete

jobs:
swift:
Expand Down
19 changes: 13 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ let package = Package(
targets: [
.target(
name: "Layout",
swiftSettings: [
.unsafeFlags([
"-strict-concurrency=complete",
"-emit-extension-block-symbols"
]),
],
swiftSettings: .swiftSettings,
plugins: [
.plugin(name: SwiftLint.plugin),
]),
Expand Down Expand Up @@ -66,3 +61,15 @@ let package = Package(
checksum: "963121d6babf2bf5fd66a21ac9297e86d855cbc9d28322790646b88dceca00f1"),
]
)

extension Array where Element == SwiftSetting {

static var swiftSettings: [SwiftSetting] {
if let value: String = Context.environment["SWIFT_STRICT_CONCURRENCY"] {
return [.unsafeFlags(["-strict-concurrency=\(value)"])]
} else if Context.environment["SWIFT_EMIT_EXTENSION_BLOCK_SYMBOLS"] != nil {
return [.unsafeFlags(["-emit-extension-block-symbols"])]
}
return []
}
}

0 comments on commit f478cb6

Please sign in to comment.