gerrit/plugins/BUCK
David Pursehouse 7fcd202680 Buck: Fix infinite loop when trying to build non-existing core plugins
Running `buck build plugins:core` before initialising the submodules
causes buck to throw FileNotFoundException and then go into an infinite
loop.

The genrule in the plugins' BUCK configuration has a check in the `cmd`
to make sure the required core plugins (`NEED`) exist, but it looks
like this gets evaluated after the `srcs` which is using `CORE`.

Change `srcs` to use `HAVE`.  Now buck will exit with an error when the
core plugins do not exist.

Bug: issue 2343
Change-Id: I1bc2f67bcf6aacfe553c00e54fff18f959ac4b79
2013-12-16 16:26:26 +09:00

38 lines
1.0 KiB
Python

BASE = get_base_path()
CORE = [
'commit-message-length-validator',
'download-commands',
'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 HAVE],
deps = ['//%s/%s:%s' % (BASE, n, n) for n in HAVE],
out = 'core.zip',
visibility = ['//:release'],
)