diff --git a/.circleci/config.pkl b/.circleci/config.pkl index ea478a5..d5b31f4 100644 --- a/.circleci/config.pkl +++ b/.circleci/config.pkl @@ -51,7 +51,7 @@ jobs { } new RunStep { name = "Check licenses" - command = "bazel run --config=circleci //scripts:hawkeye -- check --fail-if-unknown" + command = "bazel run --config=circleci //tools/lint/hawkeye -- check --fail-if-unknown" } new RunStep { name = "Gazelle" diff --git a/.circleci/config.yml b/.circleci/config.yml index bbb3c04..55d14a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: command: bazel run --config=circleci buildifier name: Buildifier lint - run: - command: bazel run --config=circleci //scripts:hawkeye -- check --fail-if-unknown + command: bazel run --config=circleci //tools/lint/hawkeye -- check --fail-if-unknown name: Check licenses - run: command: bazel run --config=circleci //:gazelle && git diff --exit-code diff --git a/BUILD.bazel b/BUILD.bazel index 1a634b6..705bf7a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -46,6 +46,7 @@ filegroup( buildifier_excludes = [ "./.git/*", "./.ijwb/*", + "./.bazelbsp/*", ] buildifier( diff --git a/MODULE.bazel b/MODULE.bazel index 1943796..e2bad82 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -114,33 +114,10 @@ use_repo( "build_bazel_bazel_8_2_1", ) -http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -hawkeye_coordinates = [ - { - "name": "hawkeye-aarch64-apple-darwin", - "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-aarch64-apple-darwin.tar.xz", - "sha256": "9f300ad84201e500c4eb09ed710239797d2a6a17de5b7c08e1d3af1704ca6bb7", - }, - { - "name": "hawkeye-x86_64-apple-darwin", - "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-apple-darwin.tar.xz", - "sha256": "6f8850adb9204b6218f4912fb987106a71fcd8d742ce20227697ddccc44cec38", - }, - { - "name": "hawkeye-x86_64-unknown-linux-gnu", - "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-unknown-linux-gnu.tar.xz", - "sha256": "d5b9d3cdb4293ac84fa27e5021c77b6c062c61071760ab05fcacfbec1ac14850", - }, -] - -[ - http_archive( - name = coords["name"], - build_file = "//scripts:hawkeye.BUILD", - sha256 = coords["sha256"], - strip_prefix = coords["name"], - url = coords["url"], - ) - for coords in hawkeye_coordinates -] +hawkeye = use_extension("//tools/lint/hawkeye:extensions.bzl", "hawkeye", dev_dependency = True) +use_repo( + hawkeye, + "hawkeye-aarch64-apple-darwin", + "hawkeye-x86_64-apple-darwin", + "hawkeye-x86_64-unknown-linux-gnu", +) diff --git a/licenserc.toml b/licenserc.toml index 9dc7b8d..a6c1000 100644 --- a/licenserc.toml +++ b/licenserc.toml @@ -1,4 +1,4 @@ -headerPath = "scripts/license-header.txt" +headerPath = "tools/lint/hawkeye/license-header.txt" includes = [ "*.BUILD", diff --git a/scripts/BUILD.bazel b/tools/lint/hawkeye/BUILD.bazel similarity index 91% rename from scripts/BUILD.bazel rename to tools/lint/hawkeye/BUILD.bazel index 43f625b..22bcf3b 100644 --- a/scripts/BUILD.bazel +++ b/tools/lint/hawkeye/BUILD.bazel @@ -16,13 +16,13 @@ You can check license files with: ``` -bazel run //scripts:hawkeye -- check --fail-if-unknown +bazel run //tools/lint/hawkeye -- check --fail-if-unknown ``` You can update header comments with: ``` -bazel run //scripts:hawkeye -- format --fail-if-unknown +bazel run //tools/lint/hawkeye -- format --fail-if-unknown ``` """ diff --git a/tools/lint/hawkeye/extensions.bzl b/tools/lint/hawkeye/extensions.bzl new file mode 100644 index 0000000..cc14151 --- /dev/null +++ b/tools/lint/hawkeye/extensions.bzl @@ -0,0 +1,47 @@ +# Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Hawkeye bzlmod extensions""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +HAWKEYE_COORDINATES = [ + { + "name": "hawkeye-aarch64-apple-darwin", + "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-aarch64-apple-darwin.tar.xz", + "sha256": "9f300ad84201e500c4eb09ed710239797d2a6a17de5b7c08e1d3af1704ca6bb7", + }, + { + "name": "hawkeye-x86_64-apple-darwin", + "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-apple-darwin.tar.xz", + "sha256": "6f8850adb9204b6218f4912fb987106a71fcd8d742ce20227697ddccc44cec38", + }, + { + "name": "hawkeye-x86_64-unknown-linux-gnu", + "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-unknown-linux-gnu.tar.xz", + "sha256": "d5b9d3cdb4293ac84fa27e5021c77b6c062c61071760ab05fcacfbec1ac14850", + }, +] + +def _hawkeye_impl(_ctx): + for coords in HAWKEYE_COORDINATES: + http_archive( + name = coords["name"], + build_file = "//tools/lint/hawkeye:hawkeye.BUILD", + sha256 = coords["sha256"], + strip_prefix = coords["name"], + url = coords["url"], + ) + +hawkeye = module_extension(implementation = _hawkeye_impl) diff --git a/scripts/hawkeye.BUILD b/tools/lint/hawkeye/hawkeye.BUILD similarity index 100% rename from scripts/hawkeye.BUILD rename to tools/lint/hawkeye/hawkeye.BUILD diff --git a/scripts/license-header.txt b/tools/lint/hawkeye/license-header.txt similarity index 100% rename from scripts/license-header.txt rename to tools/lint/hawkeye/license-header.txt