Add license argument to genrule

We implement the license argument to maven_jar by producing a
prebuilt_jar package that includes the license file as a dependency.
However, we can't depend on all artifacts that we ever download being
jars, so this doesn't work. Instead, just let a genrule provide a
license directly, adding it as a dep of the genrule. Of course,
genrules can't have deps, so we have to hack them into the command to
get buck to pick them up.

Change-Id: Ibcabc1ae63eeabf1333616780605314d0429a992
diff --git a/tools/default.defs b/tools/default.defs
index 7a6e982..191dfe5 100644
--- a/tools/default.defs
+++ b/tools/default.defs
@@ -73,6 +73,18 @@
     apds.extend(AUTO_VALUE_PROCESSOR_DEPS)
 
 
+# Add 'license' argument to genrule.
+_buck_genrule = genrule
+def genrule(*args, **kwargs):
+  license = kwargs.pop('license', None)
+  if license:
+    license = '//lib:LICENSE-%s' % license
+    # genrule has no deps attribute, but locations listed in the command show
+    # up as deps of the target with buck audit.
+    kwargs['cmd'] = 'true $(location %s); %s' % (license, kwargs['cmd'])
+  _buck_genrule(*args, **kwargs)
+
+
 def genantlr(
     name,
     srcs,