Skip to content

Commit ae5af43

Browse files
committed
Enable a fully statically linked Linux executable
If SwiftLint is built from this state using the Swift SDK, we'll get a large self-contained Linux executable that runs without loading SourceKit. It can do that by disabling any rule that requires SourceKit. With `SWIFTLINT_DISABLE_SOURCEKIT` set on a normally (dynamically linked) binary, the behavior is the same. That's different from the previously reported more serious warnings.
1 parent da74086 commit ae5af43

22 files changed

+104
-12
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
to avoid confusion with the new `swiftlint_linux_arm64.zip` archive.
4747
[Bradley Mackey](https://github.com/bradleymackey)
4848
[SimplyDanny](https://github.com/SimplyDanny)
49+
50+
* If `SWIFTLINT_DISABLE_SOURCEKIT` is set to prohibit loading `libsourcekitdInProc` at runtime,
51+
rules requiring SourceKit will be disabled and a warning will be printed once per rule.
52+
[SimplyDanny](https://github.com/SimplyDanny)
4953

5054
### Experimental
5155

@@ -169,6 +173,13 @@
169173
[p4checo](https://github.com/p4checo)
170174
[#5965](https://github.com/realm/SwiftLint/issues/5965)
171175

176+
* A fully statically linked Linux binary can now be built with the Swift SDK and
177+
the compiler options `-Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT`. This binary does not
178+
require `libsourcekitdInProc.so` or any other dynamic libraries to be present on the
179+
system at runtime. Rules requiring SourceKit will be disabled and reported to the console
180+
when running this binary.
181+
[SimplyDanny](https://github.com/SimplyDanny)
182+
172183
### Bug Fixes
173184

174185
* Fix `no_extension_access_modifier` rule incorrectly triggering for `nonisolated extension`.

Source/SwiftLintBuiltInRules/Rules/Lint/QuickDiscouragedCallRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SourceKittenFramework
22

3+
@DisabledWithoutSourceKit
34
struct QuickDiscouragedCallRule: OptInRule {
45
var configuration = SeverityConfiguration<Self>(.warning)
56

Source/SwiftLintBuiltInRules/Rules/Lint/UnusedImportRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import SourceKittenFramework
33

44
private let moduleToLog = ProcessInfo.processInfo.environment["SWIFTLINT_LOG_MODULE_USAGE"]
55

6+
@DisabledWithoutSourceKit
67
struct UnusedImportRule: CorrectableRule, AnalyzerRule {
78
var configuration = UnusedImportConfiguration()
89

Source/SwiftLintBuiltInRules/Rules/Style/FileTypesOrderRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import SourceKittenFramework
33

44
private typealias FileTypeOffset = (fileType: FileTypesOrderConfiguration.FileType, offset: ByteCount)
55

6+
@DisabledWithoutSourceKit
67
struct FileTypesOrderRule: OptInRule {
78
var configuration = FileTypesOrderConfiguration()
89

Source/SwiftLintBuiltInRules/Rules/Style/IndentationWidthRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SourceKittenFramework
33

4+
@DisabledWithoutSourceKit
45
struct IndentationWidthRule: OptInRule {
56
// MARK: - Subtypes
67
private enum Indentation: Equatable {

Source/SwiftLintBuiltInRules/Rules/Style/LiteralExpressionEndIndentationRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SourceKittenFramework
33

4+
@DisabledWithoutSourceKit
45
struct LiteralExpressionEndIndentationRule: Rule, OptInRule {
56
var configuration = SeverityConfiguration<Self>(.warning)
67

Source/SwiftLintBuiltInRules/Rules/Style/ModifierOrderRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SourceKittenFramework
33

4+
@DisabledWithoutSourceKit
45
struct ModifierOrderRule: ASTRule, OptInRule, CorrectableRule {
56
var configuration = ModifierOrderConfiguration()
67

Source/SwiftLintBuiltInRules/Rules/Style/MultilineFunctionChainsRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SourceKittenFramework
33

4+
@DisabledWithoutSourceKit
45
struct MultilineFunctionChainsRule: ASTRule, OptInRule {
56
var configuration = SeverityConfiguration<Self>(.warning)
67

Source/SwiftLintBuiltInRules/Rules/Style/MultilineParametersBracketsRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import SourceKittenFramework
33

4+
@DisabledWithoutSourceKit
45
struct MultilineParametersBracketsRule: OptInRule {
56
var configuration = SeverityConfiguration<Self>(.warning)
67

Source/SwiftLintBuiltInRules/Rules/Style/SortedImportsRule.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private extension Sequence where Element == Line {
5252
}
5353
}
5454

55+
@DisabledWithoutSourceKit
5556
struct SortedImportsRule: CorrectableRule, OptInRule {
5657
var configuration = SortedImportsConfiguration()
5758

0 commit comments

Comments
 (0)