![Shawn Pearce](/assets/img/avatar_default.png)
Assume BUCK has applied my commit to use set -e when running a genrule(). This allows us to use ';' in all genrule commands and trust the build will stop if any of the single statement terminates with a non-zero exit status. $SRCDIR is a cleaner reference to the sources of a genrule(), fixing an ugly reference to the (supposedly hidden) __srcs directory. Add a comment about the version generator, BUCK wants to make genrule output fully cacheable, which requires rules to be idempotent. Change-Id: I938450ed81675330e979d76721e0ba971d30d0e2
37 lines
1014 B
Python
37 lines
1014 B
Python
BASE = get_base_path()
|
|
CORE = [
|
|
'commit-message-length-validator',
|
|
'replication',
|
|
'reviewnotes',
|
|
]
|
|
|
|
# buck audit parses and resolves all deps even if not reachable
|
|
# from the root(s) passed to audit. Filter dependencies to only
|
|
# the ones that currently exist to allow buck to parse cleanly.
|
|
# TODO(sop): buck should more lazily resolve deps
|
|
def filter(names):
|
|
from os import path
|
|
h, n = [], []
|
|
for p in names:
|
|
if path.exists(path.join(BASE, p, 'BUCK')):
|
|
h.append(p)
|
|
else:
|
|
n.append(p)
|
|
return h, n
|
|
HAVE, NEED = filter(CORE)
|
|
|
|
genrule(
|
|
name = 'core',
|
|
cmd = '' +
|
|
';'.join(['echo >&2 plugins/'+n+' is required.' for n in NEED]) +
|
|
(';echo >&2;exit 1;' if NEED else '') +
|
|
'mkdir -p $TMP/WEB-INF/plugins;' +
|
|
'for s in $SRCS;do ln -s $s $TMP/WEB-INF/plugins;done;' +
|
|
'cd $TMP;' +
|
|
'zip -qr $OUT .',
|
|
srcs = [genfile('%s/%s.jar' % (n, n)) for n in CORE],
|
|
deps = ['//%s/%s:%s' % (BASE, n, n) for n in HAVE],
|
|
out = 'core.zip',
|
|
visibility = ['//:release'],
|
|
)
|