bazel: remove 'out' attribute from genrule2, and use throughout.

This centralizes the OSX mktemp solution.

Change-Id: Iaab18450146b649245b36865bedc5d7b50d1aa07
This commit is contained in:
Han-Wen Nienhuys
2016-10-27 11:57:01 +02:00
parent e624bc00f5
commit 29cced5e29
12 changed files with 21 additions and 27 deletions

View File

@@ -18,7 +18,7 @@ genrule2(
'@bazel_tools//tools/zip:zipper', '@bazel_tools//tools/zip:zipper',
'//lib/antlr:antlr-tool', '//lib/antlr:antlr-tool',
], ],
out = 'query_antlr.srcjar', outs = [ 'query_antlr.srcjar' ],
) )
java_library( java_library(

View File

@@ -1,4 +1,3 @@
load('//tools/bzl:genrule2.bzl', 'genrule2')
load('//tools/bzl:java.bzl', 'java_library2') load('//tools/bzl:java.bzl', 'java_library2')
load('//tools/bzl:junit.bzl', 'junit_tests') load('//tools/bzl:junit.bzl', 'junit_tests')
load('//tools/bzl:gwt.bzl', 'gwt_module') load('//tools/bzl:gwt.bzl', 'gwt_module')

View File

@@ -1,5 +1,4 @@
load('//tools/bzl:gwt.bzl', 'gwt_module') load('//tools/bzl:gwt.bzl', 'gwt_module')
load('//tools/bzl:genrule2.bzl', 'genrule2')
load('//tools/bzl:license.bzl', 'license_test') load('//tools/bzl:license.bzl', 'license_test')
load(':gwt.bzl', 'gwt_binary', 'gwt_genrule', 'gen_ui_module') load(':gwt.bzl', 'gwt_binary', 'gwt_genrule', 'gen_ui_module')

View File

@@ -33,7 +33,7 @@ genrule2(
'zip -Dq $$ROOT/$@ org/eclipse/jgit/diff/Edit.java', 'zip -Dq $$ROOT/$@ org/eclipse/jgit/diff/Edit.java',
]), ]),
tools = ['@jgit_src//file'], tools = ['@jgit_src//file'],
out = 'edit.srcjar', outs = [ 'edit.srcjar' ],
) )
java_library( java_library(

View File

@@ -35,7 +35,7 @@ genrule2(
name = 'webapp_assets', name = 'webapp_assets',
cmd = 'cd gerrit-war/src/main/webapp; zip -qr $$ROOT/$@ .', cmd = 'cd gerrit-war/src/main/webapp; zip -qr $$ROOT/$@ .',
srcs = glob(['src/main/webapp/**/*']), srcs = glob(['src/main/webapp/**/*']),
out = 'webapp_assets.zip', outs = [ 'webapp_assets.zip' ],
visibility = ['//visibility:public'], visibility = ['//visibility:public'],
) )
@@ -49,7 +49,7 @@ genrule2(
name = 'log4j-config__jar', name = 'log4j-config__jar',
cmd = 'cd gerrit-war/src/main/resources && zip -9Dqr $$ROOT/$@ .', cmd = 'cd gerrit-war/src/main/resources && zip -9Dqr $$ROOT/$@ .',
srcs = ['src/main/resources/log4j.properties'], srcs = ['src/main/resources/log4j.properties'],
out = 'log4j-config.jar', outs = [ 'log4j-config.jar' ],
) )
java_import( java_import(
@@ -67,5 +67,5 @@ genrule2(
'zip -9Dqr $$ROOT/$@ .', 'zip -9Dqr $$ROOT/$@ .',
]), ]),
tools = ['//:version.txt'], tools = ['//:version.txt'],
out = 'gen_version.jar', outs = [ 'gen_version.jar' ],
) )

View File

