gerrit/Documentation/license.defs
Dave Borowitz 51b05629a1 gen_licenses.py: Use buck query for license generation
This gives us a JSON structure so we don't have to parse .dot output,
which is nice. Tweak slightly the algorithm for cutting edges, so that
DO_NOT_DISTRIBUTE is only detected if it is actually used.

Because of the way Buck computes build cache keys for genrules, we
need to handle Java and non-Java dependencies differently; see
I09d95176 for a full explanation of this issue. Factor this
logic out into a separate defs file for brevity.

Change-Id: I6f6268e23074c714324c8e192157c85eb84c73c3
2015-11-12 18:40:30 -05:00

30 lines
902 B
Plaintext

def genlicenses(
name,
out,
opts = [],
java_deps = [],
non_java_deps = [],
visibility = []):
cmd = ['$(exe :gen_licenses)']
cmd.extend(opts)
cmd.append('>$OUT')
cmd.extend(java_deps)
cmd.extend(non_java_deps)
# Must use $(classpath) for Java deps, since transitive dependencies are not
# first-order dependencies of the output jar, so changes would not cause
# invalidation of the build cache key for the genrule.
cmd.extend('; true $(classpath %s)' % d for d in java_deps)
# Must use $(location) for non-Java deps, since $(classpath) will fail with an
# error. This is ok, because transitive dependencies are included in the
# output artifacts for everything _except_ Java libraries.
cmd.extend('; true $(location %s)' % d for d in non_java_deps)
genrule(
name = name,
out = out,
cmd = ' '.join(cmd),
visibility = visibility,
)