Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Apply buildifier to .bzl files.
  Update Bower to 1.8.2
  Bump commons-io version to 2.2

Change-Id: Ic90865db76a0e34f0f8fef33b83ec7b2fd75c875
This commit is contained in:
David Pursehouse 2018-07-11 08:34:51 +09:00
commit 8b3324c69e
22 changed files with 1933 additions and 1803 deletions

View File

@ -1,21 +1,21 @@
load("//tools/bzl:junit.bzl", "junit_tests") load("//tools/bzl:junit.bzl", "junit_tests")
def acceptance_tests( def acceptance_tests(
group, group,
deps = [], deps = [],
labels = [], labels = [],
vm_args = ['-Xmx256m'], vm_args = ["-Xmx256m"],
**kwargs): **kwargs):
junit_tests( junit_tests(
name = group, name = group,
deps = deps + [ deps = deps + [
'//gerrit-acceptance-tests:lib', "//gerrit-acceptance-tests:lib",
], ],
tags = labels + [ tags = labels + [
'acceptance', "acceptance",
'slow', "slow",
], ],
size = "large", size = "large",
jvm_flags = vm_args, jvm_flags = vm_args,
**kwargs **kwargs
) )

View File

@ -230,126 +230,142 @@ DIFF_MATCH_PATCH_TOP = ("META-INF/resources/webjars/google-diff-match-patch/%s"
DIFF_MATCH_PATCH_VERSION) DIFF_MATCH_PATCH_VERSION)
def pkg_cm(): def pkg_cm():
for archive, suffix, top, license in [ for archive, suffix, top, license in [
('@codemirror-original//jar', '', TOP, LICENSE), ("@codemirror-original//jar", "", TOP, LICENSE),
('@codemirror-minified//jar', '_r', TOP_MINIFIED, LICENSE_MINIFIED) ("@codemirror-minified//jar", "_r", TOP_MINIFIED, LICENSE_MINIFIED),
]: ]:
# Main JavaScript and addons # Main JavaScript and addons
genrule2( genrule2(
name = 'cm' + suffix, name = "cm" + suffix,
cmd = ' && '.join([ cmd = " && ".join(
"echo '/** @license' >$@", [
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top), "echo '/** @license' >$@",
"echo '*/' >>$@", "unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
] + "echo '*/' >>$@",
['unzip -p $(location %s) %s/%s >>$@' % (archive, top, n) for n in CM_JS] + ] +
['unzip -p $(location %s) %s/addon/%s >>$@' % (archive, top, n) ["unzip -p $(location %s) %s/%s >>$@" % (archive, top, n) for n in CM_JS] +
for n in CM_ADDONS] [
), "unzip -p $(location %s) %s/addon/%s >>$@" % (archive, top, n)
tools = [archive], for n in CM_ADDONS
outs = ['cm%s.js' % suffix], ],
) ),
tools = [archive],
outs = ["cm%s.js" % suffix],
)
# Main CSS # Main CSS
genrule2( genrule2(
name = 'css' + suffix, name = "css" + suffix,
cmd = ' && '.join([ cmd = " && ".join(
"echo '/** @license' >$@", [
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top), "echo '/** @license' >$@",
"echo '*/' >>$@", "unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
] + "echo '*/' >>$@",
['unzip -p $(location %s) %s/%s >>$@' % (archive, top, n) ] +
for n in CM_CSS] [
), "unzip -p $(location %s) %s/%s >>$@" % (archive, top, n)
tools = [archive], for n in CM_CSS
outs = ['cm%s.css' % suffix], ],
) ),
tools = [archive],
outs = ["cm%s.css" % suffix],
)
# Modes # Modes
for n in CM_MODES: for n in CM_MODES:
genrule2( genrule2(
name = 'mode_%s%s' % (n, suffix), name = "mode_%s%s" % (n, suffix),
cmd = ' && '.join([ cmd = " && ".join(
"echo '/** @license' >$@", [
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top), "echo '/** @license' >$@",
"echo '*/' >>$@", "unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
'unzip -p $(location %s) %s/mode/%s/%s.js >>$@' % (archive, top, n, n), "echo '*/' >>$@",
] "unzip -p $(location %s) %s/mode/%s/%s.js >>$@" % (archive, top, n, n),
), ],
tools = [archive], ),
outs = ['mode_%s%s.js' % (n, suffix)], tools = [archive],
) outs = ["mode_%s%s.js" % (n, suffix)],
)
# Themes # Themes
for n in CM_THEMES: for n in CM_THEMES:
genrule2( genrule2(
name = 'theme_%s%s' % (n, suffix), name = "theme_%s%s" % (n, suffix),
cmd = ' && '.join([ cmd = " && ".join(
"echo '/** @license' >$@", [
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top), "echo '/** @license' >$@",
"echo '*/' >>$@", "unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
'unzip -p $(location %s) %s/theme/%s.css >>$@' % (archive, top, n) "echo '*/' >>$@",
] "unzip -p $(location %s) %s/theme/%s.css >>$@" % (archive, top, n),
), ],
tools = [archive], ),
outs = ['theme_%s%s.css' % (n, suffix)], tools = [archive],
) outs = ["theme_%s%s.css" % (n, suffix)],
)
# Merge Addon bundled with diff-match-patch # Merge Addon bundled with diff-match-patch
genrule2( genrule2(
name = 'addon_merge_with_diff_match_patch%s' % suffix, name = "addon_merge_with_diff_match_patch%s" % suffix,
cmd = ' && '.join([ cmd = " && ".join(
"echo '/** @license' >$@", [
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top), "echo '/** @license' >$@",
"echo '*/\n' >>$@", "unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
"echo '// The google-diff-match-patch library is from https://repo1.maven.org/maven2/org/webjars/google-diff-match-patch/%s/google-diff-match-patch-%s.jar\n' >> $@" % (DIFF_MATCH_PATCH_VERSION, DIFF_MATCH_PATCH_VERSION), "echo '*/\n' >>$@",
"echo '/** @license' >>$@", "echo '// The google-diff-match-patch library is from https://repo1.maven.org/maven2/org/webjars/google-diff-match-patch/%s/google-diff-match-patch-%s.jar\n' >> $@" % (DIFF_MATCH_PATCH_VERSION, DIFF_MATCH_PATCH_VERSION),
"echo 'LICENSE-Apache2.0' >>$@", "echo '/** @license' >>$@",
"echo '*/' >>$@", "echo 'LICENSE-Apache2.0' >>$@",
'unzip -p $(location @diff-match-patch//jar) %s/diff_match_patch.js >>$@' % DIFF_MATCH_PATCH_TOP, "echo '*/' >>$@",
"echo ';' >> $@", "unzip -p $(location @diff-match-patch//jar) %s/diff_match_patch.js >>$@" % DIFF_MATCH_PATCH_TOP,
'unzip -p $(location %s) %s/addon/merge/merge.js >>$@' % (archive, top) "echo ';' >> $@",
] "unzip -p $(location %s) %s/addon/merge/merge.js >>$@" % (archive, top),
), ],
tools = [ ),
'@diff-match-patch//jar', tools = [
# dependency just for license tracking. "@diff-match-patch//jar",
':diff-match-patch', # dependency just for license tracking.
archive, ":diff-match-patch",
"//lib:LICENSE-Apache2.0", archive,
], "//lib:LICENSE-Apache2.0",
outs = ['addon_merge_with_diff_match_patch%s.js' % suffix], ],
) outs = ["addon_merge_with_diff_match_patch%s.js" % suffix],
)
# Jar packaging # Jar packaging
genrule2( genrule2(
name = 'jar' + suffix, name = "jar" + suffix,
cmd = ' && '.join([ cmd = " && ".join([
'cd $$TMP', "cd $$TMP",
'mkdir -p net/codemirror/{addon,lib,mode,theme}', "mkdir -p net/codemirror/{addon,lib,mode,theme}",
'cp $$ROOT/$(location :css%s) net/codemirror/lib/cm.css' % suffix, "cp $$ROOT/$(location :css%s) net/codemirror/lib/cm.css" % suffix,
'cp $$ROOT/$(location :cm%s) net/codemirror/lib/cm.js' % suffix] "cp $$ROOT/$(location :cm%s) net/codemirror/lib/cm.js" % suffix,
+ ['cp $$ROOT/$(location :mode_%s%s) net/codemirror/mode/%s.js' % (n, suffix, n) ] +
for n in CM_MODES] [
+ ['cp $$ROOT/$(location :theme_%s%s) net/codemirror/theme/%s.css' % (n, suffix, n) "cp $$ROOT/$(location :mode_%s%s) net/codemirror/mode/%s.js" % (n, suffix, n)
for n in CM_THEMES] for n in CM_MODES
+ ['cp $$ROOT/$(location :addon_merge_with_diff_match_patch%s) net/codemirror/addon/merge_bundled.js' % suffix] ] +
+ ['zip -qr $$ROOT/$@ net/codemirror/{addon,lib,mode,theme}']), [
tools = [ "cp $$ROOT/$(location :theme_%s%s) net/codemirror/theme/%s.css" % (n, suffix, n)
':addon_merge_with_diff_match_patch%s' % suffix, for n in CM_THEMES
':cm%s' % suffix, ] +
':css%s' % suffix, ["cp $$ROOT/$(location :addon_merge_with_diff_match_patch%s) net/codemirror/addon/merge_bundled.js" % suffix] +
] + [ ["zip -qr $$ROOT/$@ net/codemirror/{addon,lib,mode,theme}"]),
':mode_%s%s' % (n, suffix) for n in CM_MODES tools = [
] + [ ":addon_merge_with_diff_match_patch%s" % suffix,
':theme_%s%s' % (n, suffix) for n in CM_THEMES ":cm%s" % suffix,
], ":css%s" % suffix,
outs = ['codemirror%s.jar' % suffix], ] + [
) ":mode_%s%s" % (n, suffix)
for n in CM_MODES
] + [
":theme_%s%s" % (n, suffix)
for n in CM_THEMES
],
outs = ["codemirror%s.jar" % suffix],
)
native.java_import( native.java_import(
name = 'codemirror' + suffix, name = "codemirror" + suffix,
jars = [':jar%s' % suffix], jars = [":jar%s" % suffix],
visibility = ['//visibility:public'], visibility = ["//visibility:public"],
data = [license], data = [license],
) )

View File

@ -1,4 +1,4 @@
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "MAVEN_CENTRAL", "maven_jar") load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_CENTRAL", "MAVEN_LOCAL", "maven_jar")
_JGIT_VERS = "4.9.2.201712150930-r.15-g5fe8e31d4" _JGIT_VERS = "4.9.2.201712150930-r.15-g5fe8e31d4"
@ -13,13 +13,13 @@ _JGIT_REPO = GERRIT # Leave here even if set to MAVEN_CENTRAL.
LOCAL_JGIT_REPO = "" LOCAL_JGIT_REPO = ""
def jgit_repos(): def jgit_repos():
if LOCAL_JGIT_REPO: if LOCAL_JGIT_REPO:
native.local_repository( native.local_repository(
name = "jgit", name = "jgit",
path = LOCAL_JGIT_REPO, path = LOCAL_JGIT_REPO,
) )
else: else:
jgit_maven_repos() jgit_maven_repos()
def jgit_maven_repos(): def jgit_maven_repos():
maven_jar( maven_jar(
@ -52,15 +52,15 @@ def jgit_maven_repos():
) )
def jgit_dep(name): def jgit_dep(name):
mapping = { mapping = {
"@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit", "@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
"@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar", "@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
"@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit", "@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
"@jgit-servlet//jar":"@jgit//org.eclipse.jgit.http.server:jgit-servlet", "@jgit-servlet//jar": "@jgit//org.eclipse.jgit.http.server:jgit-servlet",
"@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive", "@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive",
} }
if LOCAL_JGIT_REPO: if LOCAL_JGIT_REPO:
return mapping[name] return mapping[name]
else: else:
return name return name

View File

