From d744b218f609f9390ef979198e9ad131374b7bbb Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Fri, 30 Jun 2023 13:05:40 +0200 Subject: [PATCH] Misc: add bazel buildifer pre-commit hook --- .pre-commit-config.yaml | 5 ++++ misc/bazel/workspace_deps.bzl | 4 +-- swift/codegen/BUILD.bazel | 10 +++---- swift/third_party/BUILD.binlog.bazel | 30 ++++++++++++------- .../BUILD.swift-llvm-support.bazel | 16 ++++++++-- swift/xcode-autobuilder/tests/BUILD.bazel | 27 ++++++++++------- 6 files changed, 61 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2cf6f530354..1a2ed103df6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,11 @@ repos: - id: autopep8 files: ^misc/codegen/.*\.py + - repo: https://github.com/warchant/pre-commit-buildifier + rev: 0.0.2 + hooks: + - id: buildifier + - repo: local hooks: - id: codeql-format diff --git a/misc/bazel/workspace_deps.bzl b/misc/bazel/workspace_deps.bzl index 674be778d78..ce91ee3959d 100644 --- a/misc/bazel/workspace_deps.bzl +++ b/misc/bazel/workspace_deps.bzl @@ -4,8 +4,8 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") def codeql_workspace_deps(repository_name = "codeql"): pip_install( - name = "codegen_deps", - requirements = "@%s//misc/codegen:requirements.txt" % repository_name, + name = "codegen_deps", + requirements = "@%s//misc/codegen:requirements.txt" % repository_name, ) bazel_skylib_workspace() rules_pkg_dependencies() diff --git a/swift/codegen/BUILD.bazel b/swift/codegen/BUILD.bazel index bc807e9329a..384d59b17e3 100644 --- a/swift/codegen/BUILD.bazel +++ b/swift/codegen/BUILD.bazel @@ -2,14 +2,14 @@ load("@bazel_skylib//rules:native_binary.bzl", "native_binary") native_binary( name = "codegen", - out = "codegen", src = "//misc/codegen", - data = [ - "//swift:schema", - "//swift:codegen_conf", - ], + out = "codegen", args = [ "--configuration-file=$(location //swift:codegen_conf)", ], + data = [ + "//swift:codegen_conf", + "//swift:schema", + ], visibility = ["//swift:__subpackages__"], ) diff --git a/swift/third_party/BUILD.binlog.bazel b/swift/third_party/BUILD.binlog.bazel index 71d42e45026..78db04fa3e2 100644 --- a/swift/third_party/BUILD.binlog.bazel +++ b/swift/third_party/BUILD.binlog.bazel @@ -1,19 +1,27 @@ cc_library( - name = "binlog", - hdrs = glob(["include/**/*.hpp"]), - srcs = glob(["include/**/*.cpp"]), - includes = ["include"], - visibility = ["//visibility:public"], + name = "binlog", + srcs = glob(["include/**/*.cpp"]), + hdrs = glob(["include/**/*.hpp"]), + includes = ["include"], + visibility = ["//visibility:public"], ) cc_binary( - name = "bread", - srcs = ["bin/bread.cpp", "bin/printers.hpp", "bin/printers.cpp", "bin/getopt.hpp"], - deps = [":binlog"], + name = "bread", + srcs = [ + "bin/bread.cpp", + "bin/getopt.hpp", + "bin/printers.cpp", + "bin/printers.hpp", + ], + deps = [":binlog"], ) cc_binary( - name = "brecovery", - srcs = ["bin/brecovery.cpp", "bin/getopt.hpp"], - deps = [":binlog"], + name = "brecovery", + srcs = [ + "bin/brecovery.cpp", + "bin/getopt.hpp", + ], + deps = [":binlog"], ) diff --git a/swift/third_party/BUILD.swift-llvm-support.bazel b/swift/third_party/BUILD.swift-llvm-support.bazel index 0a9068c4cf6..14530fcaac4 100644 --- a/swift/third_party/BUILD.swift-llvm-support.bazel +++ b/swift/third_party/BUILD.swift-llvm-support.bazel @@ -2,8 +2,19 @@ load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") cc_library( name = "swift-llvm-support", - srcs = glob(["*.a", "*.so", "*.dylib"]), - hdrs = glob(["include/**/*", "stdlib/**/*" ]), + srcs = glob([ + "*.a", + "*.so", + "*.dylib", + ]), + hdrs = glob([ + "include/**/*", + "stdlib/**/*", + ]), + includes = [ + "include", + "stdlib/public/SwiftShims", + ], linkopts = [ "-lm", "-lz", @@ -19,7 +30,6 @@ cc_library( ], "//conditions:default": [], }), - includes = ["include", "stdlib/public/SwiftShims"], visibility = ["//visibility:public"], ) diff --git a/swift/xcode-autobuilder/tests/BUILD.bazel b/swift/xcode-autobuilder/tests/BUILD.bazel index 579f96546cd..3013dd47a10 100644 --- a/swift/xcode-autobuilder/tests/BUILD.bazel +++ b/swift/xcode-autobuilder/tests/BUILD.bazel @@ -1,21 +1,28 @@ [ py_test( - name = test_dir + '-test', + name = test_dir + "-test", size = "small", - srcs = ['autobuild_tester.py'], - main = 'autobuild_tester.py', + srcs = ["autobuild_tester.py"], + args = [ + "$(location //swift/xcode-autobuilder)", + "$(location %s)" % test_dir, + ], data = [ "//swift/xcode-autobuilder", test_dir, - ] + glob([test_dir + '/**/*']), - args = [ - '$(location //swift/xcode-autobuilder)', - '$(location %s)' % test_dir, - ] + ] + glob([test_dir + "/**/*"]), + main = "autobuild_tester.py", + ) + for test_dir in glob( + ["*"], + exclude = [ + "*.*", + ".*", + ], + exclude_directories = 0, ) - for test_dir in glob(["*"], exclude_directories=0, exclude=['*.*', '.*']) ] test_suite( - name='tests' + name = "tests", )