Skip to content

Commit

Permalink
Add @rules_license style license declarations (#508)
Browse files Browse the repository at this point in the history
* Add @rules_license declarations.

This is a little more unwieldy than we would like, in that we
hand add them to each BUILD file.

This should be enforced with a test, but it should be a non-Bazel
test at the source code level.
  • Loading branch information
aiuto authored Feb 16, 2022
1 parent a8638d6 commit 3c0b364
Show file tree
Hide file tree
Showing 27 changed files with 80 additions and 9 deletions.
17 changes: 15 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_license//rules:license.bzl", "license")

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

license(
name = "license",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0"
],
license_text = "LICENSE",
)

exports_files(
["WORKSPACE"],
visibility = ["//visibility:public"],
)

exports_files(
glob([
"*.bzl",
]),
visibility = ["//visibility:public"],
)

filegroup(
Expand Down
3 changes: 1 addition & 2 deletions distro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")

licenses(["notice"])

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

Expand Down
2 changes: 2 additions & 0 deletions doc_build/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_python//python:defs.bzl", "py_library")
load("//:version.bzl", "version")

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

filegroup(
name = "standard_package",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# -*- coding: utf-8 -*-
load("@rules_python//python:defs.bzl", "py_binary", "py_library")

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

exports_files(
glob([
Expand Down
8 changes: 8 additions & 0 deletions pkg/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def rules_pkg_dependencies():
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
)
maybe(
http_archive,
name = "rules_license",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.1/rules_license-0.0.1.tar.gz",
],
sha256 = "4865059254da674e3d18ab242e21c17f7e3e8c6b1f1421fffa4c5070f82e98b5",
)


def rules_pkg_register_toolchains():
Expand Down
2 changes: 2 additions & 0 deletions pkg/legacy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

exports_files(["rpm.bzl"])

filegroup(
Expand Down
2 changes: 2 additions & 0 deletions pkg/legacy/tests/rpm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

load("//pkg:rpm.bzl", "pkg_rpm")

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

pkg_rpm(
name = "test-rpm",
data = [
Expand Down
2 changes: 1 addition & 1 deletion pkg/private/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ All interfaces are subject to change at any time.

load("@rules_python//python:defs.bzl", "py_library")

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

filegroup(
name = "standard_package",
Expand Down
2 changes: 2 additions & 0 deletions pkg/private/deb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ All interfaces are subject to change at any time.

load("@rules_python//python:defs.bzl", "py_library")

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

filegroup(
name = "standard_package",
srcs = [
Expand Down
2 changes: 1 addition & 1 deletion pkg/private/zip/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ All interfaces are subject to change at any time.

load("@rules_python//python:defs.bzl", "py_library")

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

filegroup(
name = "standard_package",
Expand Down
3 changes: 1 addition & 2 deletions pkg/releasing/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("git.bzl", "git_changelog")

licenses(["notice"])

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

Expand Down
2 changes: 2 additions & 0 deletions pkg/rpm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

load("@rules_python//python:defs.bzl", "py_binary")

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

exports_files(
glob([
"*.bzl",
Expand Down
2 changes: 2 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ load("//pkg:mappings.bzl", "pkg_attributes", "pkg_mkdirs")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg:zip.bzl", "pkg_zip")

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

licenses(["notice"])

exports_files(glob(["testdata/**"]))
Expand Down
2 changes: 2 additions & 0 deletions tests/deb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:tar.bzl", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming")

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

genrule(
name = "generate_files",
outs = [
Expand Down
2 changes: 2 additions & 0 deletions tests/install/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ load("//pkg:install.bzl", "pkg_install")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "pkg_mkdirs")
load("//tests/util:defs.bzl", "fake_artifact")

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

py_test(
name = "install_test",
srcs = ["test.py"],
Expand Down
2 changes: 2 additions & 0 deletions tests/mappings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ load(
load("//tests/util:defs.bzl", "directory", "write_content_manifest")
load("@rules_python//python:defs.bzl", "py_test")

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

py_library(
name = "manifest_test_lib",
srcs = ["manifest_test_lib.py"],
Expand Down
2 changes: 2 additions & 0 deletions tests/mappings/filter_directory/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ load("//tests/util:defs.bzl", "directory")
# Base case
############################################################################

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

inspect_directory_test(
name = "base",
directory = ":test_directory",
Expand Down
2 changes: 2 additions & 0 deletions tests/rpm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ load("toolchain_tests.bzl", "create_toolchain_analysis_tests")
# analysis tests
############################################################################

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

analysis_tests(name = "analysis_tests")

create_toolchain_analysis_tests()
Expand Down
2 changes: 2 additions & 0 deletions tests/rpm/source_date_epoch/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ load("//pkg:rpm.bzl", "pkg_rpm")
# Test handling the source_date_epoch attribute
############################################################################

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

# The actual test. It tests whether the contents match a particular desired
# "manifest", most notably with regards to file structure.
py_test(
Expand Down
2 changes: 2 additions & 0 deletions tests/rpm/tree_artifacts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ load("@rules_python//python:defs.bzl", "py_test")
# - Each file in a TreeArtifact is installed relative to its position in the
# TreeArtifact, which itself is relative to the desired install prefix.

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

# The actual test. It tests whether the contents match a particular desired
# "manifest", most notably with regards to file structure.
py_test(
Expand Down
2 changes: 2 additions & 0 deletions tests/tar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ load("//tests/util:defs.bzl", "directory", "fake_artifact")
load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

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

py_test(
name = "archive_test",
srcs = [
Expand Down
2 changes: 2 additions & 0 deletions tests/testdata/utf8/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

filegroup(
name = "files",
srcs = glob(["**"]),
Expand Down
2 changes: 2 additions & 0 deletions tests/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

load("@rules_python//python:defs.bzl", "py_binary")

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

licenses(["notice"])

exports_files(["defs.bzl"])
Expand Down
2 changes: 2 additions & 0 deletions tests/zip/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ load("//tests/util:defs.bzl", "directory", "fake_artifact")
load("@rules_python//python:defs.bzl", "py_test")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

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

licenses(["notice"])

genrule(
Expand Down
14 changes: 14 additions & 0 deletions toolchains/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@
# 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.
package(default_applicable_licenses = ["//:license"])

filegroup(
name = "standard_package",
srcs = glob([
"*",
]),
visibility = ["//distro:__pkg__"],
)

exports_files(
glob(["*"]),
visibility = ["//visibility:public"],
)
2 changes: 2 additions & 0 deletions toolchains/git/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Toolchains:

load("//toolchains/git:git.bzl", "git_toolchain", "is_git_available")

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

filegroup(
name = "standard_package",
srcs = glob(["*"]),
Expand Down
2 changes: 2 additions & 0 deletions toolchains/rpm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Toolchains:

load("//toolchains/rpm:rpmbuild.bzl", "is_rpmbuild_available", "rpmbuild_toolchain")

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

filegroup(
name = "standard_package",
srcs = glob([
Expand Down

0 comments on commit 3c0b364

Please sign in to comment.