aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Aiuto <aiuto@google.com>2022-01-20 00:36:43 -0500
committerTony Aiuto <aiuto@google.com>2022-01-20 00:42:11 -0500
commit664bde143eb36901ccef33183399147199676c8b (patch)
tree0534a4cde088b54c9e4cf168fa754abe4b22acab
parenta40563d6ea1ea5d6745762bc04eb3f07d14e3fb2 (diff)
downloadbazelbuild-rules_license-664bde143eb36901ccef33183399147199676c8b.tar.gz
First round of cleanup to start release 1 sprint.
- Add deps.bzl (properly depend on python) - Add license rule for entire package. - Update checker_demo to account for bazel fixes to UTF-8 support - Add some missing copyright notices There is certainly more to do. I am breaking work into either logical or 1 day chunks.
-rw-r--r--README.md8
-rw-r--r--WORKSPACE22
-rw-r--r--deps.bzl27
-rw-r--r--licenses/spdx/BUILD22
-rw-r--r--rules/BUILD9
-rw-r--r--tools/BUILD23
-rw-r--r--tools/checker_demo.py7
-rw-r--r--version.bzl16
8 files changed, 119 insertions, 15 deletions
diff --git a/README.md b/README.md
index 7cba46e..d4ce9e8 100644
--- a/README.md
+++ b/README.md
@@ -8,10 +8,6 @@ This repository contains a set of rules and tools for
See [License Checking with
Bazel](https://docs.google.com/document/d/1uwBuhAoBNrw8tmFs-NxlssI6VRolidGYdYqagLqHWt8/edit#)
-for more information about this project.
+for more information about the project.
-WARNING: The code here is still in early, active development.
-
-## Disclaimer
-
-This is not an officially supported Google product.
+WARNING: The code here is still in active initial development and may be under churn.
diff --git a/WORKSPACE b/WORKSPACE
index 0e352d6..e8aa17e 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1 +1,23 @@
+# Copyright 2022 The Bazel 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
+#
+# http://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.
+
workspace(name = "rules_license")
+
+load("@rules_license//:deps.bzl", "rules_license_dependencies")
+
+rules_license_dependencies()
+
+### INTERNAL ONLY - lines after this are not included in the release packaging.
+
+# TODO(aiuto): Add stardoc dependency eventually.
diff --git a/deps.bzl b/deps.bzl
new file mode 100644
index 0000000..c6d75cd
--- /dev/null
+++ b/deps.bzl
@@ -0,0 +1,27 @@
+# Copyright 2022 The Bazel 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
+#
+# http://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.
+
+# Workspace dependencies for rules_license/rules
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
+
+def rules_license_dependencies():
+ maybe(
+ http_archive,
+ name = "rules_python",
+ sha256 = "a30abdfc7126d497a7698c29c46ea9901c6392d6ed315171a6df5ce433aa4502",
+ strip_prefix = "rules_python-0.6.0",
+ url = "https://github.com/bazelbuild/rules_python/archive/0.6.0.tar.gz",
+ )
diff --git a/licenses/spdx/BUILD b/licenses/spdx/BUILD
index e3c7121..3eff4ed 100644
--- a/licenses/spdx/BUILD
+++ b/licenses/spdx/BUILD
@@ -1,3 +1,17 @@
+# Copyright 2022 The Bazel 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
+#
+# http://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.
+
# license_kind()s for SPDX license identifiers.
# This is a set of license_kind declarations based on the SPDX license
@@ -38,9 +52,15 @@
# If you maintain your own third_party directory of all your dependences,
# so that your WORKSPACE files are empty, you might favor the second.
-
+load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:license_kind.bzl", "license_kind")
+package(
+ default_applicable_licenses = ["//:license"],
+ default_visibility = ["//visibility:public"],
+)
+
+
license_kind(
name = "0BSD",
conditions = [],
diff --git a/rules/BUILD b/rules/BUILD
index 33f6ab6..24a991f 100644
--- a/rules/BUILD
+++ b/rules/BUILD
@@ -13,6 +13,13 @@
# 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.
-#
+
# TODO(aiuto): Add dependency on Skylib for bzl_library so that we can later
# generate docs with stardoc.
+
+load("@rules_license//rules:license.bzl", "license")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_visibility = ["//visibility:public"],
+)
diff --git a/tools/BUILD b/tools/BUILD
index d3a5658..c331d9a 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -1,4 +1,25 @@
-# License declaration and compliance checking rules.
+# Copyright 2022 The Bazel 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
+#
+# http://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.
+
+# License declaration and compliance checking tools.
+
+load("@rules_license//rules:license.bzl", "license")
+
+package(
+ default_applicable_licenses = [":license"],
+ default_visibility = ["//visibility:public"],
+)
py_binary(
name = "checker_demo",
diff --git a/tools/checker_demo.py b/tools/checker_demo.py
index 0b57cee..32ec5f9 100644
--- a/tools/checker_demo.py
+++ b/tools/checker_demo.py
@@ -28,12 +28,7 @@ _ALWAYS_ALLOWED_CONDITIONS = frozenset(['notice', 'permissive', 'unencumberd'])
def _get_licenses(licenses_info):
with codecs.open(licenses_info, encoding='utf-8') as licenses_file:
- # TODO(aiuto): Bazel is not parsing the BUILD file as utf-8, so it is
- # double encoding characters. We should use the line below, but we have
- # to hack up a double utf-8 decode.
- # return json.loads(licenses_file.read())
- b = bytearray([ord(c) for c in licenses_file.read()])
- return json.loads(b.decode('utf-8'))
+ return json.loads(licenses_file.read())
def _do_report(out, licenses):
diff --git a/version.bzl b/version.bzl
new file mode 100644
index 0000000..d6efb25
--- /dev/null
+++ b/version.bzl
@@ -0,0 +1,16 @@
+# Copyright 2022 The Bazel 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
+#
+# http://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.
+"""The version of rules_license."""
+
+version = "0.0.1"