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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -69,17 +69,16 @@ maven_jar(
prebuilt_jar( prebuilt_jar(
name = 'Edit', name = 'Edit',
binary_jar = genfile('edit-src.jar'), binary_jar = ':jgit_edit_src',
deps = [':jgit_edit_src'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
genrule( genrule(
name = 'jgit_edit_src', 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;' + 'cd $TMP;' +
'zip -Dq $OUT org/eclipse/jgit/diff/Edit.java', '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', out = 'edit-src.jar',
deps = [':jgit_src']
) )

View File

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

View File

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

View File

@ -28,10 +28,11 @@ genrule(
';'.join(['echo >&2 plugins/'+n+' is required.' for n in NEED]) + ';'.join(['echo >&2 plugins/'+n+' is required.' for n in NEED]) +
(';echo >&2;exit 1;' if NEED else '') + (';echo >&2;exit 1;' if NEED else '') +
'mkdir -p $TMP/WEB-INF/plugins;' + '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;' + 'cd $TMP;' +
'zip -qr $OUT .', '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], deps = ['//%s/%s:%s' % (BASE, n, n) for n in HAVE],
out = 'core.zip', out = 'core.zip',
visibility = ['//:release'], visibility = ['//:release'],

View File

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

View File

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