Files
gerrit/tools/bzl/license-map.py
Han-Wen Nienhuys eb16fe05a1 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
2016-09-21 18:34:56 +00:00

26 lines
584 B
Python

#!/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