@ -7,138 +7,165 @@
load("//tools/bzl:js.bzl", "bower_archive") load("//tools/bzl:js.bzl", "bower_archive")
def load_bower_archives(): def load_bower_archives():
bower_archive( bower_archive(
name = "accessibility-developer-tools", name = "accessibility-developer-tools",
package = "accessibility-developer-tools", package = "accessibility-developer-tools",
version = "2.12.0", version = "2.12.0",
sha1 = "88ae82dcdeb6c658f76eff509d0ee425cae14d49") sha1 = "88ae82dcdeb6c658f76eff509d0ee425cae14d49",
bower_archive( )
name = "async", bower_archive(
package = "async", name = "async",
version = "1.5.2", package = "async",
sha1 = "1ec975d3b3834646a7e3d4b7e68118b90ed72508") version = "1.5.2",
bower_archive( sha1 = "1ec975d3b3834646a7e3d4b7e68118b90ed72508",
name = "chai", )
package = "chai", bower_archive(
version = "3.5.0", name = "chai",
sha1 = "849ad3ee7c77506548b7b5db603a4e150b9431aa") package = "chai",
bower_archive( version = "3.5.0",
name = "font-roboto", sha1 = "849ad3ee7c77506548b7b5db603a4e150b9431aa",
package = "PolymerElements/font-roboto", )
version = "1.0.3", bower_archive(
sha1 = "edf478d20ae2fc0704d7c155e20162caaabdd5ae") name = "font-roboto",
bower_archive( package = "PolymerElements/font-roboto",
name = "iron-a11y-announcer", version = "1.0.3",
package = "PolymerElements/iron-a11y-announcer", sha1 = "edf478d20ae2fc0704d7c155e20162caaabdd5ae",
version = "1.0.6", )
sha1 = "14aed1e1b300ea344e80362e875919ea3d104dcc") bower_archive(
bower_archive( name = "iron-a11y-announcer",
name = "iron-a11y-keys-behavior", package = "PolymerElements/iron-a11y-announcer",
package = "PolymerElements/iron-a11y-keys-behavior", version = "1.0.6",
version = "1.1.9", sha1 = "14aed1e1b300ea344e80362e875919ea3d104dcc",
sha1 = "f58358ee652c67e6e721364ba50fb77a2ece1465") )
bower_archive( bower_archive(
name = "iron-behaviors", name = "iron-a11y-keys-behavior",
package = "PolymerElements/iron-behaviors", package = "PolymerElements/iron-a11y-keys-behavior",
version = "1.0.18", version = "1.1.9",
sha1 = "e231a1a02b090f5183db917639fdb96cdd0dca18") sha1 = "f58358ee652c67e6e721364ba50fb77a2ece1465",
bower_archive( )
name = "iron-checked-element-behavior", bower_archive(
package = "PolymerElements/iron-checked-element-behavior", name = "iron-behaviors",
version = "1.0.6", package = "PolymerElements/iron-behaviors",
sha1 = "93ad3554cec119d8c5732d1c722ad113e1866370") version = "1.0.18",
bower_archive( sha1 = "e231a1a02b090f5183db917639fdb96cdd0dca18",
name = "iron-fit-behavior", )
package = "PolymerElements/iron-fit-behavior", bower_archive(
version = "1.2.7", name = "iron-checked-element-behavior",
sha1 = "01c485fbf898307029bbb72ac7e132db1570a842") package = "PolymerElements/iron-checked-element-behavior",
bower_archive( version = "1.0.6",
name = "iron-flex-layout", sha1 = "93ad3554cec119d8c5732d1c722ad113e1866370",
package = "PolymerElements/iron-flex-layout", )
version = "1.3.7", bower_archive(
sha1 = "4d4cf3232cf750a17a7df0a37476117f831ac633") name = "iron-fit-behavior",
bower_archive( package = "PolymerElements/iron-fit-behavior",
name = "iron-form-element-behavior", version = "1.2.7",
package = "PolymerElements/iron-form-element-behavior", sha1 = "01c485fbf898307029bbb72ac7e132db1570a842",
version = "1.0.7", )
sha1 = "7b5a79e02cc32f0918725dd26925d0df1e03ed12") bower_archive(
bower_archive( name = "iron-flex-layout",
name = "iron-menu-behavior", package = "PolymerElements/iron-flex-layout",
package = "PolymerElements/iron-menu-behavior", version = "1.3.7",
version = "2.0.1", sha1 = "4d4cf3232cf750a17a7df0a37476117f831ac633",
sha1 = "139528ee1e8d86257e2aa445de7761b8ec70ae91") )
bower_archive( bower_archive(
name = "iron-meta", name = "iron-form-element-behavior",
package = "PolymerElements/iron-meta", package = "PolymerElements/iron-form-element-behavior",
version = "1.1.3", version = "1.0.7",
sha1 = "f77eba3f6f6817f10bda33918bde8f963d450041") sha1 = "7b5a79e02cc32f0918725dd26925d0df1e03ed12",
bower_archive( )
name = "iron-resizable-behavior", bower_archive(
package = "polymerelements/iron-resizable-behavior", name = "iron-menu-behavior",
version = "1.0.6", package = "PolymerElements/iron-menu-behavior",
sha1 = "719c2a8a1a784f8aefcdeef41fcc2e5a03518d9e") version = "2.0.1",
bower_archive( sha1 = "139528ee1e8d86257e2aa445de7761b8ec70ae91",
name = "iron-validatable-behavior", )
package = "PolymerElements/iron-validatable-behavior", bower_archive(
version = "1.1.2", name = "iron-meta",
sha1 = "7111f34ff32e1510131dfbdb1eaa51bfa291e8be") package = "PolymerElements/iron-meta",
bower_archive( version = "1.1.3",
name = "lodash", sha1 = "f77eba3f6f6817f10bda33918bde8f963d450041",
package = "lodash", )
version = "3.10.1", bower_archive(
sha1 = "2f207a8293c4c554bf6cf071241f7a00dc513d3a") name = "iron-resizable-behavior",
bower_archive( package = "polymerelements/iron-resizable-behavior",
name = "mocha", version = "1.0.6",
package = "mocha", sha1 = "719c2a8a1a784f8aefcdeef41fcc2e5a03518d9e",
version = "3.5.3", )
sha1 = "c14f149821e4e96241b20f85134aa757b73038f1") bower_archive(
bower_archive( name = "iron-validatable-behavior",
name = "neon-animation", package = "PolymerElements/iron-validatable-behavior",
package = "polymerelements/neon-animation", version = "1.1.2",
version = "1.2.5", sha1 = "7111f34ff32e1510131dfbdb1eaa51bfa291e8be",
sha1 = "588d289f779d02b21ce5b676e257bbd6155649e8") )
bower_archive( bower_archive(
name = "paper-behaviors", name = "lodash",
package = "polymerelements/paper-behaviors", package = "lodash",
version = "1.0.13", version = "3.10.1",
sha1 = "a81eab28a952e124c208430e17508d9a1aae4ee7") sha1 = "2f207a8293c4c554bf6cf071241f7a00dc513d3a",
bower_archive( )
name = "paper-material", bower_archive(
package = "polymerelements/paper-material", name = "mocha",
version = "1.0.7", package = "mocha",
sha1 = "159b7fb6b13b181c4276b25f9c6adbeaacb0d42b") version = "3.5.3",
bower_archive( sha1 = "c14f149821e4e96241b20f85134aa757b73038f1",
name = "paper-ripple", )
package = "polymerelements/paper-ripple", bower_archive(
version = "1.0.10", name = "neon-animation",
sha1 = "21199db50d02b842da54bd6f4f1d1b10b474e893") package = "polymerelements/neon-animation",
bower_archive( version = "1.2.5",
name = "paper-styles", sha1 = "588d289f779d02b21ce5b676e257bbd6155649e8",
package = "PolymerElements/paper-styles", )
version = "1.3.1", bower_archive(
sha1 = "4ee9c692366949a754e0e39f8031aa60ce66f24d") name = "paper-behaviors",
bower_archive( package = "polymerelements/paper-behaviors",
name = "sinon-chai", version = "1.0.13",
package = "sinon-chai", sha1 = "a81eab28a952e124c208430e17508d9a1aae4ee7",
version = "2.14.0", )
sha1 = "78f0dc184efe47012a2b1b9a16a4289acf8300dc") bower_archive(
bower_archive( name = "paper-material",
name = "sinonjs", package = "polymerelements/paper-material",
package = "sinonjs", version = "1.0.7",
version = "1.17.1", sha1 = "159b7fb6b13b181c4276b25f9c6adbeaacb0d42b",
sha1 = "a26a6aab7358807de52ba738770f6ac709afd240") )
bower_archive( bower_archive(
name = "stacky", name = "paper-ripple",
package = "stacky", package = "polymerelements/paper-ripple",
version = "1.3.2", version = "1.0.10",
sha1 = "d6c07a0112ab2e9677fe085933744466a89232fb") sha1 = "21199db50d02b842da54bd6f4f1d1b10b474e893",
bower_archive( )
name = "web-animations-js", bower_archive(
package = "web-animations/web-animations-js", name = "paper-styles",
version = "2.3.1", package = "PolymerElements/paper-styles",
sha1 = "2ba5548d36188fe54555eaad0a576de4b027661e") version = "1.3.1",
bower_archive( sha1 = "4ee9c692366949a754e0e39f8031aa60ce66f24d",
name = "webcomponentsjs", )
package = "webcomponents/webcomponentsjs", bower_archive(
version = "0.7.24", name = "sinon-chai",
sha1 = "559227f8ee9db9bfbd81989f24510cc0c1bfc65c") package = "sinon-chai",
version = "2.14.0",
sha1 = "78f0dc184efe47012a2b1b9a16a4289acf8300dc",
)
bower_archive(
name = "sinonjs",
package = "sinonjs",
version = "1.17.1",
sha1 = "a26a6aab7358807de52ba738770f6ac709afd240",
)
bower_archive(
name = "stacky",
package = "stacky",
version = "1.3.2",
sha1 = "d6c07a0112ab2e9677fe085933744466a89232fb",
)
bower_archive(
name = "web-animations-js",
package = "web-animations/web-animations-js",
version = "2.3.1",
sha1 = "2ba5548d36188fe54555eaad0a576de4b027661e",
)
bower_archive(
name = "webcomponentsjs",
package = "webcomponents/webcomponentsjs",
version = "0.7.24",
sha1 = "559227f8ee9db9bfbd81989f24510cc0c1bfc65c",
)

View File

