Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default_applicable_license and remove obsolete licenses() in all BUILD files #504

Merged
merged 9 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
load("@rules_license//rules:license.bzl", "license")
load("//:bzl_library.bzl", "bzl_library")

licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)

package(default_visibility = ["//visibility:public"])
license(
name = "license",
package_name = "bazelbuild/bazel_skylib",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
)

# buildifier: disable=skylark-comment
# gazelle:exclude skylark_library.bzl
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ register_toolchains(
)

bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_license", version = "0.0.7")

### INTERNAL ONLY - lines after this are not included in the release packaging.

Expand Down
1 change: 1 addition & 0 deletions distribution/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("distribution.bzl", "remove_internal_only")

package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:private"],
)

Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//docs/private:stardoc_with_diff_test.bzl", "stardoc_with_diff_test", "update_docs")

licenses(["notice"])
package(default_applicable_licenses = ["//:license"])

stardoc_with_diff_test(
name = "analysis_test",
Expand Down
4 changes: 3 additions & 1 deletion docs/private/BUILD
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# No targets in this package
# This package only contains source targets

package(default_applicable_licenses = ["//:license"])
9 changes: 9 additions & 0 deletions gazelle/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_license//rules:license.bzl", "license")

package(default_applicable_licenses = ["@bazel_skylib//:license"])

license(
name = "license",
package_name = "bazelbuild/bazel_skylib_gazelle_module",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
)

exports_files(["WORKSPACE.bzlmod"])

Expand Down
3 changes: 2 additions & 1 deletion gazelle/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module(
)

# Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "gazelle", version = "0.29.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")

Expand Down
2 changes: 2 additions & 0 deletions gazelle/bzl/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

package(default_applicable_licenses = ["//:license"])

# gazelle:exclude testdata

go_library(
Expand Down
10 changes: 10 additions & 0 deletions gazelle/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ def bazel_skylib_gazelle_plugin_workspace():
"""Loads dependencies required to use skylib's gazelle plugin"""
bazel_skylib_workspace()

maybe(
http_archive,
name = "rules_license",
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
tetromino marked this conversation as resolved.
Show resolved Hide resolved
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
)

maybe(
http_archive,
name = "io_bazel_rules_go",
Expand Down
7 changes: 4 additions & 3 deletions lib/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
load("//:bzl_library.bzl", "bzl_library")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)

# export bzl files for the documentation
exports_files(
Expand Down
7 changes: 4 additions & 3 deletions rules/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
load("//:bzl_library.bzl", "bzl_library")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)

bzl_library(
name = "analysis_test",
Expand Down
2 changes: 1 addition & 1 deletion rules/private/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//:bzl_library.bzl", "bzl_library")

licenses(["notice"])
package(default_applicable_licenses = ["//:license"])

bzl_library(
name = "copy_common",
Expand Down
5 changes: 4 additions & 1 deletion tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ load(":types_tests.bzl", "types_test_suite")
load(":unittest_tests.bzl", "unittest_passing_tests_suite")
load(":versions_tests.bzl", "versions_test_suite")

licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

exports_files(
["unittest.bash"],
Expand Down
5 changes: 5 additions & 0 deletions tests/bzl_library/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
load("//:bzl_library.bzl", "bzl_library")
load(":bzl_library_test.bzl", "bzl_library_test")

package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

filegroup(
name = "a",
srcs = ["testdata/a.bzl"],
Expand Down
7 changes: 4 additions & 3 deletions tests/common_settings/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
load("//rules:common_settings.bzl", "int_flag", "string_flag")

licenses(["notice"])

package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

int_flag(
name = "my_int_flag",
Expand Down
7 changes: 4 additions & 3 deletions tests/copy_directory/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
load("//rules:copy_directory.bzl", "copy_directory")
load(":empty_directory.bzl", "empty_directory")

licenses(["notice"])

package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

# Copy of directory containing files a and b, and a subdir containing c
copy_directory(
Expand Down
7 changes: 4 additions & 3 deletions tests/copy_file/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@

load("//rules:copy_file.bzl", "copy_file")

licenses(["notice"])

package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

sh_test(
name = "copy_file_tests",
Expand Down
7 changes: 4 additions & 3 deletions tests/diff_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

load("//rules:diff_test.bzl", "diff_test")

licenses(["notice"])

package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

sh_test(
name = "diff_test_tests",
Expand Down
5 changes: 5 additions & 0 deletions tests/expand_template/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

load("//rules:expand_template.bzl", "expand_template")

package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

expand_template(
name = "filled_template",
out = "foo/test.yaml",
Expand Down
1 change: 1 addition & 0 deletions tests/native_binary/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("//rules:copy_file.bzl", "copy_file")
load("//rules:native_binary.bzl", "native_binary", "native_test")

package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
default_visibility = ["//visibility:private"],
)
Expand Down
1 change: 1 addition & 0 deletions tests/run_binary/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("//rules:run_binary.bzl", "run_binary")
load("//rules:write_file.bzl", "write_file")

package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
default_visibility = ["//visibility:private"],
)
Expand Down
5 changes: 4 additions & 1 deletion tests/select_file/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
load("//rules:diff_test.bzl", "diff_test")
load("//rules:select_file.bzl", "select_file")

licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

filegroup(
name = "fg",
Expand Down
5 changes: 4 additions & 1 deletion tests/unittest_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ EOF
ln -sf "$(rlocation $TEST_WORKSPACE/lib/unittest.bzl)" lib/unittest.bzl

mkdir -p toolchains/unittest
ln -sf "$(rlocation $TEST_WORKSPACE/toolchains/unittest/BUILD)" toolchains/unittest/BUILD
# Remove `package(default_applicable_license = ...)` line to avoid depending on rules_license inside this test
sed -e '/package(default_applicable_licenses = .*)/d' \
"$(rlocation $TEST_WORKSPACE/toolchains/unittest/BUILD)" \
> toolchains/unittest/BUILD

# Create test files.
mkdir -p testdir
Expand Down
7 changes: 4 additions & 3 deletions tests/write_file/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
load("//rules:diff_test.bzl", "diff_test")
load("//rules:write_file.bzl", "write_file")

licenses(["notice"])

package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

sh_test(
name = "write_file_tests",
Expand Down
2 changes: 1 addition & 1 deletion toolchains/unittest/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//lib:unittest.bzl", "TOOLCHAIN_TYPE", "unittest_toolchain")

licenses(["notice"])
package(default_applicable_licenses = ["//:license"])

toolchain_type(
name = "toolchain_type",
Expand Down
11 changes: 11 additions & 0 deletions workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@
"""Dependency registration helpers for repositories which need to load bazel-skylib."""

load("@bazel_skylib//lib:unittest.bzl", "register_unittest_toolchains")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def bazel_skylib_workspace():
"""Registers toolchains and declares repository dependencies of the bazel_skylib repository."""
maybe(
http_archive,
name = "rules_license",
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
)
register_unittest_toolchains()