From 86524d86441f7680a0704c40880636e70ea092cd Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Mon, 9 Nov 2015 14:58:37 -0800 Subject: [PATCH] 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 --- tools/default.defs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/default.defs b/tools/default.defs index 7a6e98209e..191dfe5164 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -73,6 +73,18 @@ def _set_auto_value(kwargs): 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,