@ -7,348 +7,348 @@
load("//tools/bzl:js.bzl", "bower_component") load("//tools/bzl:js.bzl", "bower_component")
def define_bower_components(): def define_bower_components():
bower_component( bower_component(
name = "accessibility-developer-tools", name = "accessibility-developer-tools",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "async", name = "async",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "chai", name = "chai",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "es6-promise", name = "es6-promise",
license = "//lib:LICENSE-es6-promise", license = "//lib:LICENSE-es6-promise",
seed = True, seed = True,
) )
bower_component( bower_component(
name = "fetch", name = "fetch",
license = "//lib:LICENSE-fetch", license = "//lib:LICENSE-fetch",
seed = True, seed = True,
) )
bower_component( bower_component(
name = "font-roboto", name = "font-roboto",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
) )
bower_component( bower_component(
name = "iron-a11y-announcer", name = "iron-a11y-announcer",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-a11y-keys-behavior", name = "iron-a11y-keys-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-autogrow-textarea", name = "iron-autogrow-textarea",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-behaviors", ":iron-behaviors",
":iron-flex-layout", ":iron-flex-layout",
":iron-validatable-behavior", ":iron-validatable-behavior",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-behaviors", name = "iron-behaviors",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-keys-behavior", ":iron-a11y-keys-behavior",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "iron-checked-element-behavior", name = "iron-checked-element-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-form-element-behavior", ":iron-form-element-behavior",
":iron-validatable-behavior", ":iron-validatable-behavior",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "iron-dropdown", name = "iron-dropdown",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-behaviors", ":iron-behaviors",
":iron-overlay-behavior", ":iron-overlay-behavior",
":iron-resizable-behavior", ":iron-resizable-behavior",
":neon-animation", ":neon-animation",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-fit-behavior", name = "iron-fit-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-flex-layout", name = "iron-flex-layout",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-form-element-behavior", name = "iron-form-element-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-icon", name = "iron-icon",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-flex-layout", ":iron-flex-layout",
":iron-meta", ":iron-meta",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-iconset-svg", name = "iron-iconset-svg",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-meta", ":iron-meta",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-input", name = "iron-input",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-announcer", ":iron-a11y-announcer",
":iron-validatable-behavior", ":iron-validatable-behavior",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-menu-behavior", name = "iron-menu-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-keys-behavior", ":iron-a11y-keys-behavior",
":iron-flex-layout", ":iron-flex-layout",
":iron-selector", ":iron-selector",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "iron-meta", name = "iron-meta",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-overlay-behavior", name = "iron-overlay-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-keys-behavior", ":iron-a11y-keys-behavior",
":iron-fit-behavior", ":iron-fit-behavior",
":iron-resizable-behavior", ":iron-resizable-behavior",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-resizable-behavior", name = "iron-resizable-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
) )
bower_component( bower_component(
name = "iron-selector", name = "iron-selector",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":polymer" ], deps = [":polymer"],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-test-helpers", name = "iron-test-helpers",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
deps = [ ":polymer" ], deps = [":polymer"],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "iron-validatable-behavior", name = "iron-validatable-behavior",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-meta", ":iron-meta",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "lodash", name = "lodash",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "mocha", name = "mocha",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "moment", name = "moment",
license = "//lib:LICENSE-moment", license = "//lib:LICENSE-moment",
seed = True, seed = True,
) )
bower_component( bower_component(
name = "neon-animation", name = "neon-animation",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-meta", ":iron-meta",
":iron-resizable-behavior", ":iron-resizable-behavior",
":iron-selector", ":iron-selector",
":polymer", ":polymer",
":web-animations-js", ":web-animations-js",
], ],
) )
bower_component( bower_component(
name = "page", name = "page",
license = "//lib:LICENSE-page.js", license = "//lib:LICENSE-page.js",
seed = True, seed = True,
) )
bower_component( bower_component(
name = "paper-behaviors", name = "paper-behaviors",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-behaviors", ":iron-behaviors",
":iron-checked-element-behavior", ":iron-checked-element-behavior",
":paper-ripple", ":paper-ripple",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "paper-button", name = "paper-button",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-flex-layout", ":iron-flex-layout",
":paper-behaviors", ":paper-behaviors",
":paper-material", ":paper-material",
":paper-ripple", ":paper-ripple",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "paper-input", name = "paper-input",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-keys-behavior", ":iron-a11y-keys-behavior",
":iron-autogrow-textarea", ":iron-autogrow-textarea",
":iron-behaviors", ":iron-behaviors",
":iron-form-element-behavior", ":iron-form-element-behavior",
":iron-input", ":iron-input",
":paper-styles", ":paper-styles",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "paper-item", name = "paper-item",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-behaviors", ":iron-behaviors",
":iron-flex-layout", ":iron-flex-layout",
":paper-styles", ":paper-styles",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "paper-listbox", name = "paper-listbox",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-behaviors", ":iron-behaviors",
":iron-menu-behavior", ":iron-menu-behavior",
":paper-styles", ":paper-styles",
":polymer", ":polymer",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "paper-material", name = "paper-material",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":paper-styles", ":paper-styles",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "paper-ripple", name = "paper-ripple",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":iron-a11y-keys-behavior", ":iron-a11y-keys-behavior",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "paper-styles", name = "paper-styles",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":font-roboto", ":font-roboto",
":iron-flex-layout", ":iron-flex-layout",
":polymer", ":polymer",
], ],
) )
bower_component( bower_component(
name = "polymer-resin", name = "polymer-resin",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ deps = [
":polymer", ":polymer",
":webcomponentsjs", ":webcomponentsjs",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "polymer", name = "polymer",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
deps = [ ":webcomponentsjs" ], deps = [":webcomponentsjs"],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "promise-polyfill", name = "promise-polyfill",
license = "//lib:LICENSE-promise-polyfill", license = "//lib:LICENSE-promise-polyfill",
deps = [ ":polymer" ], deps = [":polymer"],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "sinon-chai", name = "sinon-chai",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "sinonjs", name = "sinonjs",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "stacky", name = "stacky",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
) )
bower_component( bower_component(
name = "test-fixture", name = "test-fixture",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
seed = True, seed = True,
) )
bower_component( bower_component(
name = "web-animations-js", name = "web-animations-js",
license = "//lib:LICENSE-Apache2.0", license = "//lib:LICENSE-Apache2.0",
) )
bower_component( bower_component(
name = "web-component-tester", name = "web-component-tester",
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE", license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
deps = [ deps = [
":accessibility-developer-tools", ":accessibility-developer-tools",
":async", ":async",
":chai", ":chai",
":lodash", ":lodash",
":mocha", ":mocha",
":sinon-chai", ":sinon-chai",
":sinonjs", ":sinonjs",
":stacky", ":stacky",
":test-fixture", ":test-fixture",
], ],
seed = True, seed = True,
) )
bower_component( bower_component(
name = "webcomponentsjs", name = "webcomponentsjs",
license = "//lib:LICENSE-polymer", license = "//lib:LICENSE-polymer",
) )

View File

@ -13,22 +13,22 @@
# limitations under the License. # limitations under the License.
def prolog_cafe_library( def prolog_cafe_library(
name, name,
srcs, srcs,
deps = [], deps = [],
**kwargs): **kwargs):
native.genrule( native.genrule(
name = name + '__pl2j', name = name + "__pl2j",
cmd = '$(location //lib/prolog:compiler-bin) ' + cmd = "$(location //lib/prolog:compiler-bin) " +
'$$(dirname $@) $@ ' + "$$(dirname $@) $@ " +
'$(SRCS)', "$(SRCS)",
srcs = srcs, srcs = srcs,
tools = ['//lib/prolog:compiler-bin'], tools = ["//lib/prolog:compiler-bin"],
outs = [ name + '.srcjar' ], outs = [name + ".srcjar"],
) )
native.java_library( native.java_library(
name = name, name = name,
srcs = [':' + name + '__pl2j'], srcs = [":" + name + "__pl2j"],
deps = ['//lib/prolog:runtime-neverlink'] + deps, deps = ["//lib/prolog:runtime-neverlink"] + deps,
**kwargs **kwargs
) )

View File

@ -1,2 +1,2 @@
def external_plugin_deps(): def external_plugin_deps():
pass pass

View File

@ -1,98 +1,98 @@
load("//tools/bzl:genrule2.bzl", "genrule2") load("//tools/bzl:genrule2.bzl", "genrule2")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_binary") load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
load( load(
"//tools/bzl:js.bzl", "//tools/bzl:js.bzl",
"bower_component_bundle",
"vulcanize",
"bower_component", "bower_component",
"bower_component_bundle",
"js_component", "js_component",
"vulcanize",
) )
def polygerrit_bundle(name, srcs, outs, app): def polygerrit_bundle(name, srcs, outs, app):
appName = app.split(".html")[0].split("/").pop() # eg: gr-app appName = app.split(".html")[0].split("/").pop() # eg: gr-app
closure_js_binary( closure_js_binary(
name = name + "_closure_bin", name = name + "_closure_bin",
# Known issue: Closure compilation not compatible with Polymer behaviors. # Known issue: Closure compilation not compatible with Polymer behaviors.
# See: https://github.com/google/closure-compiler/issues/2042 # See: https://github.com/google/closure-compiler/issues/2042
compilation_level = "WHITESPACE_ONLY", compilation_level = "WHITESPACE_ONLY",
defs = [ defs = [
"--polymer_pass", "--polymer_pass",
"--jscomp_off=duplicate", "--jscomp_off=duplicate",
"--force_inject_library=es6_runtime", "--force_inject_library=es6_runtime",
], ],
language = "ECMASCRIPT5", language = "ECMASCRIPT5",
deps = [name + "_closure_lib"], deps = [name + "_closure_lib"],
) )
closure_js_library( closure_js_library(
name = name + "_closure_lib", name = name + "_closure_lib",
srcs = [appName + ".js"], srcs = [appName + ".js"],
convention = "GOOGLE", convention = "GOOGLE",
# TODO(davido): Clean up these issues: http://paste.openstack.org/show/608548 # TODO(davido): Clean up these issues: http://paste.openstack.org/show/608548
# and remove this supression # and remove this supression
suppress = [ suppress = [
"JSC_JSDOC_MISSING_TYPE_WARNING", "JSC_JSDOC_MISSING_TYPE_WARNING",
"JSC_UNNECESSARY_ESCAPE", "JSC_UNNECESSARY_ESCAPE",
"JSC_UNUSED_LOCAL_ASSIGNMENT", "JSC_UNUSED_LOCAL_ASSIGNMENT",
], ],
deps = [ deps = [
"//lib/polymer_externs:polymer_closure", "//lib/polymer_externs:polymer_closure",
"@io_bazel_rules_closure//closure/library", "@io_bazel_rules_closure//closure/library",
], ],
) )
vulcanize( vulcanize(
name = appName, name = appName,
srcs = srcs, srcs = srcs,
app = app, app = app,
deps = ["//polygerrit-ui:polygerrit_components.bower_components"], deps = ["//polygerrit-ui:polygerrit_components.bower_components"],
) )
native.filegroup( native.filegroup(
name = name + "_app_sources", name = name + "_app_sources",
srcs = [ srcs = [
name + "_closure_bin.js", name + "_closure_bin.js",
appName + ".html", appName + ".html",
], ],
) )
native.filegroup( native.filegroup(
name = name + "_css_sources", name = name + "_css_sources",
srcs = native.glob(["styles/**/*.css"]), srcs = native.glob(["styles/**/*.css"]),
) )
native.filegroup( native.filegroup(
name = name + "_top_sources", name = name + "_top_sources",
srcs = [ srcs = [
"favicon.ico", "favicon.ico",
"index.html", "index.html",
], ],
) )
genrule2( genrule2(
name = name, name = name,
srcs = [ srcs = [
name + "_app_sources", name + "_app_sources",
name + "_css_sources", name + "_css_sources",
name + "_top_sources", name + "_top_sources",
"//lib/fonts:robotofonts", "//lib/fonts:robotofonts",
"//lib/js:highlightjs_files", "//lib/js:highlightjs_files",
# we extract from the zip, but depend on the component for license checking. # we extract from the zip, but depend on the component for license checking.
"@webcomponentsjs//:zipfile", "@webcomponentsjs//:zipfile",
"//lib/js:webcomponentsjs" "//lib/js:webcomponentsjs",
], ],
outs = outs, outs = outs,
cmd = " && ".join([ cmd = " && ".join([
"mkdir -p $$TMP/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}", "mkdir -p $$TMP/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}",
"for f in $(locations " + name + "_app_sources); do ext=$${f##*.}; cp -p $$f $$TMP/polygerrit_ui/elements/" + appName + ".$$ext; done", "for f in $(locations " + name + "_app_sources); do ext=$${f##*.}; cp -p $$f $$TMP/polygerrit_ui/elements/" + appName + ".$$ext; done",
"cp $(locations //lib/fonts:robotofonts) $$TMP/polygerrit_ui/fonts/", "cp $(locations //lib/fonts:robotofonts) $$TMP/polygerrit_ui/fonts/",
"for f in $(locations " + name + "_top_sources); do cp $$f $$TMP/polygerrit_ui/; done", "for f in $(locations " + name + "_top_sources); do cp $$f $$TMP/polygerrit_ui/; done",
"for f in $(locations "+ name + "_css_sources); do cp $$f $$TMP/polygerrit_ui/styles; done", "for f in $(locations " + name + "_css_sources); do cp $$f $$TMP/polygerrit_ui/styles; done",
"for f in $(locations //lib/js:highlightjs_files); do cp $$f $$TMP/polygerrit_ui/bower_components/highlightjs/ ; done", "for f in $(locations //lib/js:highlightjs_files); do cp $$f $$TMP/polygerrit_ui/bower_components/highlightjs/ ; done",
"unzip -qd $$TMP/polygerrit_ui/bower_components $(location @webcomponentsjs//:zipfile) webcomponentsjs/webcomponents-lite.js", "unzip -qd $$TMP/polygerrit_ui/bower_components $(location @webcomponentsjs//:zipfile) webcomponentsjs/webcomponents-lite.js",
"cd $$TMP", "cd $$TMP",
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -qr $$ROOT/$@ *", "zip -qr $$ROOT/$@ *",
]), ]),
) )

View File

@ -1,55 +1,58 @@
def documentation_attributes(): def documentation_attributes():
return [ return [
"toc2", "toc2",
'newline="\\n"', 'newline="\\n"',
'asterisk="*"', 'asterisk="*"',
'plus="+"', 'plus="+"',
'caret="^"', 'caret="^"',
'startsb="["', 'startsb="["',
'endsb="]"', 'endsb="]"',
'tilde="~"', 'tilde="~"',
"last-update-label!", "last-update-label!",
"source-highlighter=prettify", "source-highlighter=prettify",
"stylesheet=DEFAULT", "stylesheet=DEFAULT",
"linkcss=true", "linkcss=true",
"prettifydir=.", "prettifydir=.",
# Just a placeholder, will be filled in asciidoctor java binary: # Just a placeholder, will be filled in asciidoctor java binary:
"revnumber=%s", "revnumber=%s",
] ]
def release_notes_attributes(): def release_notes_attributes():
return [ return [
'toc', "toc",
'newline="\\n"', 'newline="\\n"',
'asterisk="*"', 'asterisk="*"',
'plus="+"', 'plus="+"',
'caret="^"', 'caret="^"',
'startsb="["', 'startsb="["',
'endsb="]"', 'endsb="]"',
'tilde="~"', 'tilde="~"',
'last-update-label!', "last-update-label!",
'stylesheet=DEFAULT', "stylesheet=DEFAULT",
'linkcss=true', "linkcss=true",
] ]
def _replace_macros_impl(ctx): def _replace_macros_impl(ctx):
cmd = [ cmd = [
ctx.file._exe.path, ctx.file._exe.path,
'--suffix', ctx.attr.suffix, "--suffix",
"-s", ctx.file.src.path, ctx.attr.suffix,
"-o", ctx.outputs.out.path, "-s",
] ctx.file.src.path,
if ctx.attr.searchbox: "-o",
cmd.append('--searchbox') ctx.outputs.out.path,
else: ]
cmd.append('--no-searchbox') if ctx.attr.searchbox:
ctx.actions.run_shell( cmd.append("--searchbox")
inputs = [ctx.file._exe, ctx.file.src], else:
outputs = [ctx.outputs.out], cmd.append("--no-searchbox")
command = cmd, ctx.actions.run_shell(
use_default_shell_env = True, inputs = [ctx.file._exe, ctx.file.src],
progress_message = "Replacing macros in %s" % ctx.file.src.short_path, outputs = [ctx.outputs.out],
) command = cmd,
use_default_shell_env = True,
progress_message = "Replacing macros in %s" % ctx.file.src.short_path,
)
_replace_macros = rule( _replace_macros = rule(
attrs = { attrs = {
@ -69,52 +72,55 @@ _replace_macros = rule(
) )
def _generate_asciidoc_args(ctx): def _generate_asciidoc_args(ctx):
args = [] args = []
if ctx.attr.backend: if ctx.attr.backend:
args.extend(["-b", ctx.attr.backend]) args.extend(["-b", ctx.attr.backend])
revnumber = False revnumber = False
for attribute in ctx.attr.attributes: for attribute in ctx.attr.attributes:
if attribute.startswith("revnumber="): if attribute.startswith("revnumber="):
revnumber = True revnumber = True
else: else:
args.extend(["-a", attribute]) args.extend(["-a", attribute])
if revnumber: if revnumber:
args.extend([ args.extend([
"--revnumber-file", ctx.file.version.path, "--revnumber-file",
]) ctx.file.version.path,
for src in ctx.files.srcs: ])
args.append(src.path) for src in ctx.files.srcs:
return args args.append(src.path)
return args
def _invoke_replace_macros(name, src, suffix, searchbox): def _invoke_replace_macros(name, src, suffix, searchbox):
fn = src fn = src
if fn.startswith(":"): if fn.startswith(":"):
fn = src[1:] fn = src[1:]
_replace_macros( _replace_macros(
name = "macros_%s_%s" % (name, fn), name = "macros_%s_%s" % (name, fn),
src = src, src = src,
out = fn + suffix, out = fn + suffix,
suffix = suffix, suffix = suffix,
searchbox = searchbox, searchbox = searchbox,
) )
return ":" + fn + suffix, fn.replace(".txt", ".html") return ":" + fn + suffix, fn.replace(".txt", ".html")
def _asciidoc_impl(ctx): def _asciidoc_impl(ctx):
args = [ args = [
"--bazel", "--bazel",
"--in-ext", ".txt" + ctx.attr.suffix, "--in-ext",
"--out-ext", ".html", ".txt" + ctx.attr.suffix,
] "--out-ext",
args.extend(_generate_asciidoc_args(ctx)) ".html",
ctx.actions.run( ]
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version], args.extend(_generate_asciidoc_args(ctx))
outputs = ctx.outputs.outs, ctx.actions.run(
executable = ctx.executable._exe, inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
arguments = args, outputs = ctx.outputs.outs,
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name, executable = ctx.executable._exe,
) arguments = args,
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
)
_asciidoc_attrs = { _asciidoc_attrs = {
"_exe": attr.label( "_exe": attr.label(
@ -144,81 +150,84 @@ _asciidoc = rule(
) )
def _genasciidoc_htmlonly( def _genasciidoc_htmlonly(
name, name,
srcs = [], srcs = [],
attributes = [], attributes = [],
backend = None, backend = None,
searchbox = True, searchbox = True,
**kwargs): **kwargs):
SUFFIX = "." + name + "_macros" SUFFIX = "." + name + "_macros"
new_srcs = [] new_srcs = []
outs = ["asciidoctor.css"] outs = ["asciidoctor.css"]
for src in srcs: for src in srcs:
new_src, html_name = _invoke_replace_macros(name, src, SUFFIX, searchbox) new_src, html_name = _invoke_replace_macros(name, src, SUFFIX, searchbox)
new_srcs.append(new_src) new_srcs.append(new_src)
outs.append(html_name) outs.append(html_name)
_asciidoc( _asciidoc(
name = name + "_gen", name = name + "_gen",
srcs = new_srcs, srcs = new_srcs,
suffix = SUFFIX, suffix = SUFFIX,
backend = backend, backend = backend,
attributes = attributes, attributes = attributes,
outs = outs, outs = outs,
)
native.filegroup(
name = name,
data = outs,
**kwargs
)
def genasciidoc(
name,
srcs = [],
attributes = [],
backend = None,
searchbox = True,
resources = True,
**kwargs):
SUFFIX = "_htmlonly"
_genasciidoc_htmlonly(
name = name + SUFFIX if resources else name,
srcs = srcs,
attributes = attributes,
backend = backend,
searchbox = searchbox,
**kwargs
)
if resources:
htmlonly = ":" + name + SUFFIX
native.filegroup(
name = name,
srcs = [
htmlonly,
"//Documentation:resources",
],
**kwargs
) )
native.filegroup(
name = name,
data = outs,
**kwargs
)
def genasciidoc(
name,
srcs = [],
attributes = [],
backend = None,
searchbox = True,
resources = True,
**kwargs):
SUFFIX = "_htmlonly"
_genasciidoc_htmlonly(
name = name + SUFFIX if resources else name,
srcs = srcs,
attributes = attributes,
backend = backend,
searchbox = searchbox,
**kwargs
)
if resources:
htmlonly = ":" + name + SUFFIX
native.filegroup(
name = name,
srcs = [
htmlonly,
"//Documentation:resources",
],
**kwargs
)
def _asciidoc_html_zip_impl(ctx): def _asciidoc_html_zip_impl(ctx):
args = [ args = [
"--mktmp", "--mktmp",
"-z", ctx.outputs.out.path, "-z",
"--in-ext", ".txt" + ctx.attr.suffix, ctx.outputs.out.path,
"--out-ext", ".html", "--in-ext",
] ".txt" + ctx.attr.suffix,
args.extend(_generate_asciidoc_args(ctx)) "--out-ext",
ctx.actions.run( ".html",
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version], ]
outputs = [ctx.outputs.out], args.extend(_generate_asciidoc_args(ctx))
executable = ctx.executable._exe, ctx.actions.run(
arguments = args, inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name, outputs = [ctx.outputs.out],
) executable = ctx.executable._exe,
arguments = args,
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
)
_asciidoc_html_zip = rule( _asciidoc_html_zip = rule(
attrs = _asciidoc_attrs, attrs = _asciidoc_attrs,
@ -229,53 +238,54 @@ _asciidoc_html_zip = rule(
) )
def _genasciidoc_htmlonly_zip( def _genasciidoc_htmlonly_zip(
name, name,
srcs = [], srcs = [],
attributes = [], attributes = [],
backend = None, backend = None,
searchbox = True, searchbox = True,
**kwargs): **kwargs):
SUFFIX = "." + name + "_expn" SUFFIX = "." + name + "_expn"
new_srcs = [] new_srcs = []
for src in srcs: for src in srcs:
new_src, _ = _invoke_replace_macros(name, src, SUFFIX, searchbox) new_src, _ = _invoke_replace_macros(name, src, SUFFIX, searchbox)
new_srcs.append(new_src) new_srcs.append(new_src)
_asciidoc_html_zip( _asciidoc_html_zip(
name = name, name = name,
srcs = new_srcs, srcs = new_srcs,
suffix = SUFFIX, suffix = SUFFIX,
backend = backend, backend = backend,
attributes = attributes, attributes = attributes,
) )
def _asciidoc_zip_impl(ctx): def _asciidoc_zip_impl(ctx):
tmpdir = ctx.outputs.out.path + "_tmpdir" tmpdir = ctx.outputs.out.path + "_tmpdir"
cmd = [ cmd = [
"p=$PWD", "p=$PWD",
"rm -rf %s" % tmpdir, "rm -rf %s" % tmpdir,
"mkdir -p %s/%s/" % (tmpdir, ctx.attr.directory), "mkdir -p %s/%s/" % (tmpdir, ctx.attr.directory),
"unzip -q %s -d %s/%s/" % (ctx.file.src.path, tmpdir, ctx.attr.directory), "unzip -q %s -d %s/%s/" % (ctx.file.src.path, tmpdir, ctx.attr.directory),
] ]
for r in ctx.files.resources: for r in ctx.files.resources:
if r.path == r.short_path: if r.path == r.short_path:
cmd.append("tar -cf- %s | tar -C %s -xf-" % (r.short_path, tmpdir)) cmd.append("tar -cf- %s | tar -C %s -xf-" % (r.short_path, tmpdir))
else: else:
parent = r.path[:-len(r.short_path)] parent = r.path[:-len(r.short_path)]
cmd.append( cmd.append(
"tar -C %s -cf- %s | tar -C %s -xf-" % (parent, r.short_path, tmpdir)) "tar -C %s -cf- %s | tar -C %s -xf-" % (parent, r.short_path, tmpdir),
cmd.extend([ )
"cd %s" % tmpdir, cmd.extend([
"zip -qr $p/%s *" % ctx.outputs.out.path, "cd %s" % tmpdir,
]) "zip -qr $p/%s *" % ctx.outputs.out.path,
ctx.actions.run_shell( ])
inputs = [ctx.file.src] + ctx.files.resources, ctx.actions.run_shell(
outputs = [ctx.outputs.out], inputs = [ctx.file.src] + ctx.files.resources,
command = " && ".join(cmd), outputs = [ctx.outputs.out],
progress_message = command = " && ".join(cmd),
"Generating asciidoctor zip file %s" % ctx.outputs.out.short_path, progress_message =
) "Generating asciidoctor zip file %s" % ctx.outputs.out.short_path,
)
_asciidoc_zip = rule( _asciidoc_zip = rule(
attrs = { attrs = {
@ -296,30 +306,30 @@ _asciidoc_zip = rule(
) )
def genasciidoc_zip( def genasciidoc_zip(
name, name,
srcs = [], srcs = [],
attributes = [], attributes = [],
directory = None, directory = None,
backend = None, backend = None,
searchbox = True, searchbox = True,
resources = True, resources = True,
**kwargs): **kwargs):
SUFFIX = "_htmlonly" SUFFIX = "_htmlonly"
_genasciidoc_htmlonly_zip( _genasciidoc_htmlonly_zip(
name = name + SUFFIX if resources else name, name = name + SUFFIX if resources else name,
srcs = srcs, srcs = srcs,
attributes = attributes, attributes = attributes,
backend = backend, backend = backend,
searchbox = searchbox, searchbox = searchbox,
**kwargs **kwargs
)
if resources:
htmlonly = ":" + name + SUFFIX
_asciidoc_zip(
name = name,
src = htmlonly,
resources = ["//Documentation:resources"],
directory = directory,
) )
if resources:
htmlonly = ":" + name + SUFFIX
_asciidoc_zip(
name = name,
src = htmlonly,
resources = ["//Documentation:resources"],
directory = directory,
)

View File

@ -1,15 +1,17 @@
def _classpath_collector(ctx): def _classpath_collector(ctx):
all = depset() all = depset()
for d in ctx.attr.deps: for d in ctx.attr.deps:
if hasattr(d, 'java'): if hasattr(d, "java"):
all += d.java.transitive_runtime_deps all += d.java.transitive_runtime_deps
all += d.java.compilation_info.runtime_classpath all += d.java.compilation_info.runtime_classpath
elif hasattr(d, 'files'): elif hasattr(d, "files"):
all += d.files all += d.files
as_strs = [c.path for c in all] as_strs = [c.path for c in all]
ctx.file_action(output= ctx.outputs.runtime, ctx.file_action(
content="\n".join(sorted(as_strs))) output = ctx.outputs.runtime,
content = "\n".join(sorted(as_strs)),
)
classpath_collector = rule( classpath_collector = rule(
attrs = { attrs = {

View File

@ -17,11 +17,12 @@
# expose TMP shell variable # expose TMP shell variable
def genrule2(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)",
'(' + cmd + ')', "(" + cmd + ")",
]) ])
native.genrule( native.genrule(
cmd = cmd, cmd = cmd,
**kwargs) **kwargs
)

View File

@ -92,115 +92,120 @@ USER_AGENT_XML = """<module rename-to='gerrit_ui'>
</module> </module>
""" """
def gwt_module(gwt_xml=None, resources=[], srcs=[], **kwargs): def gwt_module(gwt_xml = None, resources = [], srcs = [], **kwargs):
if gwt_xml: if gwt_xml:
resources = resources + [gwt_xml] resources = resources + [gwt_xml]
java_library2( java_library2(
srcs = srcs, srcs = srcs,
resources = resources, resources = resources,
**kwargs) **kwargs
)
def _gwt_user_agent_module(ctx): def _gwt_user_agent_module(ctx):
"""Generate user agent specific GWT module.""" """Generate user agent specific GWT module."""
if not ctx.attr.user_agent: if not ctx.attr.user_agent:
return None return None
ua = ctx.attr.user_agent ua = ctx.attr.user_agent
impl = ua impl = ua
if ua in ALIASES: if ua in ALIASES:
impl = ALIASES[ua] impl = ALIASES[ua]
# intermediate artifact: user agent speific GWT xml file # intermediate artifact: user agent speific GWT xml file
gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml") gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
ctx.file_action(output = gwt_user_agent_xml, ctx.file_action(
content=USER_AGENT_XML % (MODULE, impl)) output = gwt_user_agent_xml,
content = USER_AGENT_XML % (MODULE, impl),
)
# intermediate artifact: user agent specific zip with GWT module # intermediate artifact: user agent specific zip with GWT module
gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip") gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
gwt = '%s_%s.gwt.xml' % (MODULE.replace('.', '/'), ua) gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua)
dir = gwt_user_agent_zip.path + ".dir" dir = gwt_user_agent_zip.path + ".dir"
cmd = " && ".join([ cmd = " && ".join([
"p=$PWD", "p=$PWD",
"mkdir -p %s" % dir, "mkdir -p %s" % dir,
"cd %s" % dir, "cd %s" % dir,
"mkdir -p $(dirname %s)" % gwt, "mkdir -p $(dirname %s)" % gwt,
"cp $p/%s %s" % (gwt_user_agent_xml.path, gwt), "cp $p/%s %s" % (gwt_user_agent_xml.path, gwt),
"$p/%s cC $p/%s $(find . | sed 's|^./||')" % (ctx.executable._zip.path, gwt_user_agent_zip.path) "$p/%s cC $p/%s $(find . | sed 's|^./||')" % (ctx.executable._zip.path, gwt_user_agent_zip.path),
]) ])
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = [gwt_user_agent_xml] + ctx.files._zip, inputs = [gwt_user_agent_xml] + ctx.files._zip,
outputs = [gwt_user_agent_zip], outputs = [gwt_user_agent_zip],
command = cmd, command = cmd,
mnemonic = "GenerateUserAgentGWTModule") mnemonic = "GenerateUserAgentGWTModule",
)
return struct( return struct(
zip=gwt_user_agent_zip, zip = gwt_user_agent_zip,
module=MODULE + '_' + ua module = MODULE + "_" + ua,
) )
def _gwt_binary_impl(ctx): def _gwt_binary_impl(ctx):
module = ctx.attr.module[0] module = ctx.attr.module[0]
output_zip = ctx.outputs.output output_zip = ctx.outputs.output
output_dir = output_zip.path + '.gwt_output' output_dir = output_zip.path + ".gwt_output"
deploy_dir = output_zip.path + '.gwt_deploy' deploy_dir = output_zip.path + ".gwt_deploy"
deps = _get_transitive_closure(ctx) deps = _get_transitive_closure(ctx)
paths = [] paths = []
for dep in deps: for dep in deps:
paths.append(dep.path) paths.append(dep.path)
gwt_user_agent_modules = [] gwt_user_agent_modules = []
ua = _gwt_user_agent_module(ctx) ua = _gwt_user_agent_module(ctx)
if ua: if ua:
paths.append(ua.zip.path) paths.append(ua.zip.path)
gwt_user_agent_modules.append(ua.zip) gwt_user_agent_modules.append(ua.zip)
module = ua.module module = ua.module
cmd = "external/local_jdk/bin/java %s -Dgwt.normalizeTimestamps=true -cp %s %s -war %s -deploy %s " % ( cmd = "external/local_jdk/bin/java %s -Dgwt.normalizeTimestamps=true -cp %s %s -war %s -deploy %s " % (
" ".join(ctx.attr.jvm_args), " ".join(ctx.attr.jvm_args),
":".join(paths), ":".join(paths),
GWT_COMPILER, GWT_COMPILER,
output_dir, output_dir,
deploy_dir, deploy_dir,
)
# TODO(davido): clean up command concatenation
cmd += " ".join([
"-style %s" % ctx.attr.style,
"-optimize %s" % ctx.attr.optimize,
"-strict",
" ".join(ctx.attr.compiler_args),
module + "\n",
"rm -rf %s/gwt-unitCache\n" % output_dir,
"root=`pwd`\n",
"cd %s; $root/%s Cc ../%s $(find .)\n" % (
output_dir,
ctx.executable._zip.path,
output_zip.basename,
) )
])
ctx.actions.run_shell( # TODO(davido): clean up command concatenation
inputs = list(deps) + ctx.files._jdk + ctx.files._zip + gwt_user_agent_modules, cmd += " ".join([
outputs = [output_zip], "-style %s" % ctx.attr.style,
mnemonic = "GwtBinary", "-optimize %s" % ctx.attr.optimize,
progress_message = "GWT compiling " + output_zip.short_path, "-strict",
command = "set -e\n" + cmd, " ".join(ctx.attr.compiler_args),
) module + "\n",
"rm -rf %s/gwt-unitCache\n" % output_dir,
"root=`pwd`\n",
"cd %s; $root/%s Cc ../%s $(find .)\n" % (
output_dir,
ctx.executable._zip.path,
output_zip.basename,
),
])
ctx.actions.run_shell(
inputs = list(deps) + ctx.files._jdk + ctx.files._zip + gwt_user_agent_modules,
outputs = [output_zip],
mnemonic = "GwtBinary",
progress_message = "GWT compiling " + output_zip.short_path,
command = "set -e\n" + cmd,
)
def _get_transitive_closure(ctx): def _get_transitive_closure(ctx):
deps = depset() deps = depset()
for dep in ctx.attr.module_deps: for dep in ctx.attr.module_deps:
deps += dep.java.transitive_runtime_deps deps += dep.java.transitive_runtime_deps
deps += dep.java.transitive_source_jars deps += dep.java.transitive_source_jars
for dep in ctx.attr.deps: for dep in ctx.attr.deps:
if hasattr(dep, 'java'): if hasattr(dep, "java"):
deps += dep.java.transitive_runtime_deps deps += dep.java.transitive_runtime_deps
elif hasattr(dep, 'files'): elif hasattr(dep, "files"):
deps += dep.files deps += dep.files
return deps return deps
gwt_binary = rule( gwt_binary = rule(
attrs = { attrs = {
@ -229,77 +234,78 @@ gwt_binary = rule(
) )
def gwt_genrule(suffix = ""): def gwt_genrule(suffix = ""):
dbg = 'ui_dbg' + suffix dbg = "ui_dbg" + suffix
opt = 'ui_opt' + suffix opt = "ui_opt" + suffix
module_dep = ':ui_module' + suffix module_dep = ":ui_module" + suffix
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
genrule2( genrule2(
name = 'ui_optdbg' + suffix, name = "ui_optdbg" + suffix,
srcs = [ srcs = [
':' + dbg, ":" + dbg,
':' + opt, ":" + opt,
], ],
cmd = 'cd $$TMP;' + cmd = "cd $$TMP;" +
'unzip -q $$ROOT/$(location :%s);' % dbg + "unzip -q $$ROOT/$(location :%s);" % dbg +
'mv' + "mv" +
' gerrit_ui/gerrit_ui.nocache.js' + " gerrit_ui/gerrit_ui.nocache.js" +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' + " gerrit_ui/dbg_gerrit_ui.nocache.js;" +
'unzip -qo $$ROOT/$(location :%s);' % opt + "unzip -qo $$ROOT/$(location :%s);" % opt +
'mkdir -p $$(dirname $@);' + "mkdir -p $$(dirname $@);" +
'zip -qrD $$ROOT/$@ .', "zip -qrD $$ROOT/$@ .",
outs = ['ui_optdbg' + suffix + '.zip'], outs = ["ui_optdbg" + suffix + ".zip"],
visibility = ['//visibility:public'], visibility = ["//visibility:public"],
) )
gwt_binary( gwt_binary(
name = opt, name = opt,
module = [MODULE], module = [MODULE],
module_deps = [module_dep], module_deps = [module_dep],
deps = DEPS, deps = DEPS,
compiler_args = args, compiler_args = args,
jvm_args = GWT_JVM_ARGS, jvm_args = GWT_JVM_ARGS,
) )
gwt_binary( gwt_binary(
name = dbg, name = dbg,
style = 'PRETTY', style = "PRETTY",
optimize = "0", optimize = "0",
module_deps = [module_dep], module_deps = [module_dep],
deps = DEPS, deps = DEPS,
compiler_args = GWT_COMPILER_ARGS, compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS, jvm_args = GWT_JVM_ARGS,
) )
def gen_ui_module(name, suffix = ""): def gen_ui_module(name, suffix = ""):
gwt_module( gwt_module(
name = name + suffix, name = name + suffix,
srcs = native.glob(['src/main/java/**/*.java']), srcs = native.glob(["src/main/java/**/*.java"]),
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'), gwt_xml = "src/main/java/%s.gwt.xml" % MODULE.replace(".", "/"),
resources = native.glob( resources = native.glob(
['src/main/java/**/*'], ["src/main/java/**/*"],
exclude = ['src/main/java/**/*.java'] + exclude = ["src/main/java/**/*.java"] +
['src/main/java/%s.gwt.xml' % MODULE.replace('.', '/')]), ["src/main/java/%s.gwt.xml" % MODULE.replace(".", "/")],
deps = [ ),
'//gerrit-gwtui-common:diffy_logo', deps = [
'//gerrit-gwtui-common:client', "//gerrit-gwtui-common:diffy_logo",
'//gerrit-gwtexpui:CSS', "//gerrit-gwtui-common:client",
'//lib/codemirror:codemirror' + suffix, "//gerrit-gwtexpui:CSS",
'//lib/gwt:user', "//lib/codemirror:codemirror" + suffix,
], "//lib/gwt:user",
visibility = ['//visibility:public'], ],
) visibility = ["//visibility:public"],
)
def gwt_user_agent_permutations(): def gwt_user_agent_permutations():
for ua in BROWSERS: for ua in BROWSERS:
gwt_binary( gwt_binary(
name = "ui_%s" % ua, name = "ui_%s" % ua,
user_agent = ua, user_agent = ua,
style = 'PRETTY', style = "PRETTY",
optimize = "0", optimize = "0",
module = [MODULE], module = [MODULE],
module_deps = [':ui_module'], module_deps = [":ui_module"],
deps = DEPS, deps = DEPS,
compiler_args = GWT_COMPILER_ARGS, compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS, jvm_args = GWT_JVM_ARGS,
) )

View File

@ -15,11 +15,12 @@
# Syntactic sugar for native java_library() rule: # Syntactic sugar for native java_library() rule:
# accept exported_deps attributes # accept exported_deps attributes
def java_library2(deps=[], exported_deps=[], exports=[], **kwargs): def java_library2(deps = [], exported_deps = [], exports = [], **kwargs):
if exported_deps: if exported_deps:
deps = deps + exported_deps deps = deps + exported_deps
exports = exports + exported_deps exports = exports + exported_deps
native.java_library( native.java_library(
deps = deps, deps = deps,
exports = exports, exports = exports,
**kwargs) **kwargs
)

View File

@ -15,49 +15,51 @@
# Javadoc rule. # Javadoc rule.
def _impl(ctx): def _impl(ctx):
zip_output = ctx.outputs.zip zip_output = ctx.outputs.zip
transitive_jar_set = depset() transitive_jar_set = depset()
source_jars = depset() source_jars = depset()
for l in ctx.attr.libs: for l in ctx.attr.libs:
source_jars += l.java.source_jars source_jars += l.java.source_jars
transitive_jar_set += l.java.transitive_deps transitive_jar_set += l.java.transitive_deps
transitive_jar_paths = [j.path for j in transitive_jar_set] transitive_jar_paths = [j.path for j in transitive_jar_set]
dir = ctx.outputs.zip.path + ".dir" dir = ctx.outputs.zip.path + ".dir"
source = ctx.outputs.zip.path + ".source" source = ctx.outputs.zip.path + ".source"
external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
cmd = [ cmd = [
"TZ=UTC", "TZ=UTC",
"export TZ", "export TZ",
"rm -rf %s" % source, "rm -rf %s" % source,
"mkdir %s" % source, "mkdir %s" % source,
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]), " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
"rm -rf %s" % dir, "rm -rf %s" % dir,
"mkdir %s" % dir, "mkdir %s" % dir,
" ".join([ " ".join([
ctx.file._javadoc.path, ctx.file._javadoc.path,
"-Xdoclint:-missing", "-Xdoclint:-missing",
"-protected", "-protected",
"-encoding UTF-8", "-encoding UTF-8",
"-charset UTF-8", "-charset UTF-8",
"-notimestamp", "-notimestamp",
"-quiet", "-quiet",
"-windowtitle '%s'" % ctx.attr.title, "-windowtitle '%s'" % ctx.attr.title,
" ".join(['-link %s' % url for url in external_docs]), " ".join(["-link %s" % url for url in external_docs]),
"-sourcepath %s" % source, "-sourcepath %s" % source,
"-subpackages ", "-subpackages ",
":".join(ctx.attr.pkgs), ":".join(ctx.attr.pkgs),
" -classpath ", " -classpath ",
":".join(transitive_jar_paths), ":".join(transitive_jar_paths),
"-d %s" % dir]), "-d %s" % dir,
"find %s -exec touch -t 198001010000 '{}' ';'" % dir, ]),
"(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename), "find %s -exec touch -t 198001010000 '{}' ';'" % dir,
] "(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
ctx.actions.run_shell( ]
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk, ctx.actions.run_shell(
outputs = [zip_output], inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,
command = " && ".join(cmd)) outputs = [zip_output],
command = " && ".join(cmd),
)
java_doc = rule( java_doc = rule(
attrs = { attrs = {

View File

@ -2,37 +2,37 @@ NPMJS = "NPMJS"
GERRIT = "GERRIT:" GERRIT = "GERRIT:"
load("//lib/js:npm.bzl", "NPM_VERSIONS", "NPM_SHA1S") load("//lib/js:npm.bzl", "NPM_SHA1S", "NPM_VERSIONS")
def _npm_tarball(name): def _npm_tarball(name):
return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name]) return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name])
def _npm_binary_impl(ctx): def _npm_binary_impl(ctx):
"""rule to download a NPM archive.""" """rule to download a NPM archive."""
name = ctx.name name = ctx.name
version= NPM_VERSIONS[name] version = NPM_VERSIONS[name]
sha1 = NPM_SHA1S[name] sha1 = NPM_SHA1S[name]
dir = '%s-%s' % (name, version) dir = "%s-%s" % (name, version)
filename = '%s.tgz' % dir filename = "%s.tgz" % dir
base = '%s@%s.npm_binary.tgz' % (name, version) base = "%s@%s.npm_binary.tgz" % (name, version)
dest = ctx.path(base) dest = ctx.path(base)
repository = ctx.attr.repository repository = ctx.attr.repository
if repository == GERRIT: if repository == GERRIT:
url = 'http://gerrit-maven.storage.googleapis.com/npm-packages/%s' % filename url = "http://gerrit-maven.storage.googleapis.com/npm-packages/%s" % filename
elif repository == NPMJS: elif repository == NPMJS:
url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename) url = "http://registry.npmjs.org/%s/-/%s" % (name, filename)
else: else:
fail('repository %s not in {%s,%s}' % (repository, GERRIT, NPMJS)) fail("repository %s not in {%s,%s}" % (repository, GERRIT, NPMJS))
python = ctx.which("python") python = ctx.which("python")
script = ctx.path(ctx.attr._download_script) script = ctx.path(ctx.attr._download_script)
args = [python, script, "-o", dest, "-u", url, "-v", sha1] args = [python, script, "-o", dest, "-u", url, "-v", sha1]
out = ctx.execute(args) out = ctx.execute(args)
if out.return_code: if out.return_code:
fail("failed %s: %s" % (args, out.stderr)) fail("failed %s: %s" % (args, out.stderr))
ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False) ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False)
npm_binary = repository_rule( npm_binary = repository_rule(
attrs = { attrs = {
@ -46,64 +46,75 @@ npm_binary = repository_rule(
# for use in repo rules. # for use in repo rules.
def _run_npm_binary_str(ctx, tarball, args): def _run_npm_binary_str(ctx, tarball, args):
python_bin = ctx.which("python") python_bin = ctx.which("python")
return " ".join([ return " ".join([
python_bin, python_bin,
ctx.path(ctx.attr._run_npm), ctx.path(ctx.attr._run_npm),
ctx.path(tarball)] + args) ctx.path(tarball),
] + args)
def _bower_archive(ctx): def _bower_archive(ctx):
"""Download a bower package.""" """Download a bower package."""
download_name = '%s__download_bower.zip' % ctx.name download_name = "%s__download_bower.zip" % ctx.name
renamed_name = '%s__renamed.zip' % ctx.name renamed_name = "%s__renamed.zip" % ctx.name
version_name = '%s__version.json' % ctx.name version_name = "%s__version.json" % ctx.name
cmd = [ cmd = [
ctx.which("python"), ctx.which("python"),
ctx.path(ctx.attr._download_bower), ctx.path(ctx.attr._download_bower),
'-b', '%s' % _run_npm_binary_str(ctx, ctx.attr._bower_archive, []), "-b",
'-n', ctx.name, "%s" % _run_npm_binary_str(ctx, ctx.attr._bower_archive, []),
'-p', ctx.attr.package, "-n",
'-v', ctx.attr.version, ctx.name,
'-s', ctx.attr.sha1, "-p",
'-o', download_name, ctx.attr.package,
"-v",
ctx.attr.version,
"-s",
ctx.attr.sha1,
"-o",
download_name,
] ]
out = ctx.execute(cmd) out = ctx.execute(cmd)
if out.return_code: if out.return_code:
fail("failed %s: %s" % (" ".join(cmd), out.stderr)) fail("failed %s: %s" % (" ".join(cmd), out.stderr))
_bash(ctx, " && " .join([ _bash(ctx, " && ".join([
"TMP=$(mktemp -d || mktemp -d -t bazel-tmp)", "TMP=$(mktemp -d || mktemp -d -t bazel-tmp)",
"TZ=UTC", "TZ=UTC",
"export UTC", "export UTC",
"cd $TMP", "cd $TMP",
"mkdir bower_components", "mkdir bower_components",
"cd bower_components", "cd bower_components",
"unzip %s" % ctx.path(download_name), "unzip %s" % ctx.path(download_name),
"cd ..", "cd ..",
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -Xr %s bower_components" % renamed_name, "zip -Xr %s bower_components" % renamed_name,
"cd ..", "cd ..",
"rm -rf ${TMP}", "rm -rf ${TMP}",
])) ]))
dep_version = ctx.attr.semver if ctx.attr.semver else ctx.attr.version dep_version = ctx.attr.semver if ctx.attr.semver else ctx.attr.version
ctx.file(version_name, ctx.file(
'"%s":"%s#%s"' % (ctx.name, ctx.attr.package, dep_version)) version_name,
ctx.file( '"%s":"%s#%s"' % (ctx.name, ctx.attr.package, dep_version),
"BUILD", )
"\n".join([ ctx.file(
"package(default_visibility=['//visibility:public'])", "BUILD",
"filegroup(name = 'zipfile', srcs = ['%s'], )" % download_name, "\n".join([
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name, "package(default_visibility=['//visibility:public'])",
]), False) "filegroup(name = 'zipfile', srcs = ['%s'], )" % download_name,
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name,
]),
False,
)
def _bash(ctx, cmd): def _bash(ctx, cmd):
cmd_list = ["bash", "-c", cmd] cmd_list = ["bash", "-c", cmd]
out = ctx.execute(cmd_list) out = ctx.execute(cmd_list)
if out.return_code: if out.return_code:
fail("failed %s: %s" % (" ".join(cmd_list), out.stderr)) fail("failed %s: %s" % (" ".join(cmd_list), out.stderr))
bower_archive = repository_rule( bower_archive = repository_rule(
_bower_archive, _bower_archive,
@ -119,26 +130,26 @@ bower_archive = repository_rule(
) )
def _bower_component_impl(ctx): def _bower_component_impl(ctx):
transitive_zipfiles = depset([ctx.file.zipfile]) transitive_zipfiles = depset([ctx.file.zipfile])
for d in ctx.attr.deps: for d in ctx.attr.deps:
transitive_zipfiles += d.transitive_zipfiles transitive_zipfiles += d.transitive_zipfiles
transitive_licenses = depset() transitive_licenses = depset()
if ctx.file.license: if ctx.file.license:
transitive_licenses += depset([ctx.file.license]) transitive_licenses += depset([ctx.file.license])
for d in ctx.attr.deps: for d in ctx.attr.deps:
transitive_licenses += d.transitive_licenses transitive_licenses += d.transitive_licenses
transitive_versions = depset(ctx.files.version_json) transitive_versions = depset(ctx.files.version_json)
for d in ctx.attr.deps: for d in ctx.attr.deps:
transitive_versions += d.transitive_versions transitive_versions += d.transitive_versions
return struct( return struct(
transitive_zipfiles=transitive_zipfiles, transitive_zipfiles = transitive_zipfiles,
transitive_versions=transitive_versions, transitive_versions = transitive_versions,
transitive_licenses=transitive_licenses, transitive_licenses = transitive_licenses,
) )
_common_attrs = { _common_attrs = {
"deps": attr.label_list(providers = [ "deps": attr.label_list(providers = [
@ -149,35 +160,37 @@ _common_attrs = {
} }
def _js_component(ctx): def _js_component(ctx):
dir = ctx.outputs.zip.path + ".dir" dir = ctx.outputs.zip.path + ".dir"
name = ctx.outputs.zip.basename name = ctx.outputs.zip.basename
if name.endswith(".zip"): if name.endswith(".zip"):
name = name[:-4] name = name[:-4]
dest = "%s/%s" % (dir, name) dest = "%s/%s" % (dir, name)
cmd = " && ".join([ cmd = " && ".join([
"TZ=UTC", "TZ=UTC",
"export TZ", "export TZ",
"mkdir -p %s" % dest, "mkdir -p %s" % dest,
"cp %s %s/" % (' '.join([s.path for s in ctx.files.srcs]), dest), "cp %s %s/" % (" ".join([s.path for s in ctx.files.srcs]), dest),
"cd %s" % dir, "cd %s" % dir,
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -Xqr ../%s *" % ctx.outputs.zip.basename "zip -Xqr ../%s *" % ctx.outputs.zip.basename,
]) ])
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = ctx.files.srcs, inputs = ctx.files.srcs,
outputs = [ctx.outputs.zip], outputs = [ctx.outputs.zip],
command = cmd, command = cmd,
mnemonic = "GenBowerZip") mnemonic = "GenBowerZip",
)
licenses = depset() licenses = depset()
if ctx.file.license: if ctx.file.license:
licenses += depset([ctx.file.license]) licenses += depset([ctx.file.license])
return struct( return struct(
transitive_zipfiles=list([ctx.outputs.zip]), transitive_zipfiles = list([ctx.outputs.zip]),
transitive_versions=depset(), transitive_versions = depset(),
transitive_licenses=licenses) transitive_licenses = licenses,
)
js_component = rule( js_component = rule(
_js_component, _js_component,
@ -203,61 +216,65 @@ _bower_component = rule(
) )
# TODO(hanwen): make license mandatory. # TODO(hanwen): make license mandatory.
def bower_component(name, license=None, **kwargs): def bower_component(name, license = None, **kwargs):
prefix = "//lib:LICENSE-" prefix = "//lib:LICENSE-"
if license and not license.startswith(prefix): if license and not license.startswith(prefix):
license = prefix + license license = prefix + license
_bower_component( _bower_component(
name=name, name = name,
license=license, license = license,
zipfile="@%s//:zipfile"% name, zipfile = "@%s//:zipfile" % name,
version_json="@%s//:version_json" % name, version_json = "@%s//:version_json" % name,
**kwargs) **kwargs
)
def _bower_component_bundle_impl(ctx): def _bower_component_bundle_impl(ctx):
"""A bunch of bower components zipped up.""" """A bunch of bower components zipped up."""
zips = depset() zips = depset()
for d in ctx.attr.deps: for d in ctx.attr.deps:
zips += d.transitive_zipfiles zips += d.transitive_zipfiles
versions = depset() versions = depset()
for d in ctx.attr.deps: for d in ctx.attr.deps:
versions += d.transitive_versions versions += d.transitive_versions
licenses = depset() licenses = depset()
for d in ctx.attr.deps: for d in ctx.attr.deps:
licenses += d.transitive_versions licenses += d.transitive_versions
out_zip = ctx.outputs.zip out_zip = ctx.outputs.zip
out_versions = ctx.outputs.version_json out_versions = ctx.outputs.version_json
ctx.actions.run_shell( ctx.actions.run_shell(
inputs=list(zips), inputs = list(zips),
outputs=[out_zip], outputs = [out_zip],
command=" && ".join([ command = " && ".join([
"p=$PWD", "p=$PWD",
"TZ=UTC", "TZ=UTC",
"export TZ", "export TZ",
"rm -rf %s.dir" % out_zip.path, "rm -rf %s.dir" % out_zip.path,
"mkdir -p %s.dir/bower_components" % out_zip.path, "mkdir -p %s.dir/bower_components" % out_zip.path,
"cd %s.dir/bower_components" % out_zip.path, "cd %s.dir/bower_components" % out_zip.path,
"for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips])), "for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips])),
"cd ..", "cd ..",
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -Xqr $p/%s bower_components/*" % out_zip.path, "zip -Xqr $p/%s bower_components/*" % out_zip.path,
]), ]),
mnemonic="BowerCombine") mnemonic = "BowerCombine",
)
ctx.actions.run_shell( ctx.actions.run_shell(
inputs=list(versions), inputs = list(versions),
outputs=[out_versions], outputs = [out_versions],
mnemonic="BowerVersions", mnemonic = "BowerVersions",
command="(echo '{' ; for j in %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions]), out_versions.path)) command = "(echo '{' ; for j in %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions]), out_versions.path),
)
return struct( return struct(
transitive_zipfiles=zips, transitive_zipfiles = zips,
transitive_versions=versions, transitive_versions = versions,
transitive_licenses=licenses) transitive_licenses = licenses,
)
bower_component_bundle = rule( bower_component_bundle = rule(
_bower_component_bundle_impl, _bower_component_bundle_impl,
@ -278,69 +295,88 @@ Outputs:
""" """
def _vulcanize_impl(ctx): def _vulcanize_impl(ctx):
# intermediate artifact. # intermediate artifact.
vulcanized = ctx.new_file( vulcanized = ctx.new_file(
ctx.configuration.genfiles_dir, ctx.outputs.html, ".vulcanized.html") ctx.configuration.genfiles_dir,
destdir = ctx.outputs.html.path + ".dir" ctx.outputs.html,
zips = [z for d in ctx.attr.deps for z in d.transitive_zipfiles ] ".vulcanized.html",
)
destdir = ctx.outputs.html.path + ".dir"
zips = [z for d in ctx.attr.deps for z in d.transitive_zipfiles]
hermetic_npm_binary = " ".join([ hermetic_npm_binary = " ".join([
'python', "python",
"$p/" + ctx.file._run_npm.path, "$p/" + ctx.file._run_npm.path,
"$p/" + ctx.file._vulcanize_archive.path, "$p/" + ctx.file._vulcanize_archive.path,
'--inline-scripts', "--inline-scripts",
'--inline-css', "--inline-css",
'--strip-comments', "--strip-comments",
'--out-html', "$p/" + vulcanized.path, "--out-html",
ctx.file.app.path "$p/" + vulcanized.path,
]) ctx.file.app.path,
])
pkg_dir = ctx.attr.pkg.lstrip("/") pkg_dir = ctx.attr.pkg.lstrip("/")
cmd = " && ".join([ cmd = " && ".join([
# unpack dependencies. # unpack dependencies.
"export PATH", "export PATH",
"p=$PWD", "p=$PWD",
"rm -rf %s" % destdir, "rm -rf %s" % destdir,
"mkdir -p %s/%s/bower_components" % (destdir, pkg_dir), "mkdir -p %s/%s/bower_components" % (destdir, pkg_dir),
"for z in %s; do unzip -qd %s/%s/bower_components/ $z; done" % ( "for z in %s; do unzip -qd %s/%s/bower_components/ $z; done" % (
' '.join([z.path for z in zips]), destdir, pkg_dir), " ".join([z.path for z in zips]),
"tar -cf - %s | tar -C %s -xf -" % (" ".join([s.path for s in ctx.files.srcs]), destdir), destdir,
"cd %s" % destdir, pkg_dir,
hermetic_npm_binary, ),
]) "tar -cf - %s | tar -C %s -xf -" % (" ".join([s.path for s in ctx.files.srcs]), destdir),
"cd %s" % destdir,
hermetic_npm_binary,
])
# Node/NPM is not (yet) hermeticized, so we have to get the binary # Node/NPM is not (yet) hermeticized, so we have to get the binary
# from the environment, and it may be under $HOME, so we can't run # from the environment, and it may be under $HOME, so we can't run
# in the sandbox. # in the sandbox.
node_tweaks = dict( node_tweaks = dict(
use_default_shell_env = True, use_default_shell_env = True,
execution_requirements = {"local": "1"}, execution_requirements = {"local": "1"},
) )
ctx.actions.run_shell( ctx.actions.run_shell(
mnemonic = "Vulcanize", mnemonic = "Vulcanize",
inputs = [ctx.file._run_npm, ctx.file.app, inputs = [
ctx.file._vulcanize_archive ctx.file._run_npm,
] + list(zips) + ctx.files.srcs, ctx.file.app,
outputs = [vulcanized], ctx.file._vulcanize_archive,
command = cmd, ] + list(zips) + ctx.files.srcs,
**node_tweaks) outputs = [vulcanized],
command = cmd,
**node_tweaks
)
hermetic_npm_command = "export PATH && " + " ".join([ hermetic_npm_command = "export PATH && " + " ".join([
'python', "python",
ctx.file._run_npm.path, ctx.file._run_npm.path,
ctx.file._crisper_archive.path, ctx.file._crisper_archive.path,
"--always-write-script", "--always-write-script",
"--source", vulcanized.path, "--source",
"--html", ctx.outputs.html.path, vulcanized.path,
"--js", ctx.outputs.js.path]) "--html",
ctx.outputs.html.path,
"--js",
ctx.outputs.js.path,
])
ctx.actions.run_shell( ctx.actions.run_shell(
mnemonic = "Crisper", mnemonic = "Crisper",
inputs = [ctx.file._run_npm, ctx.file.app, inputs = [
ctx.file._crisper_archive, vulcanized], ctx.file._run_npm,
outputs = [ctx.outputs.js, ctx.outputs.html], ctx.file.app,
command = hermetic_npm_command, ctx.file._crisper_archive,
**node_tweaks) vulcanized,
],
outputs = [ctx.outputs.js, ctx.outputs.html],
command = hermetic_npm_command,
**node_tweaks
)
_vulcanize_rule = rule( _vulcanize_rule = rule(
_vulcanize_impl, _vulcanize_impl,
@ -378,5 +414,5 @@ _vulcanize_rule = rule(
) )
def vulcanize(*args, **kwargs): def vulcanize(*args, **kwargs):
"""Vulcanize runs vulcanize and crisper on a set of sources.""" """Vulcanize runs vulcanize and crisper on a set of sources."""
_vulcanize_rule(*args, pkg=PACKAGE_NAME, **kwargs) _vulcanize_rule(*args, pkg = PACKAGE_NAME, **kwargs)

View File

@ -43,15 +43,21 @@ def _AsClassName(fname):
if findex != -1: if findex != -1:
break break
if findex == -1: if findex == -1:
fail("%s does not contain any of %s", fail(
fname, _PREFIXES) "%s does not contain any of %s",
fname,
_PREFIXES,
)
return ".".join(toks[findex:]) + ".class" return ".".join(toks[findex:]) + ".class"
def _impl(ctx): def _impl(ctx):
classes = ",".join( classes = ",".join(
[_AsClassName(x) for x in ctx.attr.srcs]) [_AsClassName(x) for x in ctx.attr.srcs],
ctx.file_action(output=ctx.outputs.out, content=_OUTPUT % ( )
classes, ctx.attr.outname)) ctx.file_action(output = ctx.outputs.out, content = _OUTPUT % (
classes,
ctx.attr.outname,
))
_GenSuite = rule( _GenSuite = rule(
attrs = { attrs = {
@ -64,10 +70,14 @@ _GenSuite = rule(
def junit_tests(name, srcs, **kwargs): def junit_tests(name, srcs, **kwargs):
s_name = name + "TestSuite" s_name = name + "TestSuite"
_GenSuite(name = s_name, _GenSuite(
srcs = srcs, name = s_name,
outname = s_name) srcs = srcs,
native.java_test(name = name, outname = s_name,
test_class = s_name, )
srcs = srcs + [":"+s_name], native.java_test(
**kwargs) name = name,
test_class = s_name,
srcs = srcs + [":" + s_name],
**kwargs
)

View File

@ -1,57 +1,57 @@
def normalize_target_name(target): def normalize_target_name(target):
return target.replace("//", "").replace("/", "__").replace(":", "___") return target.replace("//", "").replace("/", "__").replace(":", "___")
def license_map(name, targets = [], opts = [], **kwargs): def license_map(name, targets = [], opts = [], **kwargs):
"""Generate XML for all targets that depend directly on a LICENSE file""" """Generate XML for all targets that depend directly on a LICENSE file"""
xmls = [] xmls = []
tools = [ "//tools/bzl:license-map.py", "//lib:all-licenses" ] tools = ["//tools/bzl:license-map.py", "//lib:all-licenses"]
for target in targets: for target in targets:
subname = name + "_" + normalize_target_name(target) + ".xml" subname = name + "_" + normalize_target_name(target) + ".xml"
xmls.append("$(location :%s)" % subname) xmls.append("$(location :%s)" % subname)
tools.append(subname) tools.append(subname)
native.genquery( native.genquery(
name = subname, name = subname,
scope = [ target ], scope = [target],
# Find everything that depends on a license file, but remove # Find everything that depends on a license file, but remove
# the license files themselves from this list. # the license files themselves from this list.
expression = 'rdeps(%s, filter("//lib:LICENSE.*", deps(%s)),1) - filter("//lib:LICENSE.*", deps(%s))' % (target, target, target), expression = 'rdeps(%s, filter("//lib:LICENSE.*", deps(%s)),1) - filter("//lib:LICENSE.*", deps(%s))' % (target, target, target),
# We are interested in the edges of the graph ({java_library, # We are interested in the edges of the graph ({java_library,
# license-file} tuples). 'query' provides this in the XML output. # license-file} tuples). 'query' provides this in the XML output.
opts = [ "--output=xml", ], opts = ["--output=xml"],
)
# post process the XML into our favorite format.
native.genrule(
name = "gen_license_txt_" + name,
cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
outs = [name + ".txt"],
tools = tools,
**kwargs
) )
# post process the XML into our favorite format.
native.genrule(
name = "gen_license_txt_" + name,
cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
outs = [ name + ".txt" ],
tools = tools,
**kwargs
)
def license_test(name, target): def license_test(name, target):
"""Make sure a target doesn't depend on DO_NOT_DISTRIBUTE license""" """Make sure a target doesn't depend on DO_NOT_DISTRIBUTE license"""
txt = name + "-forbidden.txt" txt = name + "-forbidden.txt"
# fully qualify target name. # fully qualify target name.
if target[0] not in ":/": if target[0] not in ":/":
target = ":" + target target = ":" + target
if target[0] != "/": if target[0] != "/":
target = "//" + PACKAGE_NAME + target target = "//" + PACKAGE_NAME + target
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE" forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
native.genquery( native.genquery(
name = txt, name = txt,
scope = [ target, forbidden ], scope = [target, forbidden],
# Find everything that depends on a license file, but remove # Find everything that depends on a license file, but remove
# the license files themselves from this list. # the license files themselves from this list.
expression = 'rdeps(%s, "%s", 1) - rdeps(%s, "%s", 0)' % (target, forbidden, target, forbidden), expression = 'rdeps(%s, "%s", 1) - rdeps(%s, "%s", 0)' % (target, forbidden, target, forbidden),
) )
native.sh_test( native.sh_test(
name = name, name = name,
srcs = [ "//tools/bzl:test_license.sh" ], srcs = ["//tools/bzl:test_license.sh"],
args = [ "$(location :%s)" % txt ], args = ["$(location :%s)" % txt],
data = [ txt ], data = [txt],
) )

View File

@ -15,18 +15,18 @@
# Merge maven files # Merge maven files
def cmd(jars): def cmd(jars):
return ('$(location //tools:merge_jars) $@ ' return ("$(location //tools:merge_jars) $@ " +
+ ' '.join(['$(location %s)' % j for j in jars])) " ".join(["$(location %s)" % j for j in jars]))
def merge_maven_jars(name, srcs, **kwargs): def merge_maven_jars(name, srcs, **kwargs):
native.genrule( native.genrule(
name = '%s__merged_bin' % name, name = "%s__merged_bin" % name,
cmd = cmd(srcs), cmd = cmd(srcs),
tools = srcs + ['//tools:merge_jars'], tools = srcs + ["//tools:merge_jars"],
outs = ['%s__merged.jar' % name], outs = ["%s__merged.jar" % name],
) )
native.java_import( native.java_import(
name = name, name = name,
jars = [':%s__merged_bin' % name], jars = [":%s__merged_bin" % name],
**kwargs **kwargs
) )

View File

@ -7,69 +7,70 @@ MAVEN_CENTRAL = "MAVEN_CENTRAL:"
MAVEN_LOCAL = "MAVEN_LOCAL:" MAVEN_LOCAL = "MAVEN_LOCAL:"
def _maven_release(ctx, parts): def _maven_release(ctx, parts):
"""induce jar and url name from maven coordinates.""" """induce jar and url name from maven coordinates."""
if len(parts) not in [3, 4]: if len(parts) not in [3, 4]:
fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' %
% ctx.attr.artifact) ctx.attr.artifact)
if len(parts) == 4: if len(parts) == 4:
group, artifact, version, classifier = parts group, artifact, version, classifier = parts
file_version = version + '-' + classifier file_version = version + "-" + classifier
else: else:
group, artifact, version = parts group, artifact, version = parts
file_version = version file_version = version
jar = artifact.lower() + '-' + file_version jar = artifact.lower() + "-" + file_version
url = '/'.join([ url = "/".join([
ctx.attr.repository, ctx.attr.repository,
group.replace('.', '/'), group.replace(".", "/"),
artifact, artifact,
version, version,
artifact + '-' + file_version]) artifact + "-" + file_version,
])
return jar, url return jar, url
# Creates a struct containing the different parts of an artifact's FQN # Creates a struct containing the different parts of an artifact's FQN
def _create_coordinates(fully_qualified_name): def _create_coordinates(fully_qualified_name):
parts = fully_qualified_name.split(":") parts = fully_qualified_name.split(":")
packaging = None packaging = None
classifier = None classifier = None
if len(parts) == 3: if len(parts) == 3:
group_id, artifact_id, version = parts group_id, artifact_id, version = parts
elif len(parts) == 4: elif len(parts) == 4:
group_id, artifact_id, version, packaging = parts group_id, artifact_id, version, packaging = parts
elif len(parts) == 5: elif len(parts) == 5:
group_id, artifact_id, version, packaging, classifier = parts group_id, artifact_id, version, packaging, classifier = parts
else: else:
fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name) fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name)
return struct( return struct(
fully_qualified_name = fully_qualified_name, fully_qualified_name = fully_qualified_name,
group_id = group_id, group_id = group_id,
artifact_id = artifact_id, artifact_id = artifact_id,
packaging = packaging, packaging = packaging,
classifier = classifier, classifier = classifier,
version = version, version = version,
) )
def _format_deps(attr, deps): def _format_deps(attr, deps):
formatted_deps = "" formatted_deps = ""
if deps: if deps:
if len(deps) == 1: if len(deps) == 1:
formatted_deps += "%s = [\'%s\']," % (attr, deps[0]) formatted_deps += "%s = [\'%s\']," % (attr, deps[0])
else: else:
formatted_deps += "%s = [\n" % attr formatted_deps += "%s = [\n" % attr
for dep in deps: for dep in deps:
formatted_deps += " \'%s\',\n" % dep formatted_deps += " \'%s\',\n" % dep
formatted_deps += " ]," formatted_deps += " ],"
return formatted_deps return formatted_deps
def _generate_build_files(ctx, binjar, srcjar): def _generate_build_files(ctx, binjar, srcjar):
header = "# DO NOT EDIT: automatically generated BUILD file for maven_jar rule %s" % ctx.name header = "# DO NOT EDIT: automatically generated BUILD file for maven_jar rule %s" % ctx.name
srcjar_attr = "" srcjar_attr = ""
if srcjar: if srcjar:
srcjar_attr = 'srcjar = "%s",' % srcjar srcjar_attr = 'srcjar = "%s",' % srcjar
contents = """ contents = """
{header} {header}
package(default_visibility = ['//visibility:public']) package(default_visibility = ['//visibility:public'])
java_import( java_import(
@ -86,22 +87,24 @@ java_import(
{deps} {deps}
{exports} {exports}
) )
\n""".format(srcjar_attr = srcjar_attr, \n""".format(
header = header, srcjar_attr = srcjar_attr,
binjar = binjar, header = header,
deps = _format_deps("deps", ctx.attr.deps), binjar = binjar,
exports = _format_deps("exports", ctx.attr.exports)) deps = _format_deps("deps", ctx.attr.deps),
if srcjar: exports = _format_deps("exports", ctx.attr.exports),
contents += """ )
if srcjar:
contents += """
java_import( java_import(
name = 'src', name = 'src',
jars = ['{srcjar}'], jars = ['{srcjar}'],
) )
""".format(srcjar = srcjar) """.format(srcjar = srcjar)
ctx.file('%s/BUILD' % ctx.path("jar"), contents, False) ctx.file("%s/BUILD" % ctx.path("jar"), contents, False)
# Compatibility layer for java_import_external from rules_closure # Compatibility layer for java_import_external from rules_closure
contents = """ contents = """
{header} {header}
package(default_visibility = ['//visibility:public']) package(default_visibility = ['//visibility:public'])
@ -110,52 +113,53 @@ alias(
actual = "@{rule_name}//jar", actual = "@{rule_name}//jar",
) )
\n""".format(rule_name = ctx.name, header = header) \n""".format(rule_name = ctx.name, header = header)
ctx.file("BUILD", contents, False) ctx.file("BUILD", contents, False)
def _maven_jar_impl(ctx): def _maven_jar_impl(ctx):
"""rule to download a Maven archive.""" """rule to download a Maven archive."""
coordinates = _create_coordinates(ctx.attr.artifact) coordinates = _create_coordinates(ctx.attr.artifact)
name = ctx.name name = ctx.name
sha1 = ctx.attr.sha1 sha1 = ctx.attr.sha1
parts = ctx.attr.artifact.split(':') parts = ctx.attr.artifact.split(":")
# TODO(davido): Only releases for now, implement handling snapshots
jar, url = _maven_release(ctx, parts)
binjar = jar + '.jar' # TODO(davido): Only releases for now, implement handling snapshots
binjar_path = ctx.path('/'.join(['jar', binjar])) jar, url = _maven_release(ctx, parts)
binurl = url + '.jar'
python = ctx.which("python") binjar = jar + ".jar"
script = ctx.path(ctx.attr._download_script) binjar_path = ctx.path("/".join(["jar", binjar]))
binurl = url + ".jar"
args = [python, script, "-o", binjar_path, "-u", binurl] python = ctx.which("python")
if ctx.attr.sha1: script = ctx.path(ctx.attr._download_script)
args.extend(["-v", sha1])
if ctx.attr.unsign:
args.append('--unsign')
for x in ctx.attr.exclude:
args.extend(['-x', x])
out = ctx.execute(args) args = [python, script, "-o", binjar_path, "-u", binurl]
if ctx.attr.sha1:
args.extend(["-v", sha1])
if ctx.attr.unsign:
args.append("--unsign")
for x in ctx.attr.exclude:
args.extend(["-x", x])
if out.return_code:
fail("failed %s: %s" % (' '.join(args), out.stderr))
srcjar = None
if ctx.attr.src_sha1 or ctx.attr.attach_source:
srcjar = jar + '-src.jar'
srcurl = url + '-sources.jar'
srcjar_path = ctx.path('jar/' + srcjar)
args = [python, script, "-o", srcjar_path, "-u", srcurl]
if ctx.attr.src_sha1:
args.extend(['-v', ctx.attr.src_sha1])
out = ctx.execute(args) out = ctx.execute(args)
if out.return_code:
fail("failed %s: %s" % (args, out.stderr))
_generate_build_files(ctx, binjar, srcjar) if out.return_code:
fail("failed %s: %s" % (" ".join(args), out.stderr))
srcjar = None
if ctx.attr.src_sha1 or ctx.attr.attach_source:
srcjar = jar + "-src.jar"
srcurl = url + "-sources.jar"
srcjar_path = ctx.path("jar/" + srcjar)
args = [python, script, "-o", srcjar_path, "-u", srcurl]
if ctx.attr.src_sha1:
args.extend(["-v", ctx.attr.src_sha1])
out = ctx.execute(args)
if out.return_code:
fail("failed %s: %s" % (args, out.stderr))
_generate_build_files(ctx, binjar, srcjar)
maven_jar = repository_rule( maven_jar = repository_rule(
attrs = { attrs = {

View File

@ -32,92 +32,92 @@ PGMLIBS = [
] ]
def _add_context(in_file, output): def _add_context(in_file, output):
input_path = in_file.path input_path = in_file.path
return [ return [
'unzip -qd %s %s' % (output, input_path) "unzip -qd %s %s" % (output, input_path),
] ]
def _add_file(in_file, output): def _add_file(in_file, output):
output_path = output output_path = output
input_path = in_file.path input_path = in_file.path
short_path = in_file.short_path short_path = in_file.short_path
n = in_file.basename n = in_file.basename
if short_path.startswith('gerrit-'): if short_path.startswith("gerrit-"):
n = short_path.split('/')[0] + '-' + n n = short_path.split("/")[0] + "-" + n
output_path += n output_path += n
return [ return [
'test -L %s || ln -s $(pwd)/%s %s' % (output_path, input_path, output_path) "test -L %s || ln -s $(pwd)/%s %s" % (output_path, input_path, output_path),
] ]
def _make_war(input_dir, output): def _make_war(input_dir, output):
return '(%s)' % ' && '.join([ return "(%s)" % " && ".join([
'root=$(pwd)', "root=$(pwd)",
'TZ=UTC', "TZ=UTC",
'export TZ', "export TZ",
'cd %s' % input_dir, "cd %s" % input_dir,
"find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null", "find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
'zip -X -9qr ${root}/%s .' % (output.path), "zip -X -9qr ${root}/%s ." % (output.path),
]) ])
def _war_impl(ctx): def _war_impl(ctx):
war = ctx.outputs.war war = ctx.outputs.war
build_output = war.path + '.build_output' build_output = war.path + ".build_output"
inputs = [] inputs = []
# Create war layout # Create war layout
cmd = [ cmd = [
'set -e;rm -rf ' + build_output, "set -e;rm -rf " + build_output,
'mkdir -p ' + build_output, "mkdir -p " + build_output,
'mkdir -p %s/WEB-INF/lib' % build_output, "mkdir -p %s/WEB-INF/lib" % build_output,
'mkdir -p %s/WEB-INF/pgm-lib' % build_output, "mkdir -p %s/WEB-INF/pgm-lib" % build_output,
] ]
# Add lib # Add lib
transitive_lib_deps = depset() transitive_lib_deps = depset()
for l in ctx.attr.libs: for l in ctx.attr.libs:
if hasattr(l, 'java'): if hasattr(l, "java"):
transitive_lib_deps += l.java.transitive_runtime_deps transitive_lib_deps += l.java.transitive_runtime_deps
elif hasattr(l, 'files'): elif hasattr(l, "files"):
transitive_lib_deps += l.files transitive_lib_deps += l.files
for dep in transitive_lib_deps: for dep in transitive_lib_deps:
cmd += _add_file(dep, build_output + '/WEB-INF/lib/') cmd += _add_file(dep, build_output + "/WEB-INF/lib/")
inputs.append(dep) inputs.append(dep)
# Add pgm lib # Add pgm lib
transitive_pgmlib_deps = depset() transitive_pgmlib_deps = depset()
for l in ctx.attr.pgmlibs: for l in ctx.attr.pgmlibs:
transitive_pgmlib_deps += l.java.transitive_runtime_deps transitive_pgmlib_deps += l.java.transitive_runtime_deps
for dep in transitive_pgmlib_deps: for dep in transitive_pgmlib_deps:
if dep not in inputs: if dep not in inputs:
cmd += _add_file(dep, build_output + '/WEB-INF/pgm-lib/') cmd += _add_file(dep, build_output + "/WEB-INF/pgm-lib/")
inputs.append(dep) inputs.append(dep)
# Add context # Add context
transitive_context_deps = depset() transitive_context_deps = depset()
if ctx.attr.context: if ctx.attr.context:
for jar in ctx.attr.context: for jar in ctx.attr.context:
if hasattr(jar, 'java'): if hasattr(jar, "java"):
transitive_context_deps += jar.java.transitive_runtime_deps transitive_context_deps += jar.java.transitive_runtime_deps
elif hasattr(jar, 'files'): elif hasattr(jar, "files"):
transitive_context_deps += jar.files transitive_context_deps += jar.files
for dep in transitive_context_deps: for dep in transitive_context_deps:
cmd += _add_context(dep, build_output) cmd += _add_context(dep, build_output)
inputs.append(dep) inputs.append(dep)
# Add zip war # Add zip war
cmd.append(_make_war(build_output, war)) cmd.append(_make_war(build_output, war))
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = inputs, inputs = inputs,
outputs = [war], outputs = [war],
mnemonic = 'WAR', mnemonic = "WAR",
command = '\n'.join(cmd), command = "\n".join(cmd),
use_default_shell_env = True, use_default_shell_env = True,
) )
# context: go to the root directory # context: go to the root directory
# libs: go to the WEB-INF/lib directory # libs: go to the WEB-INF/lib directory
@ -132,25 +132,25 @@ _pkg_war = rule(
implementation = _war_impl, implementation = _war_impl,
) )
def pkg_war(name, ui = 'ui_optdbg', context = [], doc = False, **kwargs): def pkg_war(name, ui = "ui_optdbg", context = [], doc = False, **kwargs):
doc_ctx = [] doc_ctx = []
doc_lib = [] doc_lib = []
ui_deps = [] ui_deps = []
if ui == 'polygerrit' or ui == 'ui_optdbg' or ui == 'ui_optdbg_r': if ui == "polygerrit" or ui == "ui_optdbg" or ui == "ui_optdbg_r":
ui_deps.append('//polygerrit-ui/app:polygerrit_ui') ui_deps.append("//polygerrit-ui/app:polygerrit_ui")
if ui and ui != 'polygerrit': if ui and ui != "polygerrit":
ui_deps.append('//gerrit-gwtui:%s' % ui) ui_deps.append("//gerrit-gwtui:%s" % ui)
if doc: if doc:
doc_ctx.append('//Documentation:html') doc_ctx.append("//Documentation:html")
doc_lib.append('//Documentation:index') doc_lib.append("//Documentation:index")
_pkg_war( _pkg_war(
name = name, name = name,
libs = LIBS + doc_lib, libs = LIBS + doc_lib,
pgmlibs = PGMLIBS, pgmlibs = PGMLIBS,
context = doc_ctx + context + ui_deps + [ context = doc_ctx + context + ui_deps + [
'//gerrit-main:main_bin_deploy.jar', "//gerrit-main:main_bin_deploy.jar",
'//gerrit-war:webapp_assets', "//gerrit-war:webapp_assets",
], ],
**kwargs **kwargs
) )

View File

@ -1,11 +1,11 @@
load("//tools/bzl:genrule2.bzl", "genrule2") load("//tools/bzl:genrule2.bzl", "genrule2")
load( load(
"//tools/bzl:gwt.bzl", "//tools/bzl:gwt.bzl",
"GWT_COMPILER_ARGS",
"GWT_JVM_ARGS",
"GWT_PLUGIN_DEPS", "GWT_PLUGIN_DEPS",
"GWT_PLUGIN_DEPS_NEVERLINK", "GWT_PLUGIN_DEPS_NEVERLINK",
"GWT_TRANSITIVE_DEPS", "GWT_TRANSITIVE_DEPS",
"GWT_COMPILER_ARGS",
"GWT_JVM_ARGS",
"gwt_binary", "gwt_binary",
) )
@ -20,82 +20,84 @@ PLUGIN_TEST_DEPS = [
] ]
def gerrit_plugin( def gerrit_plugin(
name, name,
deps = [], deps = [],
provided_deps = [], provided_deps = [],
srcs = [], srcs = [],
gwt_module = [], gwt_module = [],
resources = [], resources = [],
manifest_entries = [], manifest_entries = [],
dir_name = None, dir_name = None,
target_suffix = "", target_suffix = "",
**kwargs): **kwargs):
native.java_library(
name = name + '__plugin',
srcs = srcs,
resources = resources,
deps = provided_deps + deps + GWT_PLUGIN_DEPS_NEVERLINK + PLUGIN_DEPS_NEVERLINK,
visibility = ['//visibility:public'],
**kwargs
)
static_jars = []
if gwt_module:
static_jars = [':%s-static' % name]
if not dir_name:
dir_name = name
native.java_binary(
name = '%s__non_stamped' % name,
deploy_manifest_lines = manifest_entries + ["Gerrit-ApiType: plugin"],
main_class = 'Dummy',
runtime_deps = [
':%s__plugin' % name,
] + static_jars,
visibility = ['//visibility:public'],
**kwargs
)
if gwt_module:
native.java_library( native.java_library(
name = name + '__gwt_module', name = name + "__plugin",
resources = depset(srcs + resources).to_list(), srcs = srcs,
runtime_deps = deps + GWT_PLUGIN_DEPS, resources = resources,
visibility = ['//visibility:public'], deps = provided_deps + deps + GWT_PLUGIN_DEPS_NEVERLINK + PLUGIN_DEPS_NEVERLINK,
**kwargs visibility = ["//visibility:public"],
) **kwargs
genrule2(
name = '%s-static' % name,
cmd = ' && '.join([
'mkdir -p $$TMP/static',
'unzip -qd $$TMP/static $(location %s__gwt_application)' % name,
'cd $$TMP',
'zip -qr $$ROOT/$@ .']),
tools = [':%s__gwt_application' % name],
outs = ['%s-static.jar' % name],
)
gwt_binary(
name = name + '__gwt_application',
module = [gwt_module],
deps = GWT_PLUGIN_DEPS + GWT_TRANSITIVE_DEPS + ['//lib/gwt:dev'],
module_deps = [':%s__gwt_module' % name],
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
) )
# TODO(davido): Remove manual merge of manifest file when this feature static_jars = []
# request is implemented: https://github.com/bazelbuild/bazel/issues/2009 if gwt_module:
genrule2( static_jars = [":%s-static" % name]
name = name + target_suffix,
stamp = 1, if not dir_name:
srcs = ['%s__non_stamped_deploy.jar' % name], dir_name = name
cmd = " && ".join([
"GEN_VERSION=$$(cat bazel-out/stable-status.txt | grep -w STABLE_BUILD_%s_LABEL | cut -d ' ' -f 2)" % dir_name.upper(), native.java_binary(
"cd $$TMP", name = "%s__non_stamped" % name,
"unzip -q $$ROOT/$<", deploy_manifest_lines = manifest_entries + ["Gerrit-ApiType: plugin"],
"echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF", main_class = "Dummy",
"zip -qr $$ROOT/$@ ."]), runtime_deps = [
outs = ['%s%s.jar' % (name, target_suffix)], ":%s__plugin" % name,
visibility = ['//visibility:public'], ] + static_jars,
) visibility = ["//visibility:public"],
**kwargs
)
if gwt_module:
native.java_library(
name = name + "__gwt_module",
resources = depset(srcs + resources).to_list(),
runtime_deps = deps + GWT_PLUGIN_DEPS,
visibility = ["//visibility:public"],
**kwargs
)
genrule2(
name = "%s-static" % name,
cmd = " && ".join([
"mkdir -p $$TMP/static",
"unzip -qd $$TMP/static $(location %s__gwt_application)" % name,
"cd $$TMP",
"zip -qr $$ROOT/$@ .",
]),
tools = [":%s__gwt_application" % name],
outs = ["%s-static.jar" % name],
)
gwt_binary(
name = name + "__gwt_application",
module = [gwt_module],
deps = GWT_PLUGIN_DEPS + GWT_TRANSITIVE_DEPS + ["//lib/gwt:dev"],
module_deps = [":%s__gwt_module" % name],
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)
# TODO(davido): Remove manual merge of manifest file when this feature
# request is implemented: https://github.com/bazelbuild/bazel/issues/2009
genrule2(
name = name + target_suffix,
stamp = 1,
srcs = ["%s__non_stamped_deploy.jar" % name],
cmd = " && ".join([
"GEN_VERSION=$$(cat bazel-out/stable-status.txt | grep -w STABLE_BUILD_%s_LABEL | cut -d ' ' -f 2)" % dir_name.upper(),
"cd $$TMP",
"unzip -q $$ROOT/$<",
"echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
"zip -qr $$ROOT/$@ .",
]),
outs = ["%s%s.jar" % (name, target_suffix)],
visibility = ["//visibility:public"],
)

View File

@ -25,73 +25,86 @@ sh_bang_template = (" && ".join([
])) ]))
def maven_package( def maven_package(
version, version,
repository = None, repository = None,
url = None, url = None,
jar = {}, jar = {},
src = {}, src = {},
doc = {}, doc = {},
war = {}): war = {}):
build_cmd = ["bazel", "build"]
mvn_cmd = ["python", "tools/maven/mvn.py", "-v", version]
api_cmd = mvn_cmd[:]
api_targets = []
for type, d in [("jar", jar), ("java-source", src), ("javadoc", doc)]:
for a, t in sorted(d.items()):
api_cmd.append("-s %s:%s:$(location %s)" % (a, type, t))
api_targets.append(t)
build_cmd = ['bazel', 'build']
mvn_cmd = ['python', 'tools/maven/mvn.py', '-v', version]
api_cmd = mvn_cmd[:]
api_targets = []
for type,d in [('jar', jar), ('java-source', src), ('javadoc', doc)]:
for a,t in sorted(d.items()):
api_cmd.append('-s %s:%s:$(location %s)' % (a,type,t))
api_targets.append(t)
native.genrule(
name = 'gen_api_install',
cmd = sh_bang_template % (
' '.join(build_cmd + api_targets),
' '.join(api_cmd + ['-a', 'install'])),
srcs = api_targets,
outs = ['api_install.sh'],
executable = True,
testonly = 1,
)
if repository and url:
native.genrule( native.genrule(
name = 'gen_api_deploy', name = "gen_api_install",
cmd = sh_bang_template % ( cmd = sh_bang_template % (
' '.join(build_cmd + api_targets), " ".join(build_cmd + api_targets),
' '.join(api_cmd + ['-a', 'deploy', " ".join(api_cmd + ["-a", "install"]),
'--repository', repository, ),
'--url', url])), srcs = api_targets,
srcs = api_targets, outs = ["api_install.sh"],
outs = ['api_deploy.sh'], executable = True,
executable = True, testonly = 1,
testonly = 1,
) )
war_cmd = mvn_cmd[:] if repository and url:
war_targets = [] native.genrule(
for a,t in sorted(war.items()): name = "gen_api_deploy",
war_cmd.append('-s %s:war:$(location %s)' % (a,t)) cmd = sh_bang_template % (
war_targets.append(t) " ".join(build_cmd + api_targets),
" ".join(api_cmd + [
"-a",
"deploy",
"--repository",
repository,
"--url",
url,
]),
),
srcs = api_targets,
outs = ["api_deploy.sh"],
executable = True,
testonly = 1,
)
native.genrule( war_cmd = mvn_cmd[:]
name = 'gen_war_install', war_targets = []
cmd = sh_bang_template % (' '.join(build_cmd + war_targets), for a, t in sorted(war.items()):
' '.join(war_cmd + ['-a', 'install'])), war_cmd.append("-s %s:war:$(location %s)" % (a, t))
srcs = war_targets, war_targets.append(t)
outs = ['war_install.sh'],
executable = True,
)
if repository and url:
native.genrule( native.genrule(
name = 'gen_war_deploy', name = "gen_war_install",
cmd = sh_bang_template % ( cmd = sh_bang_template % (
' '.join(build_cmd + war_targets), " ".join(build_cmd + war_targets),
' '.join(war_cmd + [ " ".join(war_cmd + ["-a", "install"]),
'-a', 'deploy', ),
'--repository', repository, srcs = war_targets,
'--url', url])), outs = ["war_install.sh"],
srcs = war_targets, executable = True,
outs = ['war_deploy.sh'],
executable = True,
) )
if repository and url:
native.genrule(
name = "gen_war_deploy",
cmd = sh_bang_template % (
" ".join(build_cmd + war_targets),
" ".join(war_cmd + [
"-a",
"deploy",
"--repository",
repository,
"--url",
url,
]),
),
srcs = war_targets,
outs = ["war_deploy.sh"],
executable = True,
)