diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | WORKSPACE | 22 | ||||
-rw-r--r-- | deps.bzl | 27 | ||||
-rw-r--r-- | licenses/spdx/BUILD | 22 | ||||
-rw-r--r-- | rules/BUILD | 9 | ||||
-rw-r--r-- | tools/BUILD | 23 | ||||
-rw-r--r-- | tools/checker_demo.py | 7 | ||||
-rw-r--r-- | version.bzl | 16 |
8 files changed, 119 insertions, 15 deletions
@@ -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. @@ -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" |