Skip to content

Commit 8c2ac6b

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 8c2ac6b

22 files changed

+102
-14
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44

55
### Breaking
66

7-
* None.
7+
* If `SWIFTLINT_DISABLE_SOURCEKIT` is set to prohibit loading `libsourcekitdInProc` at runtime,
8+
rules requiring SourceKit will be disabled and a warning will be printed once per rule.
9+
[SimplyDanny](https://github.com/SimplyDanny)
810

911
### Experimental
1012

1113
* None.
1214

1315
### Enhancements
1416

15-
* None.
17+
* A fully statically linked Linux binary can now be built with the Swift SDK and
18+
the compiler options `-Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT`. This binary does not
19+
require `libsourcekitdInProc.so` or any other dynamic libraries to be present on the
20+
system at runtime. Rules requiring SourceKit will be disabled and reported to the console
21+
when running this binary.
22+
[SimplyDanny](https://github.com/SimplyDanny)
1623

1724
### Bug Fixes
1825

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)