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 6 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
14 changes: 12 additions & 2 deletions BUILD
@@ -1,8 +1,18 @@
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"],
)

licenses(["notice"])

# buildifier: disable=skylark-comment
# gazelle:exclude skylark_library.bzl
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
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
3 changes: 3 additions & 0 deletions distribution/BUILD
Expand Up @@ -4,9 +4,12 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("distribution.bzl", "remove_internal_only")

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

licenses(["notice"])

remove_internal_only(
name = "distro_workspace",
src = "//:WORKSPACE",
Expand Down
2 changes: 2 additions & 0 deletions docs/BUILD
@@ -1,5 +1,7 @@
load("//docs/private:stardoc_with_diff_test.bzl", "stardoc_with_diff_test", "update_docs")

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

licenses(["notice"])

stardoc_with_diff_test(
Expand Down
6 changes: 5 additions & 1 deletion docs/private/BUILD
@@ -1 +1,5 @@
# No targets in this package
# This package only contains source targets

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

licenses(["notice"])
tetromino marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions gazelle/BUILD
@@ -1,4 +1,15 @@
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"],
)

licenses(["notice"])

exports_files(["WORKSPACE.bzlmod"])

Expand Down
3 changes: 2 additions & 1 deletion gazelle/MODULE.bazel
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
@@ -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
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: 5 additions & 2 deletions lib/BUILD
@@ -1,8 +1,11 @@
load("//:bzl_library.bzl", "bzl_library")

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

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

# export bzl files for the documentation
exports_files(
Expand Down
7 changes: 5 additions & 2 deletions rules/BUILD
@@ -1,8 +1,11 @@
load("//:bzl_library.bzl", "bzl_library")

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

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

bzl_library(
name = "analysis_test",
Expand Down
2 changes: 2 additions & 0 deletions rules/private/BUILD
@@ -1,5 +1,7 @@
load("//:bzl_library.bzl", "bzl_library")

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

licenses(["notice"])

bzl_library(
Expand Down
5 changes: 5 additions & 0 deletions tests/BUILD
Expand Up @@ -15,6 +15,11 @@ load(":types_tests.bzl", "types_test_suite")
load(":unittest_tests.bzl", "unittest_passing_tests_suite")
load(":versions_tests.bzl", "versions_test_suite")

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

licenses(["notice"])

exports_files(
Expand Down
7 changes: 7 additions & 0 deletions tests/bzl_library/BUILD
@@ -1,6 +1,13 @@
load("//:bzl_library.bzl", "bzl_library")
load(":bzl_library_test.bzl", "bzl_library_test")

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

licenses(["notice"])

filegroup(
name = "a",
srcs = ["testdata/a.bzl"],
Expand Down
7 changes: 5 additions & 2 deletions tests/common_settings/BUILD
@@ -1,8 +1,11 @@
load("//rules:common_settings.bzl", "int_flag", "string_flag")

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

package(default_testonly = 1)
licenses(["notice"])

int_flag(
name = "my_int_flag",
Expand Down
7 changes: 5 additions & 2 deletions tests/copy_directory/BUILD.bazel
Expand Up @@ -3,9 +3,12 @@
load("//rules:copy_directory.bzl", "copy_directory")
load(":empty_directory.bzl", "empty_directory")

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

package(default_testonly = 1)
licenses(["notice"])

# Copy of directory containing files a and b, and a subdir containing c
copy_directory(
Expand Down
7 changes: 5 additions & 2 deletions tests/copy_file/BUILD
Expand Up @@ -33,9 +33,12 @@

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

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

package(default_testonly = 1)
licenses(["notice"])

sh_test(
name = "copy_file_tests",
Expand Down
7 changes: 5 additions & 2 deletions tests/diff_test/BUILD
Expand Up @@ -2,9 +2,12 @@

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

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

package(default_testonly = 1)
licenses(["notice"])

sh_test(
name = "diff_test_tests",
Expand Down
5 changes: 5 additions & 0 deletions tests/expand_template/BUILD
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
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
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: 5 additions & 0 deletions tests/select_file/BUILD
@@ -1,6 +1,11 @@
load("//rules:diff_test.bzl", "diff_test")
load("//rules:select_file.bzl", "select_file")

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

licenses(["notice"])

filegroup(
Expand Down
5 changes: 4 additions & 1 deletion tests/unittest_test.sh
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
5 changes: 4 additions & 1 deletion tests/write_file/BUILD
Expand Up @@ -37,7 +37,10 @@ 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: 2 additions & 0 deletions toolchains/unittest/BUILD
@@ -1,5 +1,7 @@
load("//lib:unittest.bzl", "TOOLCHAIN_TYPE", "unittest_toolchain")

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

licenses(["notice"])

toolchain_type(
Expand Down
11 changes: 11 additions & 0 deletions workspace.bzl
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()