bazel: generate license list for documentation.
Example:
$ bazel build //Documentation:pgm-licenses.txt
..
$ cat bazel-genfiles/Documentation/pgm-licenses.txt
//lib:jsch //lib:LICENSE-jsch
//lib:servlet-api-3_1 //lib:LICENSE-Apache2.0
Still missing:
* check that there are dependencies on forbidden licenses
* check that there are no external dependencies except through the
//lib directory.
Change-Id: I8f0ed94de20f68e0dbc1fe87dfd56ce11e02fab7
This commit is contained in:
25
tools/bzl/license-map.py
Normal file
25
tools/bzl/license-map.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# reads a bazel query XML file, to join target names with their licenses.
|
||||
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
tree = ET.parse(sys.argv[1])
|
||||
root = tree.getroot()
|
||||
|
||||
entries = {}
|
||||
|
||||
for child in root:
|
||||
rule_name = child.attrib["name"]
|
||||
for c in child.getchildren():
|
||||
if c.tag != "rule-input":
|
||||
continue
|
||||
|
||||
license_name = c.attrib["name"]
|
||||
if "//lib:LICENSE" in license_name:
|
||||
assert rule_name not in entries, (license_name, entries[rule_name])
|
||||
entries[rule_name] = license_name
|
||||
|
||||
for k, v in sorted(entries.items()):
|
||||
print k, v
|
||||
Reference in New Issue
Block a user