Add Documentation:js_licenses.txt for JavaScript

//Documentation:js_licenses.txt is an optional target to build
the closure of licenses that are compiled into the JavaScript
by the GWT compiler. This is a subset of what is inside of
licenses.txt, but this subset may be necessary in some cases.

Explicitly break some edges that would otherwise by found
in the build graph to avoid dragging in license information
that is not necessary in the partial report created by the
js_licenses.txt target.

Change-Id: Ibbebb3365faf8dccbcd02ad7ef82280255fc5245
This commit is contained in:
Shawn Pearce
2015-06-24 21:05:32 -07:00
parent 8db45829e0
commit bd69e3e3ec
7 changed files with 63 additions and 24 deletions

View File

@@ -3,7 +3,8 @@ include_defs('//Documentation/config.defs')
include_defs('//tools/git.defs')
DOC_DIR = 'Documentation'
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
JSUI = ['//gerrit-gwtui:ui_module']
MAIN = ['//gerrit-pgm:pgm'] + JSUI
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
genasciidoc(
@@ -29,11 +30,19 @@ genasciidoc(
genrule(
name = 'licenses.txt',
cmd = '$(exe :gen_licenses) >$OUT',
deps = [':gen_licenses'] + MAIN,
cmd = '$(exe :gen_licenses) --asciidoc ' + ' '.join(MAIN) + ' >$OUT',
deps = MAIN,
out = 'licenses.txt',
)
# Required by Google for gerrit-review.
genrule(
name = 'js_licenses.txt',
cmd = '$(exe :gen_licenses) --partial ' + ' '.join(JSUI) + ' >$OUT',
deps = JSUI,
out = 'js_licenses.txt',
)
genrule(
name = 'doc.css',
srcs = ['doc.css.in'],

View File

@@ -17,6 +17,7 @@
from __future__ import print_function
import argparse
from collections import defaultdict, deque
from os import chdir, path
import re
@@ -24,7 +25,12 @@ from shutil import copyfileobj
from subprocess import Popen, PIPE
from sys import stdout, stderr
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
parser = argparse.ArgumentParser()
parser.add_argument('--asciidoc', action='store_true')
parser.add_argument('--partial', action='store_true')
parser.add_argument('targets', nargs='+')
args = parser.parse_args()
KNOWN_PROVIDED_DEPS = [
'//lib/bouncycastle:bcpg',
'//lib/bouncycastle:bcpkix',
@@ -36,13 +42,23 @@ def parse_graph():
while not path.isfile('.buckconfig'):
chdir('..')
p = Popen(
['buck', 'audit', 'classpath', '--dot'] + MAIN,
['buck', 'audit', 'classpath', '--dot'] + args.targets,
stdout = PIPE)
for line in p.stdout:
m = re.search(r'"(//.*?)" -> "(//.*?)";', line)
if not m:
continue
target, dep = m.group(1), m.group(2)
if args.partial:
if dep == '//lib/codemirror:js_minifier':
if target == '//lib/codemirror:js':
continue
if target.startswith('//lib/codemirror:mode_'):
continue
if target == '//gerrit-gwtui:ui_module' and \
dep == '//gerrit-gwtexpui:CSS':
continue
# Dependencies included in provided_deps set are contained in audit
# classpath and must be sorted out. That's safe thing to do because
# they are not included in the final artifact.
@@ -60,7 +76,7 @@ def parse_graph():
graph = parse_graph()
licenses = defaultdict(set)
queue = deque(MAIN)
queue = deque(args.targets)
while queue:
target = queue.popleft()
for dep in graph[target]:
@@ -70,7 +86,8 @@ while queue:
queue.extend(graph[target])
used = sorted(licenses.keys())
print("""\
if args.asciidoc:
print("""\
Gerrit Code Review - Licenses
=============================
@@ -122,26 +139,33 @@ Licenses
for n in used:
libs = sorted(licenses[n])
name = n[len('//lib:LICENSE-'):]
print()
print('[[%s]]' % name.replace('.', '_'))
print(name)
print('~' * len(name))
print()
if args.asciidoc:
print()
print('[[%s]]' % name.replace('.', '_'))
print(name)
print('~' * len(name))
print()
else:
print()
print(name)
print('--')
for d in libs:
if d.startswith('//lib:') or d.startswith('//lib/'):
p = d[len('//lib:'):]
else:
p = d[d.index(':')+1:].lower()
print('* ' + p)
print()
print('[[license]]')
print('[verse]')
print('--')
if args.asciidoc:
print()
print('[[license]]')
print('[verse]')
print('--')
with open(n[2:].replace(':', '/')) as fd:
copyfileobj(fd, stdout)
print('--')
print("""
if args.asciidoc:
print("""
GERRIT
------
Part of link:index.html[Gerrit Code Review]

View File

@@ -31,7 +31,7 @@ gwt_module(
'//gerrit-prettify:client',
'//gerrit-reviewdb:client',
'//lib:gwtjsonrpc',
'//lib:gwtorm',
'//lib:gwtorm_client',
'//lib/jgit:Edit',
],
visibility = ['PUBLIC'],

View File

@@ -41,7 +41,7 @@ gwt_module(
'//gerrit-gwtexpui:CSS',
'//lib:gwtjsonrpc',
'//lib:gwtjsonrpc_src',
'//lib:gwtorm',
'//lib:gwtorm_client',
'//lib/codemirror:codemirror',
'//lib/gwt:user',
'//lib/jgit:Edit',
@@ -49,6 +49,7 @@ gwt_module(
visibility = [
'//tools/eclipse:classpath',
'//Documentation:licenses.txt',
'//Documentation:js_licenses.txt',
],
)

View File

@@ -15,7 +15,6 @@ gwt_module(
'//gerrit-patch-jgit:client',
'//gerrit-reviewdb:client',
'//gerrit-gwtexpui:SafeHtml',
'//lib:guava',
'//lib:gwtjsonrpc',
'//lib/gwt:user',
'//lib/jgit:Edit',

View File

@@ -7,8 +7,8 @@ gwt_module(
gwt_xml = SRC + 'ReviewDB.gwt.xml',
deps = [
'//gerrit-extension-api:client',
'//lib:gwtorm',
'//lib:gwtorm_src'
'//lib:gwtorm_client',
'//lib:gwtorm_client_src'
],
visibility = ['PUBLIC'],
)

View File

@@ -25,15 +25,21 @@ define_license(name = 'xz')
define_license(name = 'DO_NOT_DISTRIBUTE')
maven_jar(
name = 'gwtorm',
name = 'gwtorm_client',
id = 'com.google.gerrit:gwtorm:1.14-14-gf54f1f1',
bin_sha1 = 'c02267e0245dd06930ea64a2d7c5ddc5ba6d9cfb',
src_sha1 = '3d17ae8a173eb34d89098c748f28cddd5080adbc',
license = 'Apache2.0',
deps = [':protobuf'],
repository = GERRIT,
)
java_library(
name = 'gwtorm',
exported_deps = [':gwtorm_client'],
deps = [':protobuf'],
visibility = ['PUBLIC'],
)
maven_jar(
name = 'gwtjsonrpc',
id = 'gwtjsonrpc:gwtjsonrpc:1.7-2-g272ca32',