aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiuto <aiuto@google.com>2023-02-10 15:59:55 -0500
committerGitHub <noreply@github.com>2023-02-10 15:59:55 -0500
commit524ead2676e3144d9bfa05d5c971f189a42d2dd4 (patch)
tree75683af855d676876df42daccecc4e750621dd18
parent9a58c10b64b632ed1567d61b91f8167195164922 (diff)
parentdf22d7959456a7f3aa8298f41080ccd4126b7985 (diff)
downloadbazelbuild-rules_license-524ead2676e3144d9bfa05d5c971f189a42d2dd4.tar.gz
Merge pull request #73 from aiuto/sync2
Grab bag of nits and tweaks
-rw-r--r--BUILD2
-rw-r--r--examples/my_org/licenses/BUILD2
-rw-r--r--examples/policy_checker/BUILD6
-rw-r--r--examples/policy_checker/license_policy_check.bzl1
-rw-r--r--examples/src/BUILD8
-rw-r--r--examples/src/server_licenses_test.py4
-rw-r--r--examples/vndor/README.md (renamed from examples/vendor/README.md)0
-rw-r--r--examples/vndor/acme/ACME_LICENSE (renamed from examples/vendor/acme/ACME_LICENSE)0
-rw-r--r--examples/vndor/acme/BUILD (renamed from examples/vendor/acme/BUILD)2
-rw-r--r--examples/vndor/acme/coyote.cc (renamed from examples/vendor/acme/coyote.cc)0
-rw-r--r--examples/vndor/constant_gen/BUILD (renamed from examples/vendor/constant_gen/BUILD)2
-rw-r--r--examples/vndor/constant_gen/LICENSE (renamed from examples/vendor/constant_gen/LICENSE)0
-rw-r--r--examples/vndor/constant_gen/LICENSE.on_output (renamed from examples/vendor/constant_gen/LICENSE.on_output)0
-rw-r--r--examples/vndor/constant_gen/constant_generator.py (renamed from examples/vendor/constant_gen/constant_generator.py)0
-rw-r--r--examples/vndor/constant_gen/defs.bzl (renamed from examples/vendor/constant_gen/defs.bzl)19
-rw-r--r--examples/vndor/constant_gen/verify_licenses_test.py (renamed from examples/vendor/constant_gen/verify_licenses_test.py)8
-rw-r--r--examples/vndor/libhhgttg/BUILD (renamed from examples/vendor/libhhgttg/BUILD)2
-rw-r--r--examples/vndor/libhhgttg/LICENSE (renamed from examples/vendor/libhhgttg/LICENSE)0
-rw-r--r--examples/vndor/libhhgttg/answer.cc (renamed from examples/vendor/libhhgttg/answer.cc)0
-rw-r--r--tests/BUILD10
-rw-r--r--tests/apps/an_app.cc13
-rw-r--r--tests/apps/an_app_licenses_test.py14
-rw-r--r--tests/legacy/BUILD17
-rw-r--r--tests/legacy/file_under_notice.cc14
-rw-r--r--tests/thrdparty/new_style_lib.cc13
-rw-r--r--tools/checker_demo.py2
26 files changed, 111 insertions, 28 deletions
diff --git a/BUILD b/BUILD
index 40cfcad..31520c4 100644
--- a/BUILD
+++ b/BUILD
@@ -55,8 +55,10 @@ filegroup(
"*.bzl",
"*.md",
]) + [
+ "MODULE.bazel",
"BUILD",
"LICENSE",
+ "WORKSPACE.bzlmod",
],
visibility = ["//distro:__pkg__"],
)
diff --git a/examples/my_org/licenses/BUILD b/examples/my_org/licenses/BUILD
index f17bfa3..c200d37 100644
--- a/examples/my_org/licenses/BUILD
+++ b/examples/my_org/licenses/BUILD
@@ -66,6 +66,6 @@ license_kind(
license_kind(
name = "acme_corp_paid",
conditions = [
- "whitelist:acme_corp_paid",
+ "allowlist:acme_corp_paid",
],
)
diff --git a/examples/policy_checker/BUILD b/examples/policy_checker/BUILD
index a18bcd2..49f77aa 100644
--- a/examples/policy_checker/BUILD
+++ b/examples/policy_checker/BUILD
@@ -27,11 +27,11 @@ license_policy(
)
license_policy(
- name = "special_whitelisted_app",
- # There could be a whitelist of targets here.
+ name = "special_allowlisted_app",
+ # There could be a allowlist of targets here.
conditions = [
"notice",
- "whitelist:acme_corp_paid",
+ "allowlist:acme_corp_paid",
],
)
diff --git a/examples/policy_checker/license_policy_check.bzl b/examples/policy_checker/license_policy_check.bzl
index 2692a01..32db845 100644
--- a/examples/policy_checker/license_policy_check.bzl
+++ b/examples/policy_checker/license_policy_check.bzl
@@ -45,7 +45,6 @@ def _license_policy_check_impl(ctx):
if LicenseInfo in ctx.attr.target:
for license in ctx.attr.target[LicenseInfo].licenses.to_list():
- print(license)
for kind in license.license_kinds:
# print(kind.conditions)
for condition in kind.conditions:
diff --git a/examples/src/BUILD b/examples/src/BUILD
index 0bcb938..cd5e985 100644
--- a/examples/src/BUILD
+++ b/examples/src/BUILD
@@ -14,11 +14,11 @@
# Examples of applications and interactions with licenses
load("@rules_license//rules:compliance.bzl", "check_license", "licenses_used")
-load("@rules_license//examples/vendor/constant_gen:defs.bzl", "constant_gen")
+load("@rules_license//examples/vndor/constant_gen:defs.bzl", "constant_gen")
package(
default_package_metadata = ["//:license", "//:package_info"],
- default_visibility = ["//visibility:public"],
+ default_visibility = ["//examples:__subpackages__"],
)
cc_binary(
@@ -71,7 +71,7 @@ cc_binary(
srcs = ["server.cc"],
deps = [
":message",
- "@rules_license//examples/vendor/acme",
- "@rules_license//examples/vendor/libhhgttg",
+ "@rules_license//examples/vndor/acme",
+ "@rules_license//examples/vndor/libhhgttg",
],
)
diff --git a/examples/src/server_licenses_test.py b/examples/src/server_licenses_test.py
index c7c30da..66a20a5 100644
--- a/examples/src/server_licenses_test.py
+++ b/examples/src/server_licenses_test.py
@@ -32,10 +32,10 @@ class ServerLicensesTest(unittest.TestCase):
expected = {
"/examples/src:message_src_": [
- "/examples/vendor/constant_gen:license_for_emitted_code"
+ "/examples/vndor/constant_gen:license_for_emitted_code"
],
"/examples/src:message": [
- "/examples/vendor/constant_gen:license_for_emitted_code"
+ "/examples/vndor/constant_gen:license_for_emitted_code"
],
}
license_test_utils.check_licenses_of_dependencies(
diff --git a/examples/vendor/README.md b/examples/vndor/README.md
index 273dea6..273dea6 100644
--- a/examples/vendor/README.md
+++ b/examples/vndor/README.md
diff --git a/examples/vendor/acme/ACME_LICENSE b/examples/vndor/acme/ACME_LICENSE
index 53a5daf..53a5daf 100644
--- a/examples/vendor/acme/ACME_LICENSE
+++ b/examples/vndor/acme/ACME_LICENSE
diff --git a/examples/vendor/acme/BUILD b/examples/vndor/acme/BUILD
index 2e98d98..09da19d 100644
--- a/examples/vendor/acme/BUILD
+++ b/examples/vndor/acme/BUILD
@@ -17,7 +17,7 @@ load("@rules_license//rules:license.bzl", "license")
package(
default_applicable_licenses = [":license"],
- default_visibility = ["//visibility:public"],
+ default_visibility = ["//examples:__subpackages__"],
)
# The default license for an entire package is typically named "license".
diff --git a/examples/vendor/acme/coyote.cc b/examples/vndor/acme/coyote.cc
index d637855..d637855 100644
--- a/examples/vendor/acme/coyote.cc
+++ b/examples/vndor/acme/coyote.cc
diff --git a/examples/vendor/constant_gen/BUILD b/examples/vndor/constant_gen/BUILD
index 26e86b6..5f2ff43 100644
--- a/examples/vendor/constant_gen/BUILD
+++ b/examples/vndor/constant_gen/BUILD
@@ -19,7 +19,7 @@ load(":defs.bzl", "constant_gen")
package(
default_applicable_licenses = [":license"],
- default_visibility = ["//visibility:public"],
+ default_visibility = ["//examples:__subpackages__"],
)
# The default license for an entire package is typically named "license".
diff --git a/examples/vendor/constant_gen/LICENSE b/examples/vndor/constant_gen/LICENSE
index 861da0d..861da0d 100644
--- a/examples/vendor/constant_gen/LICENSE
+++ b/examples/vndor/constant_gen/LICENSE
diff --git a/examples/vendor/constant_gen/LICENSE.on_output b/examples/vndor/constant_gen/LICENSE.on_output
index b699638..b699638 100644
--- a/examples/vendor/constant_gen/LICENSE.on_output
+++ b/examples/vndor/constant_gen/LICENSE.on_output
diff --git a/examples/vendor/constant_gen/constant_generator.py b/examples/vndor/constant_gen/constant_generator.py
index 432b6be..432b6be 100644
--- a/examples/vendor/constant_gen/constant_generator.py
+++ b/examples/vndor/constant_gen/constant_generator.py
diff --git a/examples/vendor/constant_gen/defs.bzl b/examples/vndor/constant_gen/defs.bzl
index f3eb715..518437c 100644
--- a/examples/vendor/constant_gen/defs.bzl
+++ b/examples/vndor/constant_gen/defs.bzl
@@ -1,3 +1,16 @@
+# Copyright 2020 Google LLC
+#
+# 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.
"""A trivial rule to turn a string into a C++ constant."""
def _constant_gen_impl(ctx):
@@ -19,7 +32,7 @@ _constant_gen = rule(
"text": attr.string(mandatory = True),
"var": attr.string(mandatory = False),
"_generator": attr.label(
- default = Label("@rules_license//examples/vendor/constant_gen:constant_generator"),
+ default = Label("@rules_license//examples/vndor/constant_gen:constant_generator"),
executable = True,
allow_files = True,
cfg = "exec",
@@ -34,12 +47,12 @@ def constant_gen(name, text, var):
src_out = name + "_src_.cc",
text = text,
var = var,
- applicable_licenses = ["@rules_license//examples/vendor/constant_gen:license_for_emitted_code"],
+ applicable_licenses = ["@rules_license//examples/vndor/constant_gen:license_for_emitted_code"],
)
# And turn it into a library we can link against
native.cc_library(
name = name,
srcs = [name + "_src_"],
- applicable_licenses = ["@rules_license//examples/vendor/constant_gen:license_for_emitted_code"],
+ applicable_licenses = ["@rules_license//examples/vndor/constant_gen:license_for_emitted_code"],
)
diff --git a/examples/vendor/constant_gen/verify_licenses_test.py b/examples/vndor/constant_gen/verify_licenses_test.py
index 4fddef8..917e600 100644
--- a/examples/vendor/constant_gen/verify_licenses_test.py
+++ b/examples/vndor/constant_gen/verify_licenses_test.py
@@ -13,8 +13,8 @@ class VerifyLicensesTest(unittest.TestCase):
os.path.join(os.path.dirname(__file__), "generator_licenses.json"))
expected = {
- "examples/vendor/constant_gen:constant_generator": [
- "examples/vendor/constant_gen:license"
+ "examples/vndor/constant_gen:constant_generator": [
+ "examples/vndor/constant_gen:license"
],
}
license_test_utils.check_licenses_of_dependencies(
@@ -25,10 +25,10 @@ class VerifyLicensesTest(unittest.TestCase):
os.path.join(os.path.dirname(__file__), "generated_code_licenses.json"))
expected = {
- "examples/vendor/constant_gen:libhello": [
+ "examples/vndor/constant_gen:libhello": [
"/constant_gen:license_for_emitted_code",
],
- "examples/vendor/constant_gen:libhello_src_": [
+ "examples/vndor/constant_gen:libhello_src_": [
"/constant_gen:license_for_emitted_code",
],
}
diff --git a/examples/vendor/libhhgttg/BUILD b/examples/vndor/libhhgttg/BUILD
index 15c7655..b9e3991 100644
--- a/examples/vendor/libhhgttg/BUILD
+++ b/examples/vndor/libhhgttg/BUILD
@@ -20,7 +20,7 @@ load("@rules_license//rules:license.bzl", "license")
# license.
package(
default_applicable_licenses = [":license"],
- default_visibility = ["//visibility:public"],
+ default_visibility = ["//examples:__subpackages__"],
)
# The default license for an entire package is typically named "license".
diff --git a/examples/vendor/libhhgttg/LICENSE b/examples/vndor/libhhgttg/LICENSE
index 660e329..660e329 100644
--- a/examples/vendor/libhhgttg/LICENSE
+++ b/examples/vndor/libhhgttg/LICENSE
diff --git a/examples/vendor/libhhgttg/answer.cc b/examples/vndor/libhhgttg/answer.cc
index 440bc62..440bc62 100644
--- a/examples/vendor/libhhgttg/answer.cc
+++ b/examples/vndor/libhhgttg/answer.cc
diff --git a/tests/BUILD b/tests/BUILD
index 1d7961f..ab2438f 100644
--- a/tests/BUILD
+++ b/tests/BUILD
@@ -74,10 +74,10 @@ cc_library(
":license_for_extra_feature",
":internal_non_compliance_license",
],
- #deps = [
- # "@rules_license//rules/tests/legacy:another_library_with_legacy_license_clause",
- # "@rules_license//rules/tests/legacy:library_with_legacy_license_clause",
- #],
+ deps = [
+ "@rules_license//tests/legacy:another_library_with_legacy_license_clause",
+ "@rules_license//tests/legacy:library_with_legacy_license_clause",
+ ],
)
java_binary(
@@ -87,6 +87,7 @@ java_binary(
applicable_licenses = [
":license_for_extra_feature",
],
+ javacopts = ["-Xep:DefaultPackage:OFF"],
main_class = "Hello",
deps = [
":j_bar",
@@ -96,6 +97,7 @@ java_binary(
java_library(
name = "j_bar",
srcs = ["Bar.java"],
+ javacopts = ["-Xep:DefaultPackage:OFF"],
)
check_license(
diff --git a/tests/apps/an_app.cc b/tests/apps/an_app.cc
index 410f986..60f6fc5 100644
--- a/tests/apps/an_app.cc
+++ b/tests/apps/an_app.cc
@@ -1,3 +1,16 @@
+// Copyright 2022 Google LLC
+//
+// 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.
#include <iostream>
#include <ostream>
diff --git a/tests/apps/an_app_licenses_test.py b/tests/apps/an_app_licenses_test.py
index 9899e6c..0dbf8fb 100644
--- a/tests/apps/an_app_licenses_test.py
+++ b/tests/apps/an_app_licenses_test.py
@@ -1,4 +1,16 @@
-"""Tests for google3.tools.build_defs.license.tests.apps.an_app_licenses."""
+# Copyright 2022 Google LLC
+#
+# 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.
import os
diff --git a/tests/legacy/BUILD b/tests/legacy/BUILD
new file mode 100644
index 0000000..e065e22
--- /dev/null
+++ b/tests/legacy/BUILD
@@ -0,0 +1,17 @@
+# Example of an unmigrated package.
+
+package(default_visibility = [
+ "//tests:__subpackages__",
+])
+
+licenses(["unencumbered"])
+
+cc_library(
+ name = "library_with_legacy_license_clause",
+ srcs = ["file_under_notice.cc"],
+)
+
+cc_library(
+ name = "another_library_with_legacy_license_clause",
+ srcs = ["file_under_notice.cc"],
+)
diff --git a/tests/legacy/file_under_notice.cc b/tests/legacy/file_under_notice.cc
new file mode 100644
index 0000000..2fa8bfc
--- /dev/null
+++ b/tests/legacy/file_under_notice.cc
@@ -0,0 +1,14 @@
+// Copyright 2022 Google LLC
+//
+// 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.
+int file_under_notice = 1;
diff --git a/tests/thrdparty/new_style_lib.cc b/tests/thrdparty/new_style_lib.cc
index 545e5b4..0c739b9 100644
--- a/tests/thrdparty/new_style_lib.cc
+++ b/tests/thrdparty/new_style_lib.cc
@@ -1,3 +1,16 @@
+// Copyright 2022 Google LLC
+//
+// 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.
#include <iostream>
#include <ostream>
diff --git a/tools/checker_demo.py b/tools/checker_demo.py
index 1075621..6cdf07f 100644
--- a/tools/checker_demo.py
+++ b/tools/checker_demo.py
@@ -90,7 +90,6 @@ def _do_copyright_notices(out, licenses):
if l.get('package_version'):
name = name + "/" + l['package_version']
# IGNORE_COPYRIGHT: Not a copyright notice. It is a variable holding one.
- print(l)
out.write('package(%s), copyright(%s)\n' % (name, l['copyright_notice']))
@@ -122,7 +121,6 @@ def main():
top_level_target = target['top_level_target']
dependencies = target['dependencies']
licenses = target['licenses']
- print(licenses)
err = 0
with codecs.open(args.report, mode='w', encoding='utf-8') as rpt: