Move extra rules into its own module (#4949)

This will decouple building extra rules from built-in rules so that
making changes in one of those modules doesn't rebuild the other.
This commit is contained in:
JP Simard
2023-04-27 10:37:30 -04:00
committed by GitHub
parent 86d60400c1
commit eaf34d7204
7 changed files with 25 additions and 6 deletions
+15 -2
View File
@@ -28,16 +28,29 @@ swift_library(
}),
)
swift_library(
name = "SwiftLintExtraRules",
srcs = [
"Source/SwiftLintExtraRules/Exports.swift",
"@swiftlint_extra_rules//:extra_rules",
],
module_name = "SwiftLintExtraRules",
visibility = ["//visibility:public"],
deps = [
":SwiftLintCore",
],
)
swift_library(
name = "SwiftLintFramework",
srcs = glob(
["Source/SwiftLintFramework/**/*.swift"],
exclude = ["Source/SwiftLintFramework/Rules/ExcludedFromBazel/ExtraRules.swift"],
) + ["@swiftlint_extra_rules//:extra_rules"],
),
module_name = "SwiftLintFramework",
visibility = ["//visibility:public"],
deps = [
":SwiftLintCore",
":SwiftLintExtraRules",
],
)
+5 -1
View File
@@ -58,9 +58,13 @@ let package = Package(
]
),
.target(
name: "SwiftLintFramework",
name: "SwiftLintExtraRules",
dependencies: ["SwiftLintCore"]
),
.target(
name: "SwiftLintFramework",
dependencies: ["SwiftLintCore", "SwiftLintExtraRules"]
),
.target(name: "DyldWarningWorkaround"),
.target(
name: "SwiftLintTestHelpers",
+1
View File
@@ -0,0 +1 @@
@_exported import SwiftLintCore
@@ -3,4 +3,4 @@
/// This is an extension point for custom native rules for Bazel.
///
/// - returns: Extra rules that are compiled with Bazel.
func extraRules() -> [Rule.Type] { [] }
public func extraRules() -> [Rule.Type] { [] }
+1
View File
@@ -1,4 +1,5 @@
@_exported import SwiftLintCore
import SwiftLintExtraRules
private let _registerAllRulesOnceImpl: Void = {
RuleRegistry.shared.register(rules: builtInRules + coreRules + extraRules())
+1 -1
View File
@@ -1,4 +1,4 @@
@testable import SwiftLintFramework
@testable import SwiftLintExtraRules
import SwiftLintTestHelpers
final class ExtraRulesTests: SwiftLintTestCase {
+1 -1
View File
@@ -3,7 +3,7 @@ load("@com_github_jpsim_sourcekitten//bazel:repos.bzl", "sourcekitten_repos")
def _extra_swift_sources_impl(ctx):
ctx.file("WORKSPACE", "")
ctx.file("empty.swift", "func extraRules() -> [Rule.Type] { [] }")
ctx.file("empty.swift", "public func extraRules() -> [Rule.Type] { [] }")
label = ":empty"
if ctx.attr.srcs:
label = ctx.attr.srcs