From a70c64efaaee926b7d8ca68a2a99233393f928f8 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 17 Apr 2023 15:00:23 -0700 Subject: [PATCH] [bazel] Remove custom SwiftSyntax BUILD file Something similar to this has been merged upstream instead now. This also renames the repo name to SwiftSyntax in preparation for it being in the BCR --- BUILD | 8 ++- MODULE.bazel | 2 +- bazel/SwiftSyntax.BUILD | 110 ---------------------------------------- bazel/opt_wrapper.bzl | 35 ------------- bazel/repos.bzl | 3 +- 5 files changed, 8 insertions(+), 150 deletions(-) delete mode 100644 bazel/SwiftSyntax.BUILD delete mode 100644 bazel/opt_wrapper.bzl diff --git a/BUILD b/BUILD index 32a64338f9..240d5973e2 100644 --- a/BUILD +++ b/BUILD @@ -21,8 +21,12 @@ swift_library( module_name = "SwiftLintFramework", visibility = ["//visibility:public"], deps = [ + "@SwiftSyntax//:IDEUtils_opt", + "@SwiftSyntax//:SwiftOperators_opt", + "@SwiftSyntax//:SwiftParserDiagnostics_opt", + "@SwiftSyntax//:SwiftSyntaxBuilder_opt", + "@SwiftSyntax//:SwiftSyntax_opt", "@com_github_jpsim_sourcekitten//:SourceKittenFramework", - "@com_github_apple_swift_syntax//:optlibs", "@sourcekitten_com_github_jpsim_yams//:Yams", "@swiftlint_com_github_scottrhoyt_swifty_text_table//:SwiftyTextTable", ] + select({ @@ -80,9 +84,9 @@ filegroup( filegroup( name = "release_files", srcs = [ - "MODULE.bazel", "BUILD", "LICENSE", + "MODULE.bazel", "//:LintInputs", "//Tests:BUILD", "//bazel:release_files", diff --git a/MODULE.bazel b/MODULE.bazel index c9a66434f1..0cb76636b8 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -17,7 +17,7 @@ bazel_dep(name = "yams", version = "5.0.5", repo_name = "sourcekitten_com_github swiftlint_repos = use_extension("//bazel:repos.bzl", "swiftlint_repos_bzlmod") use_repo( swiftlint_repos, - "com_github_apple_swift_syntax", + "SwiftSyntax", "com_github_johnsundell_collectionconcurrencykit", "com_github_krzyzanowskim_cryptoswift", "swiftlint_com_github_scottrhoyt_swifty_text_table", diff --git a/bazel/SwiftSyntax.BUILD b/bazel/SwiftSyntax.BUILD deleted file mode 100644 index 3665c8aded..0000000000 --- a/bazel/SwiftSyntax.BUILD +++ /dev/null @@ -1,110 +0,0 @@ -load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") -load("@SwiftLint//bazel:opt_wrapper.bzl", "opt_wrapper") - -swift_library( - name = "SwiftSyntax", - srcs = glob( - ["Sources/SwiftSyntax/**/*.swift"], - exclude = ["Sources/SwiftSyntax/Documentation.docc/**"], - ), - module_name = "SwiftSyntax", -) - -swift_library( - name = "SwiftBasicFormat", - srcs = glob(["Sources/SwiftBasicFormat/**/*.swift"]), - module_name = "SwiftBasicFormat", - deps = [":SwiftSyntax"], -) - -swift_library( - name = "SwiftDiagnostics", - srcs = glob(["Sources/SwiftDiagnostics/**/*.swift"]), - module_name = "SwiftDiagnostics", - deps = [":SwiftSyntax"], -) - -swift_library( - name = "SwiftParser", - srcs = glob(["Sources/SwiftParser/**/*.swift"]), - module_name = "SwiftParser", - deps = [ - ":SwiftDiagnostics", - ":SwiftSyntax", - ], -) - -swift_library( - name = "SwiftSyntaxBuilder", - srcs = glob(["Sources/SwiftSyntaxBuilder/**/*.swift"]), - module_name = "SwiftSyntaxBuilder", - deps = [ - ":SwiftBasicFormat", - ":SwiftParser", - ":SwiftParserDiagnostics", - ":SwiftSyntax", - ], -) - -swift_library( - name = "SwiftSyntaxParser", - srcs = glob(["Sources/SwiftSyntaxParser/**/*.swift"]), - module_name = "SwiftSyntaxParser", - deps = [ - ":SwiftParser", - ":SwiftSyntax", - ], -) - -swift_library( - name = "SwiftOperators", - srcs = glob(["Sources/SwiftOperators/**/*.swift"]), - module_name = "SwiftOperators", - deps = [ - ":SwiftDiagnostics", - ":SwiftParser", - ":SwiftSyntax", - ], -) - -swift_library( - name = "SwiftParserDiagnostics", - srcs = glob(["Sources/SwiftParserDiagnostics/**/*.swift"]), - module_name = "SwiftParserDiagnostics", - deps = [ - ":SwiftBasicFormat", - ":SwiftDiagnostics", - ":SwiftParser", - ":SwiftSyntax", - ], -) - -swift_library( - name = "SwiftRefactor", - srcs = glob(["Sources/SwiftRefactor/**/*.swift"]), - module_name = "SwiftRefactor", - deps = [ - ":SwiftParser", - ":SwiftSyntax", - ], -) - -swift_library( - name = "IDEUtils", - srcs = glob(["Sources/IDEUtils/**/*.swift"]), - module_name = "IDEUtils", - deps = [":SwiftSyntax"], -) - -opt_wrapper( - name = "optlibs", - visibility = ["//visibility:public"], - deps = [ - ":IDEUtils", - ":SwiftOperators", - ":SwiftParser", - ":SwiftParserDiagnostics", - ":SwiftSyntax", - ":SwiftSyntaxBuilder", - ], -) diff --git a/bazel/opt_wrapper.bzl b/bazel/opt_wrapper.bzl deleted file mode 100644 index 39b5be1fba..0000000000 --- a/bazel/opt_wrapper.bzl +++ /dev/null @@ -1,35 +0,0 @@ -load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_common") - -def _force_opt_impl(_settings, _attr): - return {"//command_line_option:compilation_mode": "opt"} - -_force_opt = transition( - implementation = _force_opt_impl, - inputs = [], - outputs = ["//command_line_option:compilation_mode"], -) - -def _impl(ctx): - ccinfos = [] - swiftinfos = [] - - for dep in ctx.attr.deps: - ccinfos.append(dep[CcInfo]) - swiftinfos.append(dep[SwiftInfo]) - - return [ - cc_common.merge_cc_infos(direct_cc_infos = ccinfos), - swift_common.create_swift_info(swift_infos = swiftinfos), - ] - -opt_wrapper = rule( - implementation = _impl, - attrs = { - "deps": attr.label_list( - cfg = _force_opt, - ), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - ), - }, -) diff --git a/bazel/repos.bzl b/bazel/repos.bzl index e48191612b..4a12018d73 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -20,8 +20,7 @@ def swiftlint_repos(bzlmod = False): http_archive( name = "com_github_apple_swift_syntax", - sha256 = "3b9380abc9a3d15fc718d87f1c278d978078d777bb03e3861b904aad6ef6bb54", # SwiftSyntax sha256 - build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD", + sha256 = "3b9380abc9a3d15fc718d87f1c278d978078d777bb03e3861b904aad6ef6bb54", # SwiftSyntax sha256 strip_prefix = "swift-syntax-509.0.0-swift-5.9-DEVELOPMENT-SNAPSHOT-2023-04-10-a", url = "https://github.com/apple/swift-syntax/archive/refs/tags/509.0.0-swift-5.9-DEVELOPMENT-SNAPSHOT-2023-04-10-a.tar.gz", )