@@ -347,7 +347,7 @@ def pkg_cm():
] + [ ] + [
':theme_%s%s' % (n, suffix) for n in CM_THEMES ':theme_%s%s' % (n, suffix) for n in CM_THEMES
], ],
out = 'codemirror%s.jar' % suffix, outs = [ 'codemirror%s.jar' % suffix ],
) )
native.java_import( native.java_import(

View File

@@ -24,7 +24,7 @@ genrule2(
'OpenSans-Regular.woff', 'OpenSans-Regular.woff',
'OpenSans-Regular.woff2' 'OpenSans-Regular.woff2'
], ],
out = 'opensans.zip', outs = [ 'opensans.zip' ],
# TODO(hanwen): license. # TODO(hanwen): license.
# license = 'Apache2.0', # license = 'Apache2.0',
visibility = ['//visibility:public'], visibility = ['//visibility:public'],

View File

@@ -1,5 +1,4 @@
package(default_visibility = [ "//visibility:public" ]) package(default_visibility = [ "//visibility:public" ])
load('//tools/bzl:genrule2.bzl', 'genrule2')
load("//tools/bzl:js.bzl", "bower_component", "js_component") load("//tools/bzl:js.bzl", "bower_component", "js_component")
# For updating the bower versions, run # For updating the bower versions, run

View File

@@ -26,7 +26,7 @@ def prolog_cafe_library(
'$(SRCS)', '$(SRCS)',
srcs = srcs, srcs = srcs,
tools = ['//lib/prolog:compiler_bin'], tools = ['//lib/prolog:compiler_bin'],
out = name + '.srcjar', outs = [ name + '.srcjar' ],
) )
native.java_library( native.java_library(
name = name, name = name,

View File

@@ -17,6 +17,6 @@ genrule2(
'ln -s $$ROOT/$$s $$TMP/WEB-INF/plugins;done;' + 'ln -s $$ROOT/$$s $$TMP/WEB-INF/plugins;done;' +
'cd $$TMP;' + 'cd $$TMP;' +
'zip -qr $$ROOT/$@ .', 'zip -qr $$ROOT/$@ .',
out = 'core.zip', outs = [ 'core.zip' ],
visibility = ['//visibility:public'], visibility = ['//visibility:public'],
) )

View File

@@ -1,6 +1,7 @@
package( package(
default_visibility = ["//visibility:public"]) default_visibility = ["//visibility:public"])
load('//tools/bzl:genrule2.bzl', 'genrule2')
load("//tools/bzl:js.bzl", "bower_component_bundle", "vulcanize") load("//tools/bzl:js.bzl", "bower_component_bundle", "vulcanize")
bower_component_bundle( bower_component_bundle(
@@ -40,21 +41,19 @@ filegroup(
srcs = glob(['styles/**/*.css']) srcs = glob(['styles/**/*.css'])
) )
genrule( genrule2(
name = "polygerrit_ui", name = "polygerrit_ui",
cmd = " && ".join([ cmd = " && ".join([
"t=$$(mktemp -d || mktemp -d -t bazel-tmp)", "mkdir -p $$TMP/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}",
"p=$$PWD", "cp $(locations :gr-app) $$TMP/polygerrit_ui/elements/",
"mkdir -p $$t/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}", "cp $(locations //lib/fonts:sourcecodepro) $$TMP/polygerrit_ui/fonts/",
"cp $(locations :gr-app) $$t/polygerrit_ui/elements/", "for f in $(locations :top_sources); do cp $$f $$TMP/polygerrit_ui/; done",
"cp $(locations //lib/fonts:sourcecodepro) $$t/polygerrit_ui/fonts/", "for f in $(locations :css_sources); do cp $$f $$TMP/polygerrit_ui/styles; done",
"for f in $(locations :top_sources); do cp $$f $$t/polygerrit_ui/; done", "for f in $(locations //lib/js:highlightjs_files); do cp $$f $$TMP/polygerrit_ui/bower_components/highlightjs/ ; done",
"for f in $(locations :css_sources); do cp $$f $$t/polygerrit_ui/styles; done", "unzip -qd $$TMP/polygerrit_ui/bower_components $(location @webcomponentsjs//:zipfile) webcomponentsjs/webcomponents-lite.js",
"for f in $(locations //lib/js:highlightjs_files); do cp $$f $$t/polygerrit_ui/bower_components/highlightjs/ ; done", "cd $$TMP",
"unzip -qd $$t/polygerrit_ui/bower_components $(location @webcomponentsjs//:zipfile) webcomponentsjs/webcomponents-lite.js",
"cd $$t",
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -qr $$p/$@ *", "zip -qr $$ROOT/$@ *",
]), ]),
srcs = [ srcs = [
"//lib/fonts:sourcecodepro", "//lib/fonts:sourcecodepro",

View File

@@ -15,9 +15,8 @@
# Syntactic sugar for native genrule() rule: # Syntactic sugar for native genrule() rule:
# expose ROOT shell variable # expose ROOT shell variable
# expose TMP shell variable # expose TMP shell variable
# accept single output
def genrule2(out, cmd, **kwargs): def genrule2(cmd, **kwargs):
cmd = ' && '.join([ cmd = ' && '.join([
'ROOT=$$PWD', 'ROOT=$$PWD',
'TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)', 'TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)',
@@ -25,5 +24,4 @@ def genrule2(out, cmd, **kwargs):
]) ])
native.genrule( native.genrule(
cmd = cmd, cmd = cmd,
outs = [out],
**kwargs) **kwargs)