Minor cleanups on BUCK genrules
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
This commit is contained in:
@@ -36,9 +36,20 @@ java_library(
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
# TODO(sop): Move git describe into an uncacheable genrule()
|
||||
def git_describe():
|
||||
import subprocess
|
||||
cmd = ['git', 'describe', 'HEAD']
|
||||
p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
|
||||
v = p.communicate()[0].strip()
|
||||
r = p.returncode
|
||||
if r != 0:
|
||||
raise subprocess.CalledProcessError(r, ' '.join(cmd))
|
||||
return v
|
||||
|
||||
genrule(
|
||||
name = 'git_describe',
|
||||
cmd = 'mkdir -p $(dirname $OUT); git describe HEAD >$OUT',
|
||||
cmd = 'mkdir -p $(dirname $OUT); echo "%s" >$OUT' % git_describe(),
|
||||
srcs = [],
|
||||
out = VER,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user