Buck: Remove usage of genfile()

genfile() is considered to be deprecated and is going to be discontinued
in future Buck releases [1].

[1] https://groups.google.com/forum/#!topic/buck-build/Ci8Y95USD8I

Change-Id: I7a5a1ee99d1448c412bb51b793c1e874dd3c62f4
This commit is contained in:
David Ostrovsky 2014-05-30 12:42:32 +02:00 committed by David Ostrovsky
parent a607a784e3
commit d8af092c0a
13 changed files with 88 additions and 112 deletions

View File

@ -10,21 +10,16 @@ genrule(
name = 'html',
cmd = 'cd $TMP;' +
'mkdir -p %s/images;' % DOC_DIR +
'unzip -q $SRCDIR/only_html.zip -d %s/;' % DOC_DIR +
'unzip -q $(location %s) -d %s/;'
% (':generate_html', DOC_DIR) +
'for s in $SRCS;do ln -s $s %s;done;' % DOC_DIR +
'mv %s/*.{jpg,png} %s/images;' % (DOC_DIR, DOC_DIR) +
'rm %s/only_html.zip;' % DOC_DIR +
'rm %s/licenses.txt;' % DOC_DIR +
'cp $SRCDIR/licenses.txt LICENSES.txt;' +
'cp $(location %s) LICENSES.txt;' % ':licenses.txt' +
'zip -qr $OUT *',
srcs = glob([
'images/*.jpg',
'images/*.png',
]) + [
'doc.css',
genfile('licenses.txt'),
genfile('only_html.zip'),
],
]) + ['doc.css'],
deps = [
':generate_html',
':licenses.txt',
@ -35,7 +30,7 @@ genrule(
genasciidoc(
name = 'generate_html',
srcs = SRCS + [genfile('licenses.txt')],
srcs = SRCS + [':licenses.txt'],
deps = [':licenses.txt'],
attributes = documentation_attributes(git_describe()),
backend = 'html5',
@ -66,8 +61,9 @@ genrule(
'--prefix "%s/" ' % DOC_DIR +
'--in-ext ".txt" ' +
'--out-ext ".html" ' +
'$SRCS',
srcs = SRCS + [genfile('licenses.txt')],
'$SRCS ' +
'$(location :licenses.txt)',
srcs = SRCS,
deps = [
':licenses.txt',
'//lib/asciidoctor:doc_indexer',
@ -77,7 +73,6 @@ genrule(
prebuilt_jar(
name = 'index_lib',
binary_jar = genfile('index.jar'),
deps = [':index'],
binary_jar = ':index',
visibility = ['PUBLIC'],
)

View File

@ -36,26 +36,35 @@ def genasciidoc(
asciidoc.append('$SRCS')
newsrcs = ["doc.css"]
newdeps = deps + ['//lib/asciidoctor:asciidoc']
for src in srcs:
tx = []
fn = src
if fn.startswith('BUCKGEN:') :
fn = src[8:]
tx = [':' + fn]
# We have two cases: regular source files and generated files.
# Generated files are passed as targets ':foo', and ':' is removed.
# 1. regular files: cmd = '-s foo', srcs = ['foo']
# 2. generated files: cmd = '-s $(location :foo)', srcs = []
srcs = [src]
passed_src = ' -s %s' % fn
if fn.startswith(':') :
tx = [fn]
fn = src[1:]
srcs = []
passed_src = ' -s $(location :%s)' % fn
ex = fn + EXPN
genrule(
name = ex,
cmd = '$(exe :replace_macros) --suffix=' + EXPN +
' -s %s' % fn +
passed_src +
' -o $OUT',
srcs = [src],
srcs = srcs,
deps = tx + [':replace_macros'],
out = ex,
)
newdeps.append(':' + ex)
newsrcs.append(genfile(ex))
ex = ':' + ex
newdeps.append(ex)
asciidoc.append('$(location %s)' % ex)
genrule(
name = name,

View File

@ -17,8 +17,8 @@ genantlr(
java_library(
name = 'lib',
srcs = [genfile('query_antlr.src.zip')],
deps = PARSER_DEPS + [':query_antlr'],
srcs = [':query_antlr'],
deps = PARSER_DEPS,
)
# Hack necessary to expose ANTLR generated code as JAR to Eclipse.
@ -28,9 +28,10 @@ genrule(
deps = [':lib'],
out = 'query_parser.jar',
)
prebuilt_jar(
name = 'query_parser',
binary_jar = genfile('query_parser.jar'),
deps = PARSER_DEPS + [':query_link'],
binary_jar = ':query_link',
deps = PARSER_DEPS,
visibility = ['PUBLIC'],
)

View File

@ -95,11 +95,10 @@ gwt_module(
prebuilt_jar(
name = 'diffy_logo',
binary_jar = genfile('diffy_images.jar'),
binary_jar = ':diffy_image_files_ln',
deps = [
'//lib:LICENSE-diffy',
'//lib:LICENSE-CC-BY3.0',
':diffy_image_files_ln',
],
)

View File

@ -63,9 +63,8 @@ def gwt_user_agent_permutations(
)
prebuilt_jar(
name = '%s_gwtxml_lib' % gwt_name,
binary_jar = genfile(jar),
gwt_jar = genfile(jar),
deps = [':%s_gwtxml_gen' % gwt_name],
binary_jar = ':%s_gwtxml_gen' % gwt_name,
gwt_jar = ':%s_gwtxml_gen' % gwt_name,
)
gwt_binary(
name = gwt_name,

View File

@ -49,8 +49,7 @@ genrule(
prebuilt_jar(
name = 'log4j-config',
binary_jar = genfile('log4j-config.jar'),
deps = [':log4j-config__jar'],
binary_jar = ':log4j-config__jar',
visibility = [
'//:',
'//tools/eclipse:classpath',
@ -59,8 +58,7 @@ prebuilt_jar(
prebuilt_jar(
name = 'version',
binary_jar = genfile('version.jar'),
deps = [':gen_version'],
binary_jar = ':gen_version',
visibility = ['//:'],
)

View File

@ -13,14 +13,13 @@ genrule(
cmd = ';'.join([
':>$OUT',
"echo '/** @license' >>$OUT",
'unzip -p %s %s/LICENSE >>$OUT' % (ZIP, TOP),
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
] +
['unzip -p %s %s/%s >>$OUT' % (ZIP, TOP, n)
['unzip -p $(location :zip) %s/%s >>$OUT' % (TOP, n)
for n in CM3_CSS + CM3_THEMES]
),
srcs = [genfile(ZIP)],
deps = [':download'],
deps = [':zip'],
out = 'cm3.css',
)
@ -30,24 +29,20 @@ genrule(
cmd = ';'.join([
':>$OUT',
"echo '/** @license' >>$OUT",
'unzip -p %s %s/LICENSE >>$OUT' % (ZIP, TOP),
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
] +
['unzip -p %s %s/%s >>$OUT' % (ZIP, TOP, n)
['unzip -p $(location :zip) %s/%s >>$OUT' % (TOP, n)
for n in CM3_JS]
),
srcs = [genfile(ZIP)],
deps = [':download'],
deps = [':zip'],
out = 'cm3.js',
)
prebuilt_jar(
name = 'codemirror',
binary_jar = genfile('codemirror.jar'),
deps = [
':jar',
'//lib:LICENSE-codemirror',
],
binary_jar = ':jar',
deps = ['//lib:LICENSE-codemirror'],
visibility = ['PUBLIC'],
)
@ -55,23 +50,17 @@ genrule(
name = 'jar',
cmd = ';'.join([
'cd $TMP',
'unzip -q $SRCDIR/%s %s' % (
ZIP,
' '.join(['%s/mode/%s' % (TOP, n) for n in CM3_MODES])),
'unzip -q $(location :zip) %s' %
' '.join(['%s/mode/%s' % (TOP, n) for n in CM3_MODES]),
'mkdir net',
'mv %s net/codemirror' % TOP,
'mkdir net/codemirror/lib',
'mv $SRCDIR/cm3.css net/codemirror/lib',
'mv $SRCDIR/cm3.js net/codemirror/lib',
'mv $(location :css) net/codemirror/lib',
'mv $(location :js) net/codemirror/lib',
'zip -qr $OUT *'
]),
srcs = [
genfile(ZIP),
genfile('cm3.css'),
genfile('cm3.js'),
],
deps = [
':download',
':zip',
':css',
':js',
],
@ -79,11 +68,11 @@ genrule(
)
genrule(
name = 'download',
name = 'zip',
cmd = '$(exe //tools:download_file)' +
' -o $OUT' +
' -u ' + URL +
' -v ' + SHA1,
deps = ['//tools:download_file'],
out = 'codemirror-' + VERSION + '.zip',
out = ZIP,
)

View File

@ -69,17 +69,16 @@ maven_jar(
prebuilt_jar(
name = 'Edit',
binary_jar = genfile('edit-src.jar'),
deps = [':jgit_edit_src'],
binary_jar = ':jgit_edit_src',
visibility = ['PUBLIC'],
)
genrule(
name = 'jgit_edit_src',
cmd = 'unzip -qd $TMP $SRCS org/eclipse/jgit/diff/Edit.java;' +
cmd = 'unzip -qd $TMP $(location :jgit_src) ' +
'org/eclipse/jgit/diff/Edit.java;' +
'cd $TMP;' +
'zip -Dq $OUT org/eclipse/jgit/diff/Edit.java',
srcs = [genfile('jgit/org.eclipse.jgit-%s-src.jar' % VERS)],
deps = [':jgit_src'],
out = 'edit-src.jar',
deps = [':jgit_src']
)

View File

@ -79,7 +79,7 @@ def maven_jar(
cmd.append('--unsign')
genrule(
name = name + '__download_bin',
name = '%s__download_bin' % name,
cmd = ' '.join(cmd),
deps = ['//tools:download_file'],
out = binjar,
@ -91,32 +91,31 @@ def maven_jar(
if src_sha1:
cmd.extend(['-v', src_sha1])
genrule(
name = name + '__download_src',
name = '%s__download_src' % name,
cmd = ' '.join(cmd),
deps = ['//tools:download_file'],
out = srcjar,
)
prebuilt_jar(
name = name + '_src',
binary_jar = genfile(srcjar),
name = '%s_src' % name,
binary_jar = ':%s__download_src' % name,
deps = license + [':' + name + '__download_src'],
visibility = visibility,
)
else:
srcjar = None
genrule(
name = name + '__download_src',
name = '%s__download_src' % name,
cmd = ':>$OUT',
out = '__' + name + '__no_src',
out = '__%s__no_src' % name,
)
srcdep = [':' + name + '__download_src'] if srcjar else []
if exported_deps:
prebuilt_jar(
name = name + '__jar',
deps = deps + srcdep + license + [':' + name + '__download_bin'],
binary_jar = genfile(binjar),
source_jar = genfile(srcjar) if srcjar else None,
name = '%s__jar' % name,
deps = deps,
binary_jar = ':%s__download_bin' % name,
source_jar = ':%s__download_src' % name if srcjar else None,
)
java_library(
name = name,
@ -126,9 +125,9 @@ def maven_jar(
else:
prebuilt_jar(
name = name,
deps = deps + srcdep + license + [':' + name + '__download_bin'],
binary_jar = genfile(binjar),
source_jar = genfile(srcjar) if srcjar else None,
deps = deps,
binary_jar = ':%s__download_bin' % name,
source_jar = ':%s__download_src' % name if srcjar else None,
visibility = visibility,
)
@ -141,18 +140,17 @@ def local_jar(
binjar = name + '.jar'
srcjar = name + '-src.jar'
genrule(
name = name + '__local_bin',
name = '%s__local_bin' % name,
cmd = 'ln -s %s $OUT' % jar,
out = binjar)
if src:
genrule(
name = name + '__local_src',
name = '%s__local_src' % name,
cmd = 'ln -s %s $OUT' % src,
out = srcjar)
prebuilt_jar(
name = name + '_src',
deps = [':' + name + '__local_src'],
binary_jar = genfile(srcjar),
name = '%s_src' % name,
binary_jar = ':%s__local_src' % name,
visibility = visibility,
)
else:
@ -160,8 +158,8 @@ def local_jar(
prebuilt_jar(
name = name,
deps = deps + [':' + name + '__local_bin'],
binary_jar = genfile(binjar),
source_jar = genfile(srcjar) if srcjar else None,
deps = deps,
binary_jar = ':%s__local_bin' % name,
source_jar = ':%s__local_src' % name if srcjar else None,
visibility = visibility,
)

View File

@ -28,11 +28,8 @@ def prolog_cafe_library(
)
java_library(
name = name + '__lib',
srcs = [genfile(name + '.src.zip')],
deps = [
':' + name + '__pl2j',
'//lib/prolog:prolog-cafe',
] + deps,
srcs = [':' + name + '__pl2j'],
deps = ['//lib/prolog:prolog-cafe'] + deps,
)
genrule(
name = name + '__ln',
@ -42,7 +39,6 @@ def prolog_cafe_library(
)
prebuilt_jar(
name = name,
binary_jar = genfile(name + '.jar'),
deps = [':%s__ln' % name],
binary_jar = ':%s__ln' % name,
visibility = visibility,
)

View File

@ -28,10 +28,11 @@ genrule(
';'.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;' +
'for s in ' +
' '.join(['$(location //%s/%s:%s)' % (BASE, n, n) for n in HAVE]) +
';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'],

View File

@ -14,12 +14,8 @@
# These definitions support building a runnable version of Gerrit.
DOCS_SRC = genfile('Documentation/html.zip')
DOCS_HTML = '//Documentation:html'
DOCS_LIB = '//Documentation:index_lib'
DOCS_DEP = [
'//Documentation:html',
'//Documentation:index_lib',
]
LIBS = [
'//gerrit-war:log4j-config',
'//gerrit-war:init',
@ -50,23 +46,20 @@ def war(
for l in pgmlibs:
cmd.extend(['--pgmlib', l])
src = []
dep = []
if docs:
src.append(DOCS_SRC)
dep.extend(DOCS_DEP)
cmd.append('$(location %s)' % DOCS_HTML)
dep.append(DOCS_HTML)
dep.append(DOCS_LIB)
cmd.extend(['--lib', DOCS_LIB])
if context:
for t in context:
dep.append(t)
cmd.append('$(location %s)' % t)
if src:
cmd.append('$SRCS')
genrule(
name = name,
cmd = ' '.join(cmd),
srcs = src,
deps = libs + pgmlibs + dep + ['//tools:pack_war'],
out = name + '.war',
visibility = visibility,

View File

@ -110,8 +110,7 @@ def gerrit_plugin(
if gwt_module:
prebuilt_jar(
name = '%s-static-jar' % name,
binary_jar = genfile('%s-static.zip' % name),
deps = [':%s-static' % name],
binary_jar = ':%s-static' % name,
)
genrule(
name = '%s-static' % name,
@ -120,8 +119,8 @@ def gerrit_plugin(
':%s__gwt_application' % name +
';cd $TMP' +
';zip -qr $OUT .',
deps = [':%s__gwt_application' % name],
out = '%s-static.zip' % name,
deps = [':%s__gwt_application' % name]
)
gwt_binary(
name = name + '__gwt_application',
@ -136,7 +135,7 @@ def gerrit_plugin(
java_binary(
name = name,
manifest_file = genfile('MANIFEST.MF'),
manifest_file = ':%s__manifest' % name,
deps = [
':%s__plugin' % name,
':%s__manifest' % name,