Apply buildifier to .bzl files.
Buildifier is now also used for formatting .bzl files. This change was created by running buildifier 0.12 over our source tree. Change-Id: I9f15112d4fe23e5cec0700cfe47f1ca649f61d2a
This commit is contained in:
parent
e1ce06434c
commit
b6a4048986
@ -1,21 +1,21 @@
|
||||
load("//tools/bzl:junit.bzl", "junit_tests")
|
||||
|
||||
def acceptance_tests(
|
||||
group,
|
||||
deps = [],
|
||||
labels = [],
|
||||
vm_args = ['-Xmx256m'],
|
||||
**kwargs):
|
||||
junit_tests(
|
||||
name = group,
|
||||
deps = deps + [
|
||||
'//gerrit-acceptance-tests:lib',
|
||||
],
|
||||
tags = labels + [
|
||||
'acceptance',
|
||||
'slow',
|
||||
],
|
||||
size = "large",
|
||||
jvm_flags = vm_args,
|
||||
**kwargs
|
||||
)
|
||||
group,
|
||||
deps = [],
|
||||
labels = [],
|
||||
vm_args = ["-Xmx256m"],
|
||||
**kwargs):
|
||||
junit_tests(
|
||||
name = group,
|
||||
deps = deps + [
|
||||
"//gerrit-acceptance-tests:lib",
|
||||
],
|
||||
tags = labels + [
|
||||
"acceptance",
|
||||
"slow",
|
||||
],
|
||||
size = "large",
|
||||
jvm_flags = vm_args,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -230,126 +230,142 @@ DIFF_MATCH_PATCH_TOP = ("META-INF/resources/webjars/google-diff-match-patch/%s"
|
||||
DIFF_MATCH_PATCH_VERSION)
|
||||
|
||||
def pkg_cm():
|
||||
for archive, suffix, top, license in [
|
||||
('@codemirror-original//jar', '', TOP, LICENSE),
|
||||
('@codemirror-minified//jar', '_r', TOP_MINIFIED, LICENSE_MINIFIED)
|
||||
]:
|
||||
# Main JavaScript and addons
|
||||
genrule2(
|
||||
name = 'cm' + suffix,
|
||||
cmd = ' && '.join([
|
||||
"echo '/** @license' >$@",
|
||||
'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)
|
||||
for n in CM_ADDONS]
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ['cm%s.js' % suffix],
|
||||
)
|
||||
for archive, suffix, top, license in [
|
||||
("@codemirror-original//jar", "", TOP, LICENSE),
|
||||
("@codemirror-minified//jar", "_r", TOP_MINIFIED, LICENSE_MINIFIED),
|
||||
]:
|
||||
# Main JavaScript and addons
|
||||
genrule2(
|
||||
name = "cm" + suffix,
|
||||
cmd = " && ".join(
|
||||
[
|
||||
"echo '/** @license' >$@",
|
||||
"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)
|
||||
for n in CM_ADDONS
|
||||
],
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ["cm%s.js" % suffix],
|
||||
)
|
||||
|
||||
# Main CSS
|
||||
genrule2(
|
||||
name = 'css' + suffix,
|
||||
cmd = ' && '.join([
|
||||
"echo '/** @license' >$@",
|
||||
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
] +
|
||||
['unzip -p $(location %s) %s/%s >>$@' % (archive, top, n)
|
||||
for n in CM_CSS]
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ['cm%s.css' % suffix],
|
||||
)
|
||||
# Main CSS
|
||||
genrule2(
|
||||
name = "css" + suffix,
|
||||
cmd = " && ".join(
|
||||
[
|
||||
"echo '/** @license' >$@",
|
||||
"unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
] +
|
||||
[
|
||||
"unzip -p $(location %s) %s/%s >>$@" % (archive, top, n)
|
||||
for n in CM_CSS
|
||||
],
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ["cm%s.css" % suffix],
|
||||
)
|
||||
|
||||
# Modes
|
||||
for n in CM_MODES:
|
||||
genrule2(
|
||||
name = 'mode_%s%s' % (n, suffix),
|
||||
cmd = ' && '.join([
|
||||
"echo '/** @license' >$@",
|
||||
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
'unzip -p $(location %s) %s/mode/%s/%s.js >>$@' % (archive, top, n, n),
|
||||
]
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ['mode_%s%s.js' % (n, suffix)],
|
||||
)
|
||||
# Modes
|
||||
for n in CM_MODES:
|
||||
genrule2(
|
||||
name = "mode_%s%s" % (n, suffix),
|
||||
cmd = " && ".join(
|
||||
[
|
||||
"echo '/** @license' >$@",
|
||||
"unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
"unzip -p $(location %s) %s/mode/%s/%s.js >>$@" % (archive, top, n, n),
|
||||
],
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ["mode_%s%s.js" % (n, suffix)],
|
||||
)
|
||||
|
||||
# Themes
|
||||
for n in CM_THEMES:
|
||||
genrule2(
|
||||
name = 'theme_%s%s' % (n, suffix),
|
||||
cmd = ' && '.join([
|
||||
"echo '/** @license' >$@",
|
||||
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
'unzip -p $(location %s) %s/theme/%s.css >>$@' % (archive, top, n)
|
||||
]
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ['theme_%s%s.css' % (n, suffix)],
|
||||
)
|
||||
# Themes
|
||||
for n in CM_THEMES:
|
||||
genrule2(
|
||||
name = "theme_%s%s" % (n, suffix),
|
||||
cmd = " && ".join(
|
||||
[
|
||||
"echo '/** @license' >$@",
|
||||
"unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
|
||||
"echo '*/' >>$@",
|
||||
"unzip -p $(location %s) %s/theme/%s.css >>$@" % (archive, top, n),
|
||||
],
|
||||
),
|
||||
tools = [archive],
|
||||
outs = ["theme_%s%s.css" % (n, suffix)],
|
||||
)
|
||||
|
||||
# Merge Addon bundled with diff-match-patch
|
||||
genrule2(
|
||||
name = 'addon_merge_with_diff_match_patch%s' % suffix,
|
||||
cmd = ' && '.join([
|
||||
"echo '/** @license' >$@",
|
||||
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
|
||||
"echo '*/\n' >>$@",
|
||||
"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' >>$@",
|
||||
"echo 'LICENSE-Apache2.0' >>$@",
|
||||
"echo '*/' >>$@",
|
||||
'unzip -p $(location @diff-match-patch//jar) %s/diff_match_patch.js >>$@' % DIFF_MATCH_PATCH_TOP,
|
||||
"echo ';' >> $@",
|
||||
'unzip -p $(location %s) %s/addon/merge/merge.js >>$@' % (archive, top)
|
||||
]
|
||||
),
|
||||
tools = [
|
||||
'@diff-match-patch//jar',
|
||||
# dependency just for license tracking.
|
||||
':diff-match-patch',
|
||||
archive,
|
||||
"//lib:LICENSE-Apache2.0",
|
||||
],
|
||||
outs = ['addon_merge_with_diff_match_patch%s.js' % suffix],
|
||||
)
|
||||
# Merge Addon bundled with diff-match-patch
|
||||
genrule2(
|
||||
name = "addon_merge_with_diff_match_patch%s" % suffix,
|
||||
cmd = " && ".join(
|
||||
[
|
||||
"echo '/** @license' >$@",
|
||||
"unzip -p $(location %s) %s/LICENSE >>$@" % (archive, top),
|
||||
"echo '*/\n' >>$@",
|
||||
"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' >>$@",
|
||||
"echo 'LICENSE-Apache2.0' >>$@",
|
||||
"echo '*/' >>$@",
|
||||
"unzip -p $(location @diff-match-patch//jar) %s/diff_match_patch.js >>$@" % DIFF_MATCH_PATCH_TOP,
|
||||
"echo ';' >> $@",
|
||||
"unzip -p $(location %s) %s/addon/merge/merge.js >>$@" % (archive, top),
|
||||
],
|
||||
),
|
||||
tools = [
|
||||
"@diff-match-patch//jar",
|
||||
# dependency just for license tracking.
|
||||
":diff-match-patch",
|
||||
archive,
|
||||
"//lib:LICENSE-Apache2.0",
|
||||
],
|
||||
outs = ["addon_merge_with_diff_match_patch%s.js" % suffix],
|
||||
)
|
||||
|
||||
# Jar packaging
|
||||
genrule2(
|
||||
name = 'jar' + suffix,
|
||||
cmd = ' && '.join([
|
||||
'cd $$TMP',
|
||||
'mkdir -p net/codemirror/{addon,lib,mode,theme}',
|
||||
'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 :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)
|
||||
for n in CM_THEMES]
|
||||
+ ['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 = [
|
||||
':addon_merge_with_diff_match_patch%s' % suffix,
|
||||
':cm%s' % suffix,
|
||||
':css%s' % 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],
|
||||
)
|
||||
# Jar packaging
|
||||
genrule2(
|
||||
name = "jar" + suffix,
|
||||
cmd = " && ".join([
|
||||
"cd $$TMP",
|
||||
"mkdir -p net/codemirror/{addon,lib,mode,theme}",
|
||||
"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 :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)
|
||||
for n in CM_THEMES
|
||||
] +
|
||||
["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 = [
|
||||
":addon_merge_with_diff_match_patch%s" % suffix,
|
||||
":cm%s" % suffix,
|
||||
":css%s" % 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(
|
||||
name = 'codemirror' + suffix,
|
||||
jars = [':jar%s' % suffix],
|
||||
visibility = ['//visibility:public'],
|
||||
data = [license],
|
||||
)
|
||||
native.java_import(
|
||||
name = "codemirror" + suffix,
|
||||
jars = [":jar%s" % suffix],
|
||||
visibility = ["//visibility:public"],
|
||||
data = [license],
|
||||
)
|
||||
|
@ -1,25 +1,25 @@
|
||||
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.7.1.201706071930-r"
|
||||
|
||||
_DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot
|
||||
_DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot
|
||||
|
||||
JGIT_DOC_URL = "http://download.eclipse.org/jgit/site/" + _DOC_VERS + "/apidocs"
|
||||
|
||||
_JGIT_REPO = MAVEN_CENTRAL # Leave here even if set to MAVEN_CENTRAL.
|
||||
_JGIT_REPO = MAVEN_CENTRAL # Leave here even if set to MAVEN_CENTRAL.
|
||||
|
||||
# set this to use a local version.
|
||||
# "/home/<user>/projects/jgit"
|
||||
LOCAL_JGIT_REPO = ""
|
||||
|
||||
def jgit_repos():
|
||||
if LOCAL_JGIT_REPO:
|
||||
native.local_repository(
|
||||
name = "jgit",
|
||||
path = LOCAL_JGIT_REPO,
|
||||
)
|
||||
else:
|
||||
jgit_maven_repos()
|
||||
if LOCAL_JGIT_REPO:
|
||||
native.local_repository(
|
||||
name = "jgit",
|
||||
path = LOCAL_JGIT_REPO,
|
||||
)
|
||||
else:
|
||||
jgit_maven_repos()
|
||||
|
||||
def jgit_maven_repos():
|
||||
maven_jar(
|
||||
@ -52,15 +52,15 @@ def jgit_maven_repos():
|
||||
)
|
||||
|
||||
def jgit_dep(name):
|
||||
mapping = {
|
||||
"@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
|
||||
"@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
|
||||
"@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
|
||||
"@jgit-servlet//jar":"@jgit//org.eclipse.jgit.http.server:jgit-servlet",
|
||||
"@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive",
|
||||
}
|
||||
mapping = {
|
||||
"@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
|
||||
"@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
|
||||
"@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
|
||||
"@jgit-servlet//jar": "@jgit//org.eclipse.jgit.http.server:jgit-servlet",
|
||||
"@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive",
|
||||
}
|
||||
|
||||
if LOCAL_JGIT_REPO:
|
||||
return mapping[name]
|
||||
else:
|
||||
return name
|
||||
if LOCAL_JGIT_REPO:
|
||||
return mapping[name]
|
||||
else:
|
||||
return name
|
||||
|
@ -7,103 +7,123 @@
|
||||
load("//tools/bzl:js.bzl", "bower_archive")
|
||||
|
||||
def load_bower_archives():
|
||||
bower_archive(
|
||||
name = "accessibility-developer-tools",
|
||||
package = "accessibility-developer-tools",
|
||||
version = "2.11.0",
|
||||
sha1 = "792cb24b649dafb316e7e536f8ae65d0d7b52bab")
|
||||
bower_archive(
|
||||
name = "async",
|
||||
package = "async",
|
||||
version = "1.5.2",
|
||||
sha1 = "1ec975d3b3834646a7e3d4b7e68118b90ed72508")
|
||||
bower_archive(
|
||||
name = "chai",
|
||||
package = "chai",
|
||||
version = "3.5.0",
|
||||
sha1 = "849ad3ee7c77506548b7b5db603a4e150b9431aa")
|
||||
bower_archive(
|
||||
name = "iron-a11y-announcer",
|
||||
package = "iron-a11y-announcer",
|
||||
version = "1.0.5",
|
||||
sha1 = "007902c041dd8863a1fe893f62450852f4d8c69b")
|
||||
bower_archive(
|
||||
name = "iron-a11y-keys-behavior",
|
||||
package = "iron-a11y-keys-behavior",
|
||||
version = "1.1.9",
|
||||
sha1 = "f58358ee652c67e6e721364ba50fb77a2ece1465")
|
||||
bower_archive(
|
||||
name = "iron-behaviors",
|
||||
package = "iron-behaviors",
|
||||
version = "1.0.17",
|
||||
sha1 = "47df7e1c2b97978dcafa13edb50fbdb702570acd")
|
||||
bower_archive(
|
||||
name = "iron-fit-behavior",
|
||||
package = "iron-fit-behavior",
|
||||
version = "1.2.5",
|
||||
sha1 = "5938815cd227843fc77ebeac480b999600a76157")
|
||||
bower_archive(
|
||||
name = "iron-flex-layout",
|
||||
package = "iron-flex-layout",
|
||||
version = "1.3.1",
|
||||
sha1 = "ba696394abff5e799fc06eb11bff4720129a1b52")
|
||||
bower_archive(
|
||||
name = "iron-form-element-behavior",
|
||||
package = "iron-form-element-behavior",
|
||||
version = "1.0.6",
|
||||
sha1 = "8d9e6530edc1b99bec1a5c34853911fba3701220")
|
||||
bower_archive(
|
||||
name = "iron-meta",
|
||||
package = "iron-meta",
|
||||
version = "1.1.2",
|
||||
sha1 = "dc22fe05e1cb5f94f30a7193d3433ca1808773b8")
|
||||
bower_archive(
|
||||
name = "iron-resizable-behavior",
|
||||
package = "iron-resizable-behavior",
|
||||
version = "1.0.5",
|
||||
sha1 = "2ebe983377dceb3794dd335131050656e23e2beb")
|
||||
bower_archive(
|
||||
name = "iron-validatable-behavior",
|
||||
package = "iron-validatable-behavior",
|
||||
version = "1.1.1",
|
||||
sha1 = "480423380be0536f948735d91bc472f6e7ced5b4")
|
||||
bower_archive(
|
||||
name = "lodash",
|
||||
package = "lodash",
|
||||
version = "3.10.1",
|
||||
sha1 = "2f207a8293c4c554bf6cf071241f7a00dc513d3a")
|
||||
bower_archive(
|
||||
name = "mocha",
|
||||
package = "mocha",
|
||||
version = "3.2.0",
|
||||
sha1 = "b77f23f7ad1f1363501bcae96f0f4f47745dad0f")
|
||||
bower_archive(
|
||||
name = "neon-animation",
|
||||
package = "neon-animation",
|
||||
version = "1.2.4",
|
||||
sha1 = "e8ccbb930c4b7ff470b1450baa901618888a7fd3")
|
||||
bower_archive(
|
||||
name = "sinon-chai",
|
||||
package = "sinon-chai",
|
||||
version = "2.8.0",
|
||||
sha1 = "0464b5d944fdf8116bb23e0b02ecfbac945b3517")
|
||||
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-js",
|
||||
version = "2.2.2",
|
||||
sha1 = "6276a9f227da7d4ccaf77c202b50e174dd11a2c2")
|
||||
bower_archive(
|
||||
name = "webcomponentsjs",
|
||||
package = "webcomponentsjs",
|
||||
version = "0.7.23",
|
||||
sha1 = "3d62269e614175573b0a0f3039aab05d40f0a763")
|
||||
bower_archive(
|
||||
name = "accessibility-developer-tools",
|
||||
package = "accessibility-developer-tools",
|
||||
version = "2.11.0",
|
||||
sha1 = "792cb24b649dafb316e7e536f8ae65d0d7b52bab",
|
||||
)
|
||||
bower_archive(
|
||||
name = "async",
|
||||
package = "async",
|
||||
version = "1.5.2",
|
||||
sha1 = "1ec975d3b3834646a7e3d4b7e68118b90ed72508",
|
||||
)
|
||||
bower_archive(
|
||||
name = "chai",
|
||||
package = "chai",
|
||||
version = "3.5.0",
|
||||
sha1 = "849ad3ee7c77506548b7b5db603a4e150b9431aa",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-a11y-announcer",
|
||||
package = "iron-a11y-announcer",
|
||||
version = "1.0.5",
|
||||
sha1 = "007902c041dd8863a1fe893f62450852f4d8c69b",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-a11y-keys-behavior",
|
||||
package = "iron-a11y-keys-behavior",
|
||||
version = "1.1.9",
|
||||
sha1 = "f58358ee652c67e6e721364ba50fb77a2ece1465",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-behaviors",
|
||||
package = "iron-behaviors",
|
||||
version = "1.0.17",
|
||||
sha1 = "47df7e1c2b97978dcafa13edb50fbdb702570acd",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-fit-behavior",
|
||||
package = "iron-fit-behavior",
|
||||
version = "1.2.5",
|
||||
sha1 = "5938815cd227843fc77ebeac480b999600a76157",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-flex-layout",
|
||||
package = "iron-flex-layout",
|
||||
version = "1.3.1",
|
||||
sha1 = "ba696394abff5e799fc06eb11bff4720129a1b52",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-form-element-behavior",
|
||||
package = "iron-form-element-behavior",
|
||||
version = "1.0.6",
|
||||
sha1 = "8d9e6530edc1b99bec1a5c34853911fba3701220",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-meta",
|
||||
package = "iron-meta",
|
||||
version = "1.1.2",
|
||||
sha1 = "dc22fe05e1cb5f94f30a7193d3433ca1808773b8",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-resizable-behavior",
|
||||
package = "iron-resizable-behavior",
|
||||
version = "1.0.5",
|
||||
sha1 = "2ebe983377dceb3794dd335131050656e23e2beb",
|
||||
)
|
||||
bower_archive(
|
||||
name = "iron-validatable-behavior",
|
||||
package = "iron-validatable-behavior",
|
||||
version = "1.1.1",
|
||||
sha1 = "480423380be0536f948735d91bc472f6e7ced5b4",
|
||||
)
|
||||
bower_archive(
|
||||
name = "lodash",
|
||||
package = "lodash",
|
||||
version = "3.10.1",
|
||||
sha1 = "2f207a8293c4c554bf6cf071241f7a00dc513d3a",
|
||||
)
|
||||
bower_archive(
|
||||
name = "mocha",
|
||||
package = "mocha",
|
||||
version = "3.2.0",
|
||||
sha1 = "b77f23f7ad1f1363501bcae96f0f4f47745dad0f",
|
||||
)
|
||||
bower_archive(
|
||||
name = "neon-animation",
|
||||
package = "neon-animation",
|
||||
version = "1.2.4",
|
||||
sha1 = "e8ccbb930c4b7ff470b1450baa901618888a7fd3",
|
||||
)
|
||||
bower_archive(
|
||||
name = "sinon-chai",
|
||||
package = "sinon-chai",
|
||||
version = "2.8.0",
|
||||
sha1 = "0464b5d944fdf8116bb23e0b02ecfbac945b3517",
|
||||
)
|
||||
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-js",
|
||||
version = "2.2.2",
|
||||
sha1 = "6276a9f227da7d4ccaf77c202b50e174dd11a2c2",
|
||||
)
|
||||
bower_archive(
|
||||
name = "webcomponentsjs",
|
||||
package = "webcomponentsjs",
|
||||
version = "0.7.23",
|
||||
sha1 = "3d62269e614175573b0a0f3039aab05d40f0a763",
|
||||
)
|
||||
|
@ -7,216 +7,216 @@
|
||||
load("//tools/bzl:js.bzl", "bower_component")
|
||||
|
||||
def define_bower_components():
|
||||
bower_component(
|
||||
name = "accessibility-developer-tools",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "async",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "chai",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "es6-promise",
|
||||
license = "//lib:LICENSE-es6-promise",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "fetch",
|
||||
license = "//lib:LICENSE-fetch",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-a11y-announcer",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-a11y-keys-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-autogrow-textarea",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-behaviors",
|
||||
":iron-flex-layout",
|
||||
":iron-form-element-behavior",
|
||||
":iron-validatable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-behaviors",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":polymer",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-dropdown",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":iron-behaviors",
|
||||
":iron-overlay-behavior",
|
||||
":iron-resizable-behavior",
|
||||
":neon-animation",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-fit-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-flex-layout",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-form-element-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-input",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-announcer",
|
||||
":iron-validatable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-meta",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-overlay-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":iron-fit-behavior",
|
||||
":iron-resizable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-resizable-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-selector",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":polymer" ],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-test-helpers",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
deps = [ ":polymer" ],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-validatable-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-meta",
|
||||
":polymer",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "lodash",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "mocha",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "moment",
|
||||
license = "//lib:LICENSE-moment",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "neon-animation",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-meta",
|
||||
":iron-resizable-behavior",
|
||||
":iron-selector",
|
||||
":polymer",
|
||||
":web-animations-js",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "page",
|
||||
license = "//lib:LICENSE-page.js",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "polymer",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [ ":webcomponentsjs" ],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "promise-polyfill",
|
||||
license = "//lib:LICENSE-promise-polyfill",
|
||||
deps = [ ":polymer" ],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "sinon-chai",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "sinonjs",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "stacky",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "test-fixture",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "web-animations-js",
|
||||
license = "//lib:LICENSE-Apache2.0",
|
||||
)
|
||||
bower_component(
|
||||
name = "web-component-tester",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
deps = [
|
||||
":accessibility-developer-tools",
|
||||
":async",
|
||||
":chai",
|
||||
":lodash",
|
||||
":mocha",
|
||||
":sinon-chai",
|
||||
":sinonjs",
|
||||
":stacky",
|
||||
":test-fixture",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "webcomponentsjs",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
)
|
||||
bower_component(
|
||||
name = "accessibility-developer-tools",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "async",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "chai",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "es6-promise",
|
||||
license = "//lib:LICENSE-es6-promise",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "fetch",
|
||||
license = "//lib:LICENSE-fetch",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-a11y-announcer",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-a11y-keys-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-autogrow-textarea",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-behaviors",
|
||||
":iron-flex-layout",
|
||||
":iron-form-element-behavior",
|
||||
":iron-validatable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-behaviors",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":polymer",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-dropdown",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":iron-behaviors",
|
||||
":iron-overlay-behavior",
|
||||
":iron-resizable-behavior",
|
||||
":neon-animation",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-fit-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-flex-layout",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-form-element-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-input",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-announcer",
|
||||
":iron-validatable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-meta",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-overlay-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-a11y-keys-behavior",
|
||||
":iron-fit-behavior",
|
||||
":iron-resizable-behavior",
|
||||
":polymer",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-resizable-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-selector",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":polymer"],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-test-helpers",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
deps = [":polymer"],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "iron-validatable-behavior",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-meta",
|
||||
":polymer",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "lodash",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "mocha",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "moment",
|
||||
license = "//lib:LICENSE-moment",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "neon-animation",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [
|
||||
":iron-meta",
|
||||
":iron-resizable-behavior",
|
||||
":iron-selector",
|
||||
":polymer",
|
||||
":web-animations-js",
|
||||
],
|
||||
)
|
||||
bower_component(
|
||||
name = "page",
|
||||
license = "//lib:LICENSE-page.js",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "polymer",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
deps = [":webcomponentsjs"],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "promise-polyfill",
|
||||
license = "//lib:LICENSE-promise-polyfill",
|
||||
deps = [":polymer"],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "sinon-chai",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "sinonjs",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "stacky",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
)
|
||||
bower_component(
|
||||
name = "test-fixture",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "web-animations-js",
|
||||
license = "//lib:LICENSE-Apache2.0",
|
||||
)
|
||||
bower_component(
|
||||
name = "web-component-tester",
|
||||
license = "//lib:LICENSE-DO_NOT_DISTRIBUTE",
|
||||
deps = [
|
||||
":accessibility-developer-tools",
|
||||
":async",
|
||||
":chai",
|
||||
":lodash",
|
||||
":mocha",
|
||||
":sinon-chai",
|
||||
":sinonjs",
|
||||
":stacky",
|
||||
":test-fixture",
|
||||
],
|
||||
seed = True,
|
||||
)
|
||||
bower_component(
|
||||
name = "webcomponentsjs",
|
||||
license = "//lib:LICENSE-polymer",
|
||||
)
|
||||
|
@ -15,22 +15,22 @@
|
||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||
|
||||
def prolog_cafe_library(
|
||||
name,
|
||||
srcs,
|
||||
deps = [],
|
||||
**kwargs):
|
||||
genrule2(
|
||||
name = name + '__pl2j',
|
||||
cmd = '$(location //lib/prolog:compiler-bin) ' +
|
||||
'$$(dirname $@) $@ ' +
|
||||
'$(SRCS)',
|
||||
srcs = srcs,
|
||||
tools = ['//lib/prolog:compiler-bin'],
|
||||
outs = [ name + '.srcjar' ],
|
||||
)
|
||||
native.java_library(
|
||||
name = name,
|
||||
srcs = [':' + name + '__pl2j'],
|
||||
deps = ['//lib/prolog:runtime-neverlink'] + deps,
|
||||
**kwargs
|
||||
)
|
||||
name,
|
||||
srcs,
|
||||
deps = [],
|
||||
**kwargs):
|
||||
genrule2(
|
||||
name = name + "__pl2j",
|
||||
cmd = "$(location //lib/prolog:compiler-bin) " +
|
||||
"$$(dirname $@) $@ " +
|
||||
"$(SRCS)",
|
||||
srcs = srcs,
|
||||
tools = ["//lib/prolog:compiler-bin"],
|
||||
outs = [name + ".srcjar"],
|
||||
)
|
||||
native.java_library(
|
||||
name = name,
|
||||
srcs = [":" + name + "__pl2j"],
|
||||
deps = ["//lib/prolog:runtime-neverlink"] + deps,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -1,2 +1,2 @@
|
||||
def external_plugin_deps():
|
||||
pass
|
||||
pass
|
||||
|
@ -1,55 +1,58 @@
|
||||
def documentation_attributes():
|
||||
return [
|
||||
"toc",
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
"last-update-label!",
|
||||
"source-highlighter=prettify",
|
||||
"stylesheet=DEFAULT",
|
||||
"linkcss=true",
|
||||
"prettifydir=.",
|
||||
# Just a placeholder, will be filled in asciidoctor java binary:
|
||||
"revnumber=%s",
|
||||
]
|
||||
return [
|
||||
"toc",
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
"last-update-label!",
|
||||
"source-highlighter=prettify",
|
||||
"stylesheet=DEFAULT",
|
||||
"linkcss=true",
|
||||
"prettifydir=.",
|
||||
# Just a placeholder, will be filled in asciidoctor java binary:
|
||||
"revnumber=%s",
|
||||
]
|
||||
|
||||
def release_notes_attributes():
|
||||
return [
|
||||
'toc',
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
'last-update-label!',
|
||||
'stylesheet=DEFAULT',
|
||||
'linkcss=true',
|
||||
]
|
||||
return [
|
||||
"toc",
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
"last-update-label!",
|
||||
"stylesheet=DEFAULT",
|
||||
"linkcss=true",
|
||||
]
|
||||
|
||||
def _replace_macros_impl(ctx):
|
||||
cmd = [
|
||||
ctx.file._exe.path,
|
||||
'--suffix', ctx.attr.suffix,
|
||||
"-s", ctx.file.src.path,
|
||||
"-o", ctx.outputs.out.path,
|
||||
]
|
||||
if ctx.attr.searchbox:
|
||||
cmd.append('--searchbox')
|
||||
else:
|
||||
cmd.append('--no-searchbox')
|
||||
ctx.action(
|
||||
inputs = [ctx.file._exe, ctx.file.src],
|
||||
outputs = [ctx.outputs.out],
|
||||
command = cmd,
|
||||
use_default_shell_env = True,
|
||||
progress_message = "Replacing macros in %s" % ctx.file.src.short_path,
|
||||
)
|
||||
cmd = [
|
||||
ctx.file._exe.path,
|
||||
"--suffix",
|
||||
ctx.attr.suffix,
|
||||
"-s",
|
||||
ctx.file.src.path,
|
||||
"-o",
|
||||
ctx.outputs.out.path,
|
||||
]
|
||||
if ctx.attr.searchbox:
|
||||
cmd.append("--searchbox")
|
||||
else:
|
||||
cmd.append("--no-searchbox")
|
||||
ctx.action(
|
||||
inputs = [ctx.file._exe, ctx.file.src],
|
||||
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(
|
||||
attrs = {
|
||||
@ -69,52 +72,55 @@ _replace_macros = rule(
|
||||
)
|
||||
|
||||
def _generate_asciidoc_args(ctx):
|
||||
args = []
|
||||
if ctx.attr.backend:
|
||||
args.extend(["-b", ctx.attr.backend])
|
||||
revnumber = False
|
||||
for attribute in ctx.attr.attributes:
|
||||
if attribute.startswith("revnumber="):
|
||||
revnumber = True
|
||||
else:
|
||||
args.extend(["-a", attribute])
|
||||
if revnumber:
|
||||
args.extend([
|
||||
"--revnumber-file", ctx.file.version.path,
|
||||
])
|
||||
for src in ctx.files.srcs:
|
||||
args.append(src.path)
|
||||
return args
|
||||
args = []
|
||||
if ctx.attr.backend:
|
||||
args.extend(["-b", ctx.attr.backend])
|
||||
revnumber = False
|
||||
for attribute in ctx.attr.attributes:
|
||||
if attribute.startswith("revnumber="):
|
||||
revnumber = True
|
||||
else:
|
||||
args.extend(["-a", attribute])
|
||||
if revnumber:
|
||||
args.extend([
|
||||
"--revnumber-file",
|
||||
ctx.file.version.path,
|
||||
])
|
||||
for src in ctx.files.srcs:
|
||||
args.append(src.path)
|
||||
return args
|
||||
|
||||
def _invoke_replace_macros(name, src, suffix, searchbox):
|
||||
fn = src
|
||||
if fn.startswith(":"):
|
||||
fn = src[1:]
|
||||
fn = src
|
||||
if fn.startswith(":"):
|
||||
fn = src[1:]
|
||||
|
||||
_replace_macros(
|
||||
name = "macros_%s_%s" % (name, fn),
|
||||
src = src,
|
||||
out = fn + suffix,
|
||||
suffix = suffix,
|
||||
searchbox = searchbox,
|
||||
)
|
||||
_replace_macros(
|
||||
name = "macros_%s_%s" % (name, fn),
|
||||
src = src,
|
||||
out = fn + suffix,
|
||||
suffix = suffix,
|
||||
searchbox = searchbox,
|
||||
)
|
||||
|
||||
return ":" + fn + suffix, fn.replace(".txt", ".html")
|
||||
return ":" + fn + suffix, fn.replace(".txt", ".html")
|
||||
|
||||
def _asciidoc_impl(ctx):
|
||||
args = [
|
||||
"--bazel",
|
||||
"--in-ext", ".txt" + ctx.attr.suffix,
|
||||
"--out-ext", ".html",
|
||||
]
|
||||
args.extend(_generate_asciidoc_args(ctx))
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
|
||||
outputs = ctx.outputs.outs,
|
||||
executable = ctx.executable._exe,
|
||||
arguments = args,
|
||||
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
|
||||
)
|
||||
args = [
|
||||
"--bazel",
|
||||
"--in-ext",
|
||||
".txt" + ctx.attr.suffix,
|
||||
"--out-ext",
|
||||
".html",
|
||||
]
|
||||
args.extend(_generate_asciidoc_args(ctx))
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
|
||||
outputs = ctx.outputs.outs,
|
||||
executable = ctx.executable._exe,
|
||||
arguments = args,
|
||||
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
|
||||
)
|
||||
|
||||
_asciidoc_attrs = {
|
||||
"_exe": attr.label(
|
||||
@ -144,81 +150,84 @@ _asciidoc = rule(
|
||||
)
|
||||
|
||||
def _genasciidoc_htmlonly(
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
**kwargs):
|
||||
SUFFIX = "." + name + "_macros"
|
||||
new_srcs = []
|
||||
outs = ["asciidoctor.css"]
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
**kwargs):
|
||||
SUFFIX = "." + name + "_macros"
|
||||
new_srcs = []
|
||||
outs = ["asciidoctor.css"]
|
||||
|
||||
for src in srcs:
|
||||
new_src, html_name = _invoke_replace_macros(name, src, SUFFIX, searchbox)
|
||||
new_srcs.append(new_src)
|
||||
outs.append(html_name)
|
||||
for src in srcs:
|
||||
new_src, html_name = _invoke_replace_macros(name, src, SUFFIX, searchbox)
|
||||
new_srcs.append(new_src)
|
||||
outs.append(html_name)
|
||||
|
||||
_asciidoc(
|
||||
name = name + "_gen",
|
||||
srcs = new_srcs,
|
||||
suffix = SUFFIX,
|
||||
backend = backend,
|
||||
attributes = attributes,
|
||||
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
|
||||
_asciidoc(
|
||||
name = name + "_gen",
|
||||
srcs = new_srcs,
|
||||
suffix = SUFFIX,
|
||||
backend = backend,
|
||||
attributes = attributes,
|
||||
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
|
||||
)
|
||||
|
||||
def _asciidoc_html_zip_impl(ctx):
|
||||
args = [
|
||||
"--mktmp",
|
||||
"-z", ctx.outputs.out.path,
|
||||
"--in-ext", ".txt" + ctx.attr.suffix,
|
||||
"--out-ext", ".html",
|
||||
]
|
||||
args.extend(_generate_asciidoc_args(ctx))
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
|
||||
outputs = [ctx.outputs.out],
|
||||
executable = ctx.executable._exe,
|
||||
arguments = args,
|
||||
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
|
||||
)
|
||||
args = [
|
||||
"--mktmp",
|
||||
"-z",
|
||||
ctx.outputs.out.path,
|
||||
"--in-ext",
|
||||
".txt" + ctx.attr.suffix,
|
||||
"--out-ext",
|
||||
".html",
|
||||
]
|
||||
args.extend(_generate_asciidoc_args(ctx))
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
|
||||
outputs = [ctx.outputs.out],
|
||||
executable = ctx.executable._exe,
|
||||
arguments = args,
|
||||
progress_message = "Rendering asciidoctor files for %s" % ctx.label.name,
|
||||
)
|
||||
|
||||
_asciidoc_html_zip = rule(
|
||||
attrs = _asciidoc_attrs,
|
||||
@ -229,53 +238,54 @@ _asciidoc_html_zip = rule(
|
||||
)
|
||||
|
||||
def _genasciidoc_htmlonly_zip(
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
**kwargs):
|
||||
SUFFIX = "." + name + "_expn"
|
||||
new_srcs = []
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
**kwargs):
|
||||
SUFFIX = "." + name + "_expn"
|
||||
new_srcs = []
|
||||
|
||||
for src in srcs:
|
||||
new_src, _ = _invoke_replace_macros(name, src, SUFFIX, searchbox)
|
||||
new_srcs.append(new_src)
|
||||
for src in srcs:
|
||||
new_src, _ = _invoke_replace_macros(name, src, SUFFIX, searchbox)
|
||||
new_srcs.append(new_src)
|
||||
|
||||
_asciidoc_html_zip(
|
||||
name = name,
|
||||
srcs = new_srcs,
|
||||
suffix = SUFFIX,
|
||||
backend = backend,
|
||||
attributes = attributes,
|
||||
)
|
||||
_asciidoc_html_zip(
|
||||
name = name,
|
||||
srcs = new_srcs,
|
||||
suffix = SUFFIX,
|
||||
backend = backend,
|
||||
attributes = attributes,
|
||||
)
|
||||
|
||||
def _asciidoc_zip_impl(ctx):
|
||||
tmpdir = ctx.outputs.out.path + "_tmpdir"
|
||||
cmd = [
|
||||
"p=$PWD",
|
||||
"rm -rf %s" % tmpdir,
|
||||
"mkdir -p %s/%s/" % (tmpdir, ctx.attr.directory),
|
||||
"unzip -q %s -d %s/%s/" % (ctx.file.src.path, tmpdir, ctx.attr.directory),
|
||||
]
|
||||
for r in ctx.files.resources:
|
||||
if r.path == r.short_path:
|
||||
cmd.append("tar -cf- %s | tar -C %s -xf-" % (r.short_path, tmpdir))
|
||||
else:
|
||||
parent = r.path[:-len(r.short_path)]
|
||||
cmd.append(
|
||||
"tar -C %s -cf- %s | tar -C %s -xf-" % (parent, r.short_path, tmpdir))
|
||||
cmd.extend([
|
||||
"cd %s" % tmpdir,
|
||||
"zip -qr $p/%s *" % ctx.outputs.out.path,
|
||||
])
|
||||
ctx.action(
|
||||
inputs = [ctx.file.src] + ctx.files.resources,
|
||||
outputs = [ctx.outputs.out],
|
||||
command = " && ".join(cmd),
|
||||
progress_message =
|
||||
"Generating asciidoctor zip file %s" % ctx.outputs.out.short_path,
|
||||
)
|
||||
tmpdir = ctx.outputs.out.path + "_tmpdir"
|
||||
cmd = [
|
||||
"p=$PWD",
|
||||
"rm -rf %s" % tmpdir,
|
||||
"mkdir -p %s/%s/" % (tmpdir, ctx.attr.directory),
|
||||
"unzip -q %s -d %s/%s/" % (ctx.file.src.path, tmpdir, ctx.attr.directory),
|
||||
]
|
||||
for r in ctx.files.resources:
|
||||
if r.path == r.short_path:
|
||||
cmd.append("tar -cf- %s | tar -C %s -xf-" % (r.short_path, tmpdir))
|
||||
else:
|
||||
parent = r.path[:-len(r.short_path)]
|
||||
cmd.append(
|
||||
"tar -C %s -cf- %s | tar -C %s -xf-" % (parent, r.short_path, tmpdir),
|
||||
)
|
||||
cmd.extend([
|
||||
"cd %s" % tmpdir,
|
||||
"zip -qr $p/%s *" % ctx.outputs.out.path,
|
||||
])
|
||||
ctx.action(
|
||||
inputs = [ctx.file.src] + ctx.files.resources,
|
||||
outputs = [ctx.outputs.out],
|
||||
command = " && ".join(cmd),
|
||||
progress_message =
|
||||
"Generating asciidoctor zip file %s" % ctx.outputs.out.short_path,
|
||||
)
|
||||
|
||||
_asciidoc_zip = rule(
|
||||
attrs = {
|
||||
@ -296,30 +306,30 @@ _asciidoc_zip = rule(
|
||||
)
|
||||
|
||||
def genasciidoc_zip(
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
directory = None,
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
resources = True,
|
||||
**kwargs):
|
||||
SUFFIX = "_htmlonly"
|
||||
name,
|
||||
srcs = [],
|
||||
attributes = [],
|
||||
directory = None,
|
||||
backend = None,
|
||||
searchbox = True,
|
||||
resources = True,
|
||||
**kwargs):
|
||||
SUFFIX = "_htmlonly"
|
||||
|
||||
_genasciidoc_htmlonly_zip(
|
||||
name = name + SUFFIX if resources else name,
|
||||
srcs = srcs,
|
||||
attributes = attributes,
|
||||
backend = backend,
|
||||
searchbox = searchbox,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
if resources:
|
||||
htmlonly = ":" + name + SUFFIX
|
||||
_asciidoc_zip(
|
||||
name = name,
|
||||
src = htmlonly,
|
||||
resources = ["//Documentation:resources"],
|
||||
directory = directory,
|
||||
_genasciidoc_htmlonly_zip(
|
||||
name = name + SUFFIX if resources else name,
|
||||
srcs = srcs,
|
||||
attributes = attributes,
|
||||
backend = backend,
|
||||
searchbox = searchbox,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
if resources:
|
||||
htmlonly = ":" + name + SUFFIX
|
||||
_asciidoc_zip(
|
||||
name = name,
|
||||
src = htmlonly,
|
||||
resources = ["//Documentation:resources"],
|
||||
directory = directory,
|
||||
)
|
||||
|
@ -1,15 +1,17 @@
|
||||
def _classpath_collector(ctx):
|
||||
all = depset()
|
||||
for d in ctx.attr.deps:
|
||||
if hasattr(d, 'java'):
|
||||
if hasattr(d, "java"):
|
||||
all += d.java.transitive_runtime_deps
|
||||
all += d.java.compilation_info.runtime_classpath
|
||||
elif hasattr(d, 'files'):
|
||||
elif hasattr(d, "files"):
|
||||
all += d.files
|
||||
|
||||
as_strs = [c.path for c in all]
|
||||
ctx.file_action(output= ctx.outputs.runtime,
|
||||
content="\n".join(sorted(as_strs)))
|
||||
ctx.file_action(
|
||||
output = ctx.outputs.runtime,
|
||||
content = "\n".join(sorted(as_strs)),
|
||||
)
|
||||
|
||||
classpath_collector = rule(
|
||||
attrs = {
|
||||
|
@ -17,11 +17,12 @@
|
||||
# expose TMP shell variable
|
||||
|
||||
def genrule2(cmd, **kwargs):
|
||||
cmd = ' && '.join([
|
||||
'ROOT=$$PWD',
|
||||
'TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)',
|
||||
'(' + cmd + ')',
|
||||
])
|
||||
native.genrule(
|
||||
cmd = cmd,
|
||||
**kwargs)
|
||||
cmd = " && ".join([
|
||||
"ROOT=$$PWD",
|
||||
"TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)",
|
||||
"(" + cmd + ")",
|
||||
])
|
||||
native.genrule(
|
||||
cmd = cmd,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -96,115 +96,120 @@ USER_AGENT_XML = """<module rename-to='gerrit_ui'>
|
||||
</module>
|
||||
"""
|
||||
|
||||
def gwt_module(gwt_xml=None, resources=[], srcs=[], **kwargs):
|
||||
if gwt_xml:
|
||||
resources = resources + [gwt_xml]
|
||||
def gwt_module(gwt_xml = None, resources = [], srcs = [], **kwargs):
|
||||
if gwt_xml:
|
||||
resources = resources + [gwt_xml]
|
||||
|
||||
java_library2(
|
||||
srcs = srcs,
|
||||
resources = resources,
|
||||
**kwargs)
|
||||
java_library2(
|
||||
srcs = srcs,
|
||||
resources = resources,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def _gwt_user_agent_module(ctx):
|
||||
"""Generate user agent specific GWT module."""
|
||||
if not ctx.attr.user_agent:
|
||||
return None
|
||||
"""Generate user agent specific GWT module."""
|
||||
if not ctx.attr.user_agent:
|
||||
return None
|
||||
|
||||
ua = ctx.attr.user_agent
|
||||
impl = ua
|
||||
if ua in ALIASES:
|
||||
impl = ALIASES[ua]
|
||||
ua = ctx.attr.user_agent
|
||||
impl = ua
|
||||
if ua in ALIASES:
|
||||
impl = ALIASES[ua]
|
||||
|
||||
# intermediate artifact: user agent speific GWT xml file
|
||||
gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
|
||||
ctx.file_action(output = gwt_user_agent_xml,
|
||||
content=USER_AGENT_XML % (MODULE, impl))
|
||||
# intermediate artifact: user agent speific GWT xml file
|
||||
gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
|
||||
ctx.file_action(
|
||||
output = gwt_user_agent_xml,
|
||||
content = USER_AGENT_XML % (MODULE, impl),
|
||||
)
|
||||
|
||||
# intermediate artifact: user agent specific zip with GWT module
|
||||
gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
|
||||
gwt = '%s_%s.gwt.xml' % (MODULE.replace('.', '/'), ua)
|
||||
dir = gwt_user_agent_zip.path + ".dir"
|
||||
cmd = " && ".join([
|
||||
"p=$PWD",
|
||||
"mkdir -p %s" % dir,
|
||||
"cd %s" % dir,
|
||||
"mkdir -p $(dirname %s)" % 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)
|
||||
])
|
||||
ctx.action(
|
||||
inputs = [gwt_user_agent_xml] + ctx.files._zip,
|
||||
outputs = [gwt_user_agent_zip],
|
||||
command = cmd,
|
||||
mnemonic = "GenerateUserAgentGWTModule")
|
||||
# intermediate artifact: user agent specific zip with GWT module
|
||||
gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
|
||||
gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua)
|
||||
dir = gwt_user_agent_zip.path + ".dir"
|
||||
cmd = " && ".join([
|
||||
"p=$PWD",
|
||||
"mkdir -p %s" % dir,
|
||||
"cd %s" % dir,
|
||||
"mkdir -p $(dirname %s)" % 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),
|
||||
])
|
||||
ctx.action(
|
||||
inputs = [gwt_user_agent_xml] + ctx.files._zip,
|
||||
outputs = [gwt_user_agent_zip],
|
||||
command = cmd,
|
||||
mnemonic = "GenerateUserAgentGWTModule",
|
||||
)
|
||||
|
||||
return struct(
|
||||
zip=gwt_user_agent_zip,
|
||||
module=MODULE + '_' + ua
|
||||
)
|
||||
return struct(
|
||||
zip = gwt_user_agent_zip,
|
||||
module = MODULE + "_" + ua,
|
||||
)
|
||||
|
||||
def _gwt_binary_impl(ctx):
|
||||
module = ctx.attr.module[0]
|
||||
output_zip = ctx.outputs.output
|
||||
output_dir = output_zip.path + '.gwt_output'
|
||||
deploy_dir = output_zip.path + '.gwt_deploy'
|
||||
module = ctx.attr.module[0]
|
||||
output_zip = ctx.outputs.output
|
||||
output_dir = output_zip.path + ".gwt_output"
|
||||
deploy_dir = output_zip.path + ".gwt_deploy"
|
||||
|
||||
deps = _get_transitive_closure(ctx)
|
||||
deps = _get_transitive_closure(ctx)
|
||||
|
||||
paths = []
|
||||
for dep in deps:
|
||||
paths.append(dep.path)
|
||||
paths = []
|
||||
for dep in deps:
|
||||
paths.append(dep.path)
|
||||
|
||||
gwt_user_agent_modules = []
|
||||
ua = _gwt_user_agent_module(ctx)
|
||||
if ua:
|
||||
paths.append(ua.zip.path)
|
||||
gwt_user_agent_modules.append(ua.zip)
|
||||
module = ua.module
|
||||
gwt_user_agent_modules = []
|
||||
ua = _gwt_user_agent_module(ctx)
|
||||
if ua:
|
||||
paths.append(ua.zip.path)
|
||||
gwt_user_agent_modules.append(ua.zip)
|
||||
module = ua.module
|
||||
|
||||
cmd = "external/local_jdk/bin/java %s -Dgwt.normalizeTimestamps=true -cp %s %s -war %s -deploy %s " % (
|
||||
" ".join(ctx.attr.jvm_args),
|
||||
":".join(paths),
|
||||
GWT_COMPILER,
|
||||
output_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,
|
||||
cmd = "external/local_jdk/bin/java %s -Dgwt.normalizeTimestamps=true -cp %s %s -war %s -deploy %s " % (
|
||||
" ".join(ctx.attr.jvm_args),
|
||||
":".join(paths),
|
||||
GWT_COMPILER,
|
||||
output_dir,
|
||||
deploy_dir,
|
||||
)
|
||||
])
|
||||
|
||||
ctx.action(
|
||||
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,
|
||||
)
|
||||
# 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.action(
|
||||
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):
|
||||
deps = depset()
|
||||
for dep in ctx.attr.module_deps:
|
||||
deps += dep.java.transitive_runtime_deps
|
||||
deps += dep.java.transitive_source_jars
|
||||
for dep in ctx.attr.deps:
|
||||
if hasattr(dep, 'java'):
|
||||
deps += dep.java.transitive_runtime_deps
|
||||
elif hasattr(dep, 'files'):
|
||||
deps += dep.files
|
||||
deps = depset()
|
||||
for dep in ctx.attr.module_deps:
|
||||
deps += dep.java.transitive_runtime_deps
|
||||
deps += dep.java.transitive_source_jars
|
||||
for dep in ctx.attr.deps:
|
||||
if hasattr(dep, "java"):
|
||||
deps += dep.java.transitive_runtime_deps
|
||||
elif hasattr(dep, "files"):
|
||||
deps += dep.files
|
||||
|
||||
return deps
|
||||
return deps
|
||||
|
||||
gwt_binary = rule(
|
||||
attrs = {
|
||||
@ -233,77 +238,78 @@ gwt_binary = rule(
|
||||
)
|
||||
|
||||
def gwt_genrule(suffix = ""):
|
||||
dbg = 'ui_dbg' + suffix
|
||||
opt = 'ui_opt' + suffix
|
||||
module_dep = ':ui_module' + suffix
|
||||
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
|
||||
dbg = "ui_dbg" + suffix
|
||||
opt = "ui_opt" + suffix
|
||||
module_dep = ":ui_module" + suffix
|
||||
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
|
||||
|
||||
genrule2(
|
||||
name = 'ui_optdbg' + suffix,
|
||||
srcs = [
|
||||
':' + dbg,
|
||||
':' + opt,
|
||||
],
|
||||
cmd = 'cd $$TMP;' +
|
||||
'unzip -q $$ROOT/$(location :%s);' % dbg +
|
||||
'mv' +
|
||||
' gerrit_ui/gerrit_ui.nocache.js' +
|
||||
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
|
||||
'unzip -qo $$ROOT/$(location :%s);' % opt +
|
||||
'mkdir -p $$(dirname $@);' +
|
||||
'zip -qrD $$ROOT/$@ .',
|
||||
outs = ['ui_optdbg' + suffix + '.zip'],
|
||||
visibility = ['//visibility:public'],
|
||||
)
|
||||
genrule2(
|
||||
name = "ui_optdbg" + suffix,
|
||||
srcs = [
|
||||
":" + dbg,
|
||||
":" + opt,
|
||||
],
|
||||
cmd = "cd $$TMP;" +
|
||||
"unzip -q $$ROOT/$(location :%s);" % dbg +
|
||||
"mv" +
|
||||
" gerrit_ui/gerrit_ui.nocache.js" +
|
||||
" gerrit_ui/dbg_gerrit_ui.nocache.js;" +
|
||||
"unzip -qo $$ROOT/$(location :%s);" % opt +
|
||||
"mkdir -p $$(dirname $@);" +
|
||||
"zip -qrD $$ROOT/$@ .",
|
||||
outs = ["ui_optdbg" + suffix + ".zip"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
gwt_binary(
|
||||
name = opt,
|
||||
module = [MODULE],
|
||||
module_deps = [module_dep],
|
||||
deps = DEPS,
|
||||
compiler_args = args,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
gwt_binary(
|
||||
name = opt,
|
||||
module = [MODULE],
|
||||
module_deps = [module_dep],
|
||||
deps = DEPS,
|
||||
compiler_args = args,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
|
||||
gwt_binary(
|
||||
name = dbg,
|
||||
style = 'PRETTY',
|
||||
optimize = "0",
|
||||
module_deps = [module_dep],
|
||||
deps = DEPS,
|
||||
compiler_args = GWT_COMPILER_ARGS,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
gwt_binary(
|
||||
name = dbg,
|
||||
style = "PRETTY",
|
||||
optimize = "0",
|
||||
module_deps = [module_dep],
|
||||
deps = DEPS,
|
||||
compiler_args = GWT_COMPILER_ARGS,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
|
||||
def gen_ui_module(name, suffix = ""):
|
||||
gwt_module(
|
||||
name = name + suffix,
|
||||
srcs = native.glob(['src/main/java/**/*.java']),
|
||||
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
|
||||
resources = native.glob(
|
||||
['src/main/java/**/*'],
|
||||
exclude = ['src/main/java/**/*.java'] +
|
||||
['src/main/java/%s.gwt.xml' % MODULE.replace('.', '/')]),
|
||||
deps = [
|
||||
'//gerrit-gwtui-common:diffy_logo',
|
||||
'//gerrit-gwtui-common:client',
|
||||
'//gerrit-gwtexpui:CSS',
|
||||
'//lib/codemirror:codemirror' + suffix,
|
||||
'//lib/gwt:user',
|
||||
],
|
||||
visibility = ['//visibility:public'],
|
||||
)
|
||||
gwt_module(
|
||||
name = name + suffix,
|
||||
srcs = native.glob(["src/main/java/**/*.java"]),
|
||||
gwt_xml = "src/main/java/%s.gwt.xml" % MODULE.replace(".", "/"),
|
||||
resources = native.glob(
|
||||
["src/main/java/**/*"],
|
||||
exclude = ["src/main/java/**/*.java"] +
|
||||
["src/main/java/%s.gwt.xml" % MODULE.replace(".", "/")],
|
||||
),
|
||||
deps = [
|
||||
"//gerrit-gwtui-common:diffy_logo",
|
||||
"//gerrit-gwtui-common:client",
|
||||
"//gerrit-gwtexpui:CSS",
|
||||
"//lib/codemirror:codemirror" + suffix,
|
||||
"//lib/gwt:user",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
def gwt_user_agent_permutations():
|
||||
for ua in BROWSERS:
|
||||
gwt_binary(
|
||||
name = "ui_%s" % ua,
|
||||
user_agent = ua,
|
||||
style = 'PRETTY',
|
||||
optimize = "0",
|
||||
module = [MODULE],
|
||||
module_deps = [':ui_module'],
|
||||
deps = DEPS,
|
||||
compiler_args = GWT_COMPILER_ARGS,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
for ua in BROWSERS:
|
||||
gwt_binary(
|
||||
name = "ui_%s" % ua,
|
||||
user_agent = ua,
|
||||
style = "PRETTY",
|
||||
optimize = "0",
|
||||
module = [MODULE],
|
||||
module_deps = [":ui_module"],
|
||||
deps = DEPS,
|
||||
compiler_args = GWT_COMPILER_ARGS,
|
||||
jvm_args = GWT_JVM_ARGS,
|
||||
)
|
||||
|
@ -15,11 +15,12 @@
|
||||
# Syntactic sugar for native java_library() rule:
|
||||
# accept exported_deps attributes
|
||||
|
||||
def java_library2(deps=[], exported_deps=[], exports=[], **kwargs):
|
||||
if exported_deps:
|
||||
deps = deps + exported_deps
|
||||
exports = exports + exported_deps
|
||||
native.java_library(
|
||||
deps = deps,
|
||||
exports = exports,
|
||||
**kwargs)
|
||||
def java_library2(deps = [], exported_deps = [], exports = [], **kwargs):
|
||||
if exported_deps:
|
||||
deps = deps + exported_deps
|
||||
exports = exports + exported_deps
|
||||
native.java_library(
|
||||
deps = deps,
|
||||
exports = exports,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -15,49 +15,51 @@
|
||||
# Javadoc rule.
|
||||
|
||||
def _impl(ctx):
|
||||
zip_output = ctx.outputs.zip
|
||||
zip_output = ctx.outputs.zip
|
||||
|
||||
transitive_jar_set = depset()
|
||||
source_jars = depset()
|
||||
for l in ctx.attr.libs:
|
||||
source_jars += l.java.source_jars
|
||||
transitive_jar_set += l.java.transitive_deps
|
||||
transitive_jar_set = depset()
|
||||
source_jars = depset()
|
||||
for l in ctx.attr.libs:
|
||||
source_jars += l.java.source_jars
|
||||
transitive_jar_set += l.java.transitive_deps
|
||||
|
||||
transitive_jar_paths = [j.path for j in transitive_jar_set]
|
||||
dir = ctx.outputs.zip.path + ".dir"
|
||||
source = ctx.outputs.zip.path + ".source"
|
||||
external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
|
||||
cmd = [
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"rm -rf %s" % source,
|
||||
"mkdir %s" % source,
|
||||
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
|
||||
"rm -rf %s" % dir,
|
||||
"mkdir %s" % dir,
|
||||
" ".join([
|
||||
ctx.file._javadoc.path,
|
||||
"-Xdoclint:-missing",
|
||||
"-protected",
|
||||
"-encoding UTF-8",
|
||||
"-charset UTF-8",
|
||||
"-notimestamp",
|
||||
"-quiet",
|
||||
"-windowtitle '%s'" % ctx.attr.title,
|
||||
" ".join(['-link %s' % url for url in external_docs]),
|
||||
"-sourcepath %s" % source,
|
||||
"-subpackages ",
|
||||
":".join(ctx.attr.pkgs),
|
||||
" -classpath ",
|
||||
":".join(transitive_jar_paths),
|
||||
"-d %s" % dir]),
|
||||
"find %s -exec touch -t 198001010000 '{}' ';'" % dir,
|
||||
"(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
|
||||
]
|
||||
ctx.action(
|
||||
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,
|
||||
outputs = [zip_output],
|
||||
command = " && ".join(cmd))
|
||||
transitive_jar_paths = [j.path for j in transitive_jar_set]
|
||||
dir = ctx.outputs.zip.path + ".dir"
|
||||
source = ctx.outputs.zip.path + ".source"
|
||||
external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
|
||||
cmd = [
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"rm -rf %s" % source,
|
||||
"mkdir %s" % source,
|
||||
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
|
||||
"rm -rf %s" % dir,
|
||||
"mkdir %s" % dir,
|
||||
" ".join([
|
||||
ctx.file._javadoc.path,
|
||||
"-Xdoclint:-missing",
|
||||
"-protected",
|
||||
"-encoding UTF-8",
|
||||
"-charset UTF-8",
|
||||
"-notimestamp",
|
||||
"-quiet",
|
||||
"-windowtitle '%s'" % ctx.attr.title,
|
||||
" ".join(["-link %s" % url for url in external_docs]),
|
||||
"-sourcepath %s" % source,
|
||||
"-subpackages ",
|
||||
":".join(ctx.attr.pkgs),
|
||||
" -classpath ",
|
||||
":".join(transitive_jar_paths),
|
||||
"-d %s" % dir,
|
||||
]),
|
||||
"find %s -exec touch -t 198001010000 '{}' ';'" % dir,
|
||||
"(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
|
||||
]
|
||||
ctx.action(
|
||||
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,
|
||||
outputs = [zip_output],
|
||||
command = " && ".join(cmd),
|
||||
)
|
||||
|
||||
java_doc = rule(
|
||||
attrs = {
|
||||
|
480
tools/bzl/js.bzl
480
tools/bzl/js.bzl
@ -15,35 +15,35 @@ NPM_SHA1S = {
|
||||
}
|
||||
|
||||
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):
|
||||
"""rule to download a NPM archive."""
|
||||
name = ctx.name
|
||||
version= NPM_VERSIONS[name]
|
||||
sha1 = NPM_VERSIONS[name]
|
||||
"""rule to download a NPM archive."""
|
||||
name = ctx.name
|
||||
version = NPM_VERSIONS[name]
|
||||
sha1 = NPM_VERSIONS[name]
|
||||
|
||||
dir = '%s-%s' % (name, version)
|
||||
filename = '%s.tgz' % dir
|
||||
base = '%s@%s.npm_binary.tgz' % (name, version)
|
||||
dest = ctx.path(base)
|
||||
repository = ctx.attr.repository
|
||||
if repository == GERRIT:
|
||||
url = 'http://gerrit-maven.storage.googleapis.com/npm-packages/%s' % filename
|
||||
elif repository == NPMJS:
|
||||
url = 'http://registry.npmjs.org/%s/-/%s' % (name, filename)
|
||||
else:
|
||||
fail('repository %s not in {%s,%s}' % (repository, GERRIT, NPMJS))
|
||||
dir = "%s-%s" % (name, version)
|
||||
filename = "%s.tgz" % dir
|
||||
base = "%s@%s.npm_binary.tgz" % (name, version)
|
||||
dest = ctx.path(base)
|
||||
repository = ctx.attr.repository
|
||||
if repository == GERRIT:
|
||||
url = "http://gerrit-maven.storage.googleapis.com/npm-packages/%s" % filename
|
||||
elif repository == NPMJS:
|
||||
url = "http://registry.npmjs.org/%s/-/%s" % (name, filename)
|
||||
else:
|
||||
fail("repository %s not in {%s,%s}" % (repository, GERRIT, NPMJS))
|
||||
|
||||
python = ctx.which("python")
|
||||
script = ctx.path(ctx.attr._download_script)
|
||||
python = ctx.which("python")
|
||||
script = ctx.path(ctx.attr._download_script)
|
||||
|
||||
sha1 = NPM_SHA1S[name]
|
||||
args = [python, script, "-o", dest, "-u", url, "-v", sha1]
|
||||
out = ctx.execute(args)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (args, out.stderr))
|
||||
ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False)
|
||||
sha1 = NPM_SHA1S[name]
|
||||
args = [python, script, "-o", dest, "-u", url, "-v", sha1]
|
||||
out = ctx.execute(args)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (args, out.stderr))
|
||||
ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False)
|
||||
|
||||
npm_binary = repository_rule(
|
||||
attrs = {
|
||||
@ -57,64 +57,75 @@ npm_binary = repository_rule(
|
||||
|
||||
# for use in repo rules.
|
||||
def _run_npm_binary_str(ctx, tarball, args):
|
||||
python_bin = ctx.which("python")
|
||||
return " ".join([
|
||||
python_bin,
|
||||
ctx.path(ctx.attr._run_npm),
|
||||
ctx.path(tarball)] + args)
|
||||
python_bin = ctx.which("python")
|
||||
return " ".join([
|
||||
python_bin,
|
||||
ctx.path(ctx.attr._run_npm),
|
||||
ctx.path(tarball),
|
||||
] + args)
|
||||
|
||||
def _bower_archive(ctx):
|
||||
"""Download a bower package."""
|
||||
download_name = '%s__download_bower.zip' % ctx.name
|
||||
renamed_name = '%s__renamed.zip' % ctx.name
|
||||
version_name = '%s__version.json' % ctx.name
|
||||
"""Download a bower package."""
|
||||
download_name = "%s__download_bower.zip" % ctx.name
|
||||
renamed_name = "%s__renamed.zip" % ctx.name
|
||||
version_name = "%s__version.json" % ctx.name
|
||||
|
||||
cmd = [
|
||||
ctx.which("python"),
|
||||
ctx.path(ctx.attr._download_bower),
|
||||
'-b', '%s' % _run_npm_binary_str(ctx, ctx.attr._bower_archive, []),
|
||||
'-n', ctx.name,
|
||||
'-p', ctx.attr.package,
|
||||
'-v', ctx.attr.version,
|
||||
'-s', ctx.attr.sha1,
|
||||
'-o', download_name,
|
||||
cmd = [
|
||||
ctx.which("python"),
|
||||
ctx.path(ctx.attr._download_bower),
|
||||
"-b",
|
||||
"%s" % _run_npm_binary_str(ctx, ctx.attr._bower_archive, []),
|
||||
"-n",
|
||||
ctx.name,
|
||||
"-p",
|
||||
ctx.attr.package,
|
||||
"-v",
|
||||
ctx.attr.version,
|
||||
"-s",
|
||||
ctx.attr.sha1,
|
||||
"-o",
|
||||
download_name,
|
||||
]
|
||||
|
||||
out = ctx.execute(cmd)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (" ".join(cmd), out.stderr))
|
||||
out = ctx.execute(cmd)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (" ".join(cmd), out.stderr))
|
||||
|
||||
_bash(ctx, " && " .join([
|
||||
"TMP=$(mktemp -d || mktemp -d -t bazel-tmp)",
|
||||
"TZ=UTC",
|
||||
"export UTC",
|
||||
"cd $TMP",
|
||||
"mkdir bower_components",
|
||||
"cd bower_components",
|
||||
"unzip %s" % ctx.path(download_name),
|
||||
"cd ..",
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xr %s bower_components" % renamed_name,
|
||||
"cd ..",
|
||||
"rm -rf ${TMP}",
|
||||
]))
|
||||
_bash(ctx, " && ".join([
|
||||
"TMP=$(mktemp -d || mktemp -d -t bazel-tmp)",
|
||||
"TZ=UTC",
|
||||
"export UTC",
|
||||
"cd $TMP",
|
||||
"mkdir bower_components",
|
||||
"cd bower_components",
|
||||
"unzip %s" % ctx.path(download_name),
|
||||
"cd ..",
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xr %s bower_components" % renamed_name,
|
||||
"cd ..",
|
||||
"rm -rf ${TMP}",
|
||||
]))
|
||||
|
||||
dep_version = ctx.attr.semver if ctx.attr.semver else ctx.attr.version
|
||||
ctx.file(version_name,
|
||||
'"%s":"%s#%s"' % (ctx.name, ctx.attr.package, dep_version))
|
||||
ctx.file(
|
||||
"BUILD",
|
||||
"\n".join([
|
||||
"package(default_visibility=['//visibility:public'])",
|
||||
"filegroup(name = 'zipfile', srcs = ['%s'], )" % download_name,
|
||||
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name,
|
||||
]), False)
|
||||
dep_version = ctx.attr.semver if ctx.attr.semver else ctx.attr.version
|
||||
ctx.file(
|
||||
version_name,
|
||||
'"%s":"%s#%s"' % (ctx.name, ctx.attr.package, dep_version),
|
||||
)
|
||||
ctx.file(
|
||||
"BUILD",
|
||||
"\n".join([
|
||||
"package(default_visibility=['//visibility:public'])",
|
||||
"filegroup(name = 'zipfile', srcs = ['%s'], )" % download_name,
|
||||
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name,
|
||||
]),
|
||||
False,
|
||||
)
|
||||
|
||||
def _bash(ctx, cmd):
|
||||
cmd_list = ["bash", "-c", cmd]
|
||||
out = ctx.execute(cmd_list)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (" ".join(cmd_list), out.stderr))
|
||||
cmd_list = ["bash", "-c", cmd]
|
||||
out = ctx.execute(cmd_list)
|
||||
if out.return_code:
|
||||
fail("failed %s: %s" % (" ".join(cmd_list), out.stderr))
|
||||
|
||||
bower_archive = repository_rule(
|
||||
_bower_archive,
|
||||
@ -130,26 +141,26 @@ bower_archive = repository_rule(
|
||||
)
|
||||
|
||||
def _bower_component_impl(ctx):
|
||||
transitive_zipfiles = depset([ctx.file.zipfile])
|
||||
for d in ctx.attr.deps:
|
||||
transitive_zipfiles += d.transitive_zipfiles
|
||||
transitive_zipfiles = depset([ctx.file.zipfile])
|
||||
for d in ctx.attr.deps:
|
||||
transitive_zipfiles += d.transitive_zipfiles
|
||||
|
||||
transitive_licenses = depset()
|
||||
if ctx.file.license:
|
||||
transitive_licenses += depset([ctx.file.license])
|
||||
transitive_licenses = depset()
|
||||
if ctx.file.license:
|
||||
transitive_licenses += depset([ctx.file.license])
|
||||
|
||||
for d in ctx.attr.deps:
|
||||
transitive_licenses += d.transitive_licenses
|
||||
for d in ctx.attr.deps:
|
||||
transitive_licenses += d.transitive_licenses
|
||||
|
||||
transitive_versions = depset(ctx.files.version_json)
|
||||
for d in ctx.attr.deps:
|
||||
transitive_versions += d.transitive_versions
|
||||
transitive_versions = depset(ctx.files.version_json)
|
||||
for d in ctx.attr.deps:
|
||||
transitive_versions += d.transitive_versions
|
||||
|
||||
return struct(
|
||||
transitive_zipfiles=transitive_zipfiles,
|
||||
transitive_versions=transitive_versions,
|
||||
transitive_licenses=transitive_licenses,
|
||||
)
|
||||
return struct(
|
||||
transitive_zipfiles = transitive_zipfiles,
|
||||
transitive_versions = transitive_versions,
|
||||
transitive_licenses = transitive_licenses,
|
||||
)
|
||||
|
||||
_common_attrs = {
|
||||
"deps": attr.label_list(providers = [
|
||||
@ -160,35 +171,37 @@ _common_attrs = {
|
||||
}
|
||||
|
||||
def _js_component(ctx):
|
||||
dir = ctx.outputs.zip.path + ".dir"
|
||||
name = ctx.outputs.zip.basename
|
||||
if name.endswith(".zip"):
|
||||
name = name[:-4]
|
||||
dest = "%s/%s" % (dir, name)
|
||||
cmd = " && ".join([
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"mkdir -p %s" % dest,
|
||||
"cp %s %s/" % (' '.join([s.path for s in ctx.files.srcs]), dest),
|
||||
"cd %s" % dir,
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xqr ../%s *" % ctx.outputs.zip.basename
|
||||
])
|
||||
dir = ctx.outputs.zip.path + ".dir"
|
||||
name = ctx.outputs.zip.basename
|
||||
if name.endswith(".zip"):
|
||||
name = name[:-4]
|
||||
dest = "%s/%s" % (dir, name)
|
||||
cmd = " && ".join([
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"mkdir -p %s" % dest,
|
||||
"cp %s %s/" % (" ".join([s.path for s in ctx.files.srcs]), dest),
|
||||
"cd %s" % dir,
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xqr ../%s *" % ctx.outputs.zip.basename,
|
||||
])
|
||||
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs,
|
||||
outputs = [ctx.outputs.zip],
|
||||
command = cmd,
|
||||
mnemonic = "GenBowerZip")
|
||||
ctx.action(
|
||||
inputs = ctx.files.srcs,
|
||||
outputs = [ctx.outputs.zip],
|
||||
command = cmd,
|
||||
mnemonic = "GenBowerZip",
|
||||
)
|
||||
|
||||
licenses = depset()
|
||||
if ctx.file.license:
|
||||
licenses += depset([ctx.file.license])
|
||||
licenses = depset()
|
||||
if ctx.file.license:
|
||||
licenses += depset([ctx.file.license])
|
||||
|
||||
return struct(
|
||||
transitive_zipfiles=list([ctx.outputs.zip]),
|
||||
transitive_versions=depset(),
|
||||
transitive_licenses=licenses)
|
||||
return struct(
|
||||
transitive_zipfiles = list([ctx.outputs.zip]),
|
||||
transitive_versions = depset(),
|
||||
transitive_licenses = licenses,
|
||||
)
|
||||
|
||||
js_component = rule(
|
||||
_js_component,
|
||||
@ -214,61 +227,65 @@ _bower_component = rule(
|
||||
)
|
||||
|
||||
# TODO(hanwen): make license mandatory.
|
||||
def bower_component(name, license=None, **kwargs):
|
||||
prefix = "//lib:LICENSE-"
|
||||
if license and not license.startswith(prefix):
|
||||
license = prefix + license
|
||||
_bower_component(
|
||||
name=name,
|
||||
license=license,
|
||||
zipfile="@%s//:zipfile"% name,
|
||||
version_json="@%s//:version_json" % name,
|
||||
**kwargs)
|
||||
def bower_component(name, license = None, **kwargs):
|
||||
prefix = "//lib:LICENSE-"
|
||||
if license and not license.startswith(prefix):
|
||||
license = prefix + license
|
||||
_bower_component(
|
||||
name = name,
|
||||
license = license,
|
||||
zipfile = "@%s//:zipfile" % name,
|
||||
version_json = "@%s//:version_json" % name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def _bower_component_bundle_impl(ctx):
|
||||
"""A bunch of bower components zipped up."""
|
||||
zips = depset()
|
||||
for d in ctx.attr.deps:
|
||||
zips += d.transitive_zipfiles
|
||||
"""A bunch of bower components zipped up."""
|
||||
zips = depset()
|
||||
for d in ctx.attr.deps:
|
||||
zips += d.transitive_zipfiles
|
||||
|
||||
versions = depset()
|
||||
for d in ctx.attr.deps:
|
||||
versions += d.transitive_versions
|
||||
versions = depset()
|
||||
for d in ctx.attr.deps:
|
||||
versions += d.transitive_versions
|
||||
|
||||
licenses = depset()
|
||||
for d in ctx.attr.deps:
|
||||
licenses += d.transitive_versions
|
||||
licenses = depset()
|
||||
for d in ctx.attr.deps:
|
||||
licenses += d.transitive_versions
|
||||
|
||||
out_zip = ctx.outputs.zip
|
||||
out_versions = ctx.outputs.version_json
|
||||
out_zip = ctx.outputs.zip
|
||||
out_versions = ctx.outputs.version_json
|
||||
|
||||
ctx.action(
|
||||
inputs=list(zips),
|
||||
outputs=[out_zip],
|
||||
command=" && ".join([
|
||||
"p=$PWD",
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"rm -rf %s.dir" % out_zip.path,
|
||||
"mkdir -p %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])),
|
||||
"cd ..",
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xqr $p/%s bower_components/*" % out_zip.path,
|
||||
]),
|
||||
mnemonic="BowerCombine")
|
||||
ctx.action(
|
||||
inputs = list(zips),
|
||||
outputs = [out_zip],
|
||||
command = " && ".join([
|
||||
"p=$PWD",
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"rm -rf %s.dir" % out_zip.path,
|
||||
"mkdir -p %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])),
|
||||
"cd ..",
|
||||
"find . -exec touch -t 198001010000 '{}' ';'",
|
||||
"zip -Xqr $p/%s bower_components/*" % out_zip.path,
|
||||
]),
|
||||
mnemonic = "BowerCombine",
|
||||
)
|
||||
|
||||
ctx.action(
|
||||
inputs=list(versions),
|
||||
outputs=[out_versions],
|
||||
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))
|
||||
ctx.action(
|
||||
inputs = list(versions),
|
||||
outputs = [out_versions],
|
||||
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),
|
||||
)
|
||||
|
||||
return struct(
|
||||
transitive_zipfiles=zips,
|
||||
transitive_versions=versions,
|
||||
transitive_licenses=licenses)
|
||||
return struct(
|
||||
transitive_zipfiles = zips,
|
||||
transitive_versions = versions,
|
||||
transitive_licenses = licenses,
|
||||
)
|
||||
|
||||
bower_component_bundle = rule(
|
||||
_bower_component_bundle_impl,
|
||||
@ -289,69 +306,88 @@ Outputs:
|
||||
"""
|
||||
|
||||
def _vulcanize_impl(ctx):
|
||||
# intermediate artifact.
|
||||
vulcanized = ctx.new_file(
|
||||
ctx.configuration.genfiles_dir, ctx.outputs.html, ".vulcanized.html")
|
||||
destdir = ctx.outputs.html.path + ".dir"
|
||||
zips = [z for d in ctx.attr.deps for z in d.transitive_zipfiles ]
|
||||
# intermediate artifact.
|
||||
vulcanized = ctx.new_file(
|
||||
ctx.configuration.genfiles_dir,
|
||||
ctx.outputs.html,
|
||||
".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([
|
||||
'python',
|
||||
"$p/" + ctx.file._run_npm.path,
|
||||
"$p/" + ctx.file._vulcanize_archive.path,
|
||||
'--inline-scripts',
|
||||
'--inline-css',
|
||||
'--strip-comments',
|
||||
'--out-html', "$p/" + vulcanized.path,
|
||||
ctx.file.app.path
|
||||
])
|
||||
hermetic_npm_binary = " ".join([
|
||||
"python",
|
||||
"$p/" + ctx.file._run_npm.path,
|
||||
"$p/" + ctx.file._vulcanize_archive.path,
|
||||
"--inline-scripts",
|
||||
"--inline-css",
|
||||
"--strip-comments",
|
||||
"--out-html",
|
||||
"$p/" + vulcanized.path,
|
||||
ctx.file.app.path,
|
||||
])
|
||||
|
||||
pkg_dir = ctx.attr.pkg.lstrip("/")
|
||||
cmd = " && ".join([
|
||||
# unpack dependencies.
|
||||
"export PATH",
|
||||
"p=$PWD",
|
||||
"rm -rf %s" % destdir,
|
||||
"mkdir -p %s/%s/bower_components" % (destdir, pkg_dir),
|
||||
"for z in %s; do unzip -qd %s/%s/bower_components/ $z; done" % (
|
||||
' '.join([z.path for z in zips]), destdir, pkg_dir),
|
||||
"tar -cf - %s | tar -C %s -xf -" % (" ".join([s.path for s in ctx.files.srcs]), destdir),
|
||||
"cd %s" % destdir,
|
||||
hermetic_npm_binary,
|
||||
])
|
||||
pkg_dir = ctx.attr.pkg.lstrip("/")
|
||||
cmd = " && ".join([
|
||||
# unpack dependencies.
|
||||
"export PATH",
|
||||
"p=$PWD",
|
||||
"rm -rf %s" % destdir,
|
||||
"mkdir -p %s/%s/bower_components" % (destdir, pkg_dir),
|
||||
"for z in %s; do unzip -qd %s/%s/bower_components/ $z; done" % (
|
||||
" ".join([z.path for z in zips]),
|
||||
destdir,
|
||||
pkg_dir,
|
||||
),
|
||||
"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
|
||||
# from the environment, and it may be under $HOME, so we can't run
|
||||
# in the sandbox.
|
||||
node_tweaks = dict(
|
||||
use_default_shell_env = True,
|
||||
execution_requirements = {"local": "1"},
|
||||
)
|
||||
ctx.action(
|
||||
mnemonic = "Vulcanize",
|
||||
inputs = [ctx.file._run_npm, ctx.file.app,
|
||||
ctx.file._vulcanize_archive
|
||||
] + list(zips) + ctx.files.srcs,
|
||||
outputs = [vulcanized],
|
||||
command = cmd,
|
||||
**node_tweaks)
|
||||
# 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
|
||||
# in the sandbox.
|
||||
node_tweaks = dict(
|
||||
use_default_shell_env = True,
|
||||
execution_requirements = {"local": "1"},
|
||||
)
|
||||
ctx.action(
|
||||
mnemonic = "Vulcanize",
|
||||
inputs = [
|
||||
ctx.file._run_npm,
|
||||
ctx.file.app,
|
||||
ctx.file._vulcanize_archive,
|
||||
] + list(zips) + ctx.files.srcs,
|
||||
outputs = [vulcanized],
|
||||
command = cmd,
|
||||
**node_tweaks
|
||||
)
|
||||
|
||||
hermetic_npm_command = "export PATH && " + " ".join([
|
||||
'python',
|
||||
ctx.file._run_npm.path,
|
||||
ctx.file._crisper_archive.path,
|
||||
"--always-write-script",
|
||||
"--source", vulcanized.path,
|
||||
"--html", ctx.outputs.html.path,
|
||||
"--js", ctx.outputs.js.path])
|
||||
hermetic_npm_command = "export PATH && " + " ".join([
|
||||
"python",
|
||||
ctx.file._run_npm.path,
|
||||
ctx.file._crisper_archive.path,
|
||||
"--always-write-script",
|
||||
"--source",
|
||||
vulcanized.path,
|
||||
"--html",
|
||||
ctx.outputs.html.path,
|
||||
"--js",
|
||||
ctx.outputs.js.path,
|
||||
])
|
||||
|
||||
ctx.action(
|
||||
mnemonic = "Crisper",
|
||||
inputs = [ctx.file._run_npm, ctx.file.app,
|
||||
ctx.file._crisper_archive, vulcanized],
|
||||
outputs = [ctx.outputs.js, ctx.outputs.html],
|
||||
command = hermetic_npm_command,
|
||||
**node_tweaks)
|
||||
ctx.action(
|
||||
mnemonic = "Crisper",
|
||||
inputs = [
|
||||
ctx.file._run_npm,
|
||||
ctx.file.app,
|
||||
ctx.file._crisper_archive,
|
||||
vulcanized,
|
||||
],
|
||||
outputs = [ctx.outputs.js, ctx.outputs.html],
|
||||
command = hermetic_npm_command,
|
||||
**node_tweaks
|
||||
)
|
||||
|
||||
_vulcanize_rule = rule(
|
||||
_vulcanize_impl,
|
||||
@ -389,5 +425,5 @@ _vulcanize_rule = rule(
|
||||
)
|
||||
|
||||
def vulcanize(*args, **kwargs):
|
||||
"""Vulcanize runs vulcanize and crisper on a set of sources."""
|
||||
_vulcanize_rule(*args, pkg=PACKAGE_NAME, **kwargs)
|
||||
"""Vulcanize runs vulcanize and crisper on a set of sources."""
|
||||
_vulcanize_rule(*args, pkg = PACKAGE_NAME, **kwargs)
|
||||
|
@ -43,15 +43,21 @@ def _AsClassName(fname):
|
||||
if findex != -1:
|
||||
break
|
||||
if findex == -1:
|
||||
fail("%s does not contain any of %s",
|
||||
fname, _PREFIXES)
|
||||
fail(
|
||||
"%s does not contain any of %s",
|
||||
fname,
|
||||
_PREFIXES,
|
||||
)
|
||||
return ".".join(toks[findex:]) + ".class"
|
||||
|
||||
def _impl(ctx):
|
||||
classes = ",".join(
|
||||
[_AsClassName(x) for x in ctx.attr.srcs])
|
||||
ctx.file_action(output=ctx.outputs.out, content=_OUTPUT % (
|
||||
classes, ctx.attr.outname))
|
||||
[_AsClassName(x) for x in ctx.attr.srcs],
|
||||
)
|
||||
ctx.file_action(output = ctx.outputs.out, content = _OUTPUT % (
|
||||
classes,
|
||||
ctx.attr.outname,
|
||||
))
|
||||
|
||||
_GenSuite = rule(
|
||||
attrs = {
|
||||
@ -64,10 +70,14 @@ _GenSuite = rule(
|
||||
|
||||
def junit_tests(name, srcs, **kwargs):
|
||||
s_name = name + "TestSuite"
|
||||
_GenSuite(name = s_name,
|
||||
srcs = srcs,
|
||||
outname = s_name)
|
||||
native.java_test(name = name,
|
||||
test_class = s_name,
|
||||
srcs = srcs + [":"+s_name],
|
||||
**kwargs)
|
||||
_GenSuite(
|
||||
name = s_name,
|
||||
srcs = srcs,
|
||||
outname = s_name,
|
||||
)
|
||||
native.java_test(
|
||||
name = name,
|
||||
test_class = s_name,
|
||||
srcs = srcs + [":" + s_name],
|
||||
**kwargs
|
||||
)
|
||||
|
@ -1,57 +1,57 @@
|
||||
def normalize_target_name(target):
|
||||
return target.replace("//", "").replace("/", "__").replace(":", "___")
|
||||
return target.replace("//", "").replace("/", "__").replace(":", "___")
|
||||
|
||||
def license_map(name, targets = [], opts = [], **kwargs):
|
||||
"""Generate XML for all targets that depend directly on a LICENSE file"""
|
||||
xmls = []
|
||||
tools = [ "//tools/bzl:license-map.py", "//lib:all-licenses" ]
|
||||
for target in targets:
|
||||
subname = name + "_" + normalize_target_name(target) + ".xml"
|
||||
xmls.append("$(location :%s)" % subname)
|
||||
tools.append(subname)
|
||||
native.genquery(
|
||||
name = subname,
|
||||
scope = [ target ],
|
||||
"""Generate XML for all targets that depend directly on a LICENSE file"""
|
||||
xmls = []
|
||||
tools = ["//tools/bzl:license-map.py", "//lib:all-licenses"]
|
||||
for target in targets:
|
||||
subname = name + "_" + normalize_target_name(target) + ".xml"
|
||||
xmls.append("$(location :%s)" % subname)
|
||||
tools.append(subname)
|
||||
native.genquery(
|
||||
name = subname,
|
||||
scope = [target],
|
||||
|
||||
# Find everything that depends on a license file, but remove
|
||||
# the license files themselves from this list.
|
||||
expression = 'rdeps(%s, filter("//lib:LICENSE.*", deps(%s)),1) - filter("//lib:LICENSE.*", deps(%s))' % (target, target, target),
|
||||
# Find everything that depends on a license file, but remove
|
||||
# the license files themselves from this list.
|
||||
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,
|
||||
# license-file} tuples). 'query' provides this in the XML output.
|
||||
opts = [ "--output=xml", ],
|
||||
# We are interested in the edges of the graph ({java_library,
|
||||
# license-file} tuples). 'query' provides this in the XML output.
|
||||
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):
|
||||
"""Make sure a target doesn't depend on DO_NOT_DISTRIBUTE license"""
|
||||
txt = name + "-forbidden.txt"
|
||||
"""Make sure a target doesn't depend on DO_NOT_DISTRIBUTE license"""
|
||||
txt = name + "-forbidden.txt"
|
||||
|
||||
# fully qualify target name.
|
||||
if target[0] not in ":/":
|
||||
target = ":" + target
|
||||
if target[0] != "/":
|
||||
target = "//" + PACKAGE_NAME + target
|
||||
# fully qualify target name.
|
||||
if target[0] not in ":/":
|
||||
target = ":" + target
|
||||
if target[0] != "/":
|
||||
target = "//" + PACKAGE_NAME + target
|
||||
|
||||
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
|
||||
native.genquery(
|
||||
name = txt,
|
||||
scope = [ target, forbidden ],
|
||||
# Find everything that depends on a license file, but remove
|
||||
# the license files themselves from this list.
|
||||
expression = 'rdeps(%s, "%s", 1) - rdeps(%s, "%s", 0)' % (target, forbidden, target, forbidden),
|
||||
)
|
||||
native.sh_test(
|
||||
name = name,
|
||||
srcs = [ "//tools/bzl:test_license.sh" ],
|
||||
args = [ "$(location :%s)" % txt ],
|
||||
data = [ txt ],
|
||||
)
|
||||
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
|
||||
native.genquery(
|
||||
name = txt,
|
||||
scope = [target, forbidden],
|
||||
# Find everything that depends on a license file, but remove
|
||||
# the license files themselves from this list.
|
||||
expression = 'rdeps(%s, "%s", 1) - rdeps(%s, "%s", 0)' % (target, forbidden, target, forbidden),
|
||||
)
|
||||
native.sh_test(
|
||||
name = name,
|
||||
srcs = ["//tools/bzl:test_license.sh"],
|
||||
args = ["$(location :%s)" % txt],
|
||||
data = [txt],
|
||||
)
|
||||
|
@ -15,18 +15,18 @@
|
||||
# Merge maven files
|
||||
|
||||
def cmd(jars):
|
||||
return ('$(location //tools:merge_jars) $@ '
|
||||
+ ' '.join(['$(location %s)' % j for j in jars]))
|
||||
return ("$(location //tools:merge_jars) $@ " +
|
||||
" ".join(["$(location %s)" % j for j in jars]))
|
||||
|
||||
def merge_maven_jars(name, srcs, **kwargs):
|
||||
native.genrule(
|
||||
name = '%s__merged_bin' % name,
|
||||
cmd = cmd(srcs),
|
||||
tools = srcs + ['//tools:merge_jars'],
|
||||
outs = ['%s__merged.jar' % name],
|
||||
)
|
||||
native.java_import(
|
||||
name = name,
|
||||
jars = [':%s__merged_bin' % name],
|
||||
**kwargs
|
||||
)
|
||||
native.genrule(
|
||||
name = "%s__merged_bin" % name,
|
||||
cmd = cmd(srcs),
|
||||
tools = srcs + ["//tools:merge_jars"],
|
||||
outs = ["%s__merged.jar" % name],
|
||||
)
|
||||
native.java_import(
|
||||
name = name,
|
||||
jars = [":%s__merged_bin" % name],
|
||||
**kwargs
|
||||
)
|
||||
|
@ -7,69 +7,70 @@ MAVEN_CENTRAL = "MAVEN_CENTRAL:"
|
||||
MAVEN_LOCAL = "MAVEN_LOCAL:"
|
||||
|
||||
def _maven_release(ctx, parts):
|
||||
"""induce jar and url name from maven coordinates."""
|
||||
if len(parts) not in [3, 4]:
|
||||
fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"'
|
||||
% ctx.attr.artifact)
|
||||
if len(parts) == 4:
|
||||
group, artifact, version, classifier = parts
|
||||
file_version = version + '-' + classifier
|
||||
else:
|
||||
group, artifact, version = parts
|
||||
file_version = version
|
||||
"""induce jar and url name from maven coordinates."""
|
||||
if len(parts) not in [3, 4]:
|
||||
fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' %
|
||||
ctx.attr.artifact)
|
||||
if len(parts) == 4:
|
||||
group, artifact, version, classifier = parts
|
||||
file_version = version + "-" + classifier
|
||||
else:
|
||||
group, artifact, version = parts
|
||||
file_version = version
|
||||
|
||||
jar = artifact.lower() + '-' + file_version
|
||||
url = '/'.join([
|
||||
ctx.attr.repository,
|
||||
group.replace('.', '/'),
|
||||
artifact,
|
||||
version,
|
||||
artifact + '-' + file_version])
|
||||
jar = artifact.lower() + "-" + file_version
|
||||
url = "/".join([
|
||||
ctx.attr.repository,
|
||||
group.replace(".", "/"),
|
||||
artifact,
|
||||
version,
|
||||
artifact + "-" + file_version,
|
||||
])
|
||||
|
||||
return jar, url
|
||||
return jar, url
|
||||
|
||||
# Creates a struct containing the different parts of an artifact's FQN
|
||||
def _create_coordinates(fully_qualified_name):
|
||||
parts = fully_qualified_name.split(":")
|
||||
packaging = None
|
||||
classifier = None
|
||||
parts = fully_qualified_name.split(":")
|
||||
packaging = None
|
||||
classifier = None
|
||||
|
||||
if len(parts) == 3:
|
||||
group_id, artifact_id, version = parts
|
||||
elif len(parts) == 4:
|
||||
group_id, artifact_id, version, packaging = parts
|
||||
elif len(parts) == 5:
|
||||
group_id, artifact_id, version, packaging, classifier = parts
|
||||
else:
|
||||
fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name)
|
||||
if len(parts) == 3:
|
||||
group_id, artifact_id, version = parts
|
||||
elif len(parts) == 4:
|
||||
group_id, artifact_id, version, packaging = parts
|
||||
elif len(parts) == 5:
|
||||
group_id, artifact_id, version, packaging, classifier = parts
|
||||
else:
|
||||
fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name)
|
||||
|
||||
return struct(
|
||||
fully_qualified_name = fully_qualified_name,
|
||||
group_id = group_id,
|
||||
artifact_id = artifact_id,
|
||||
packaging = packaging,
|
||||
classifier = classifier,
|
||||
version = version,
|
||||
)
|
||||
return struct(
|
||||
fully_qualified_name = fully_qualified_name,
|
||||
group_id = group_id,
|
||||
artifact_id = artifact_id,
|
||||
packaging = packaging,
|
||||
classifier = classifier,
|
||||
version = version,
|
||||
)
|
||||
|
||||
def _format_deps(attr, deps):
|
||||
formatted_deps = ""
|
||||
if deps:
|
||||
if len(deps) == 1:
|
||||
formatted_deps += "%s = [\'%s\']," % (attr, deps[0])
|
||||
else:
|
||||
formatted_deps += "%s = [\n" % attr
|
||||
for dep in deps:
|
||||
formatted_deps += " \'%s\',\n" % dep
|
||||
formatted_deps += " ],"
|
||||
return formatted_deps
|
||||
formatted_deps = ""
|
||||
if deps:
|
||||
if len(deps) == 1:
|
||||
formatted_deps += "%s = [\'%s\']," % (attr, deps[0])
|
||||
else:
|
||||
formatted_deps += "%s = [\n" % attr
|
||||
for dep in deps:
|
||||
formatted_deps += " \'%s\',\n" % dep
|
||||
formatted_deps += " ],"
|
||||
return formatted_deps
|
||||
|
||||
def _generate_build_files(ctx, binjar, srcjar):
|
||||
header = "# DO NOT EDIT: automatically generated BUILD file for maven_jar rule %s" % ctx.name
|
||||
srcjar_attr = ""
|
||||
if srcjar:
|
||||
srcjar_attr = 'srcjar = "%s",' % srcjar
|
||||
contents = """
|
||||
header = "# DO NOT EDIT: automatically generated BUILD file for maven_jar rule %s" % ctx.name
|
||||
srcjar_attr = ""
|
||||
if srcjar:
|
||||
srcjar_attr = 'srcjar = "%s",' % srcjar
|
||||
contents = """
|
||||
{header}
|
||||
package(default_visibility = ['//visibility:public'])
|
||||
java_import(
|
||||
@ -86,22 +87,24 @@ java_import(
|
||||
{deps}
|
||||
{exports}
|
||||
)
|
||||
\n""".format(srcjar_attr = srcjar_attr,
|
||||
header = header,
|
||||
binjar = binjar,
|
||||
deps = _format_deps("deps", ctx.attr.deps),
|
||||
exports = _format_deps("exports", ctx.attr.exports))
|
||||
if srcjar:
|
||||
contents += """
|
||||
\n""".format(
|
||||
srcjar_attr = srcjar_attr,
|
||||
header = header,
|
||||
binjar = binjar,
|
||||
deps = _format_deps("deps", ctx.attr.deps),
|
||||
exports = _format_deps("exports", ctx.attr.exports),
|
||||
)
|
||||
if srcjar:
|
||||
contents += """
|
||||
java_import(
|
||||
name = 'src',
|
||||
jars = ['{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
|
||||
contents = """
|
||||
# Compatibility layer for java_import_external from rules_closure
|
||||
contents = """
|
||||
{header}
|
||||
package(default_visibility = ['//visibility:public'])
|
||||
|
||||
@ -110,52 +113,53 @@ alias(
|
||||
actual = "@{rule_name}//jar",
|
||||
)
|
||||
\n""".format(rule_name = ctx.name, header = header)
|
||||
ctx.file("BUILD", contents, False)
|
||||
ctx.file("BUILD", contents, False)
|
||||
|
||||
def _maven_jar_impl(ctx):
|
||||
"""rule to download a Maven archive."""
|
||||
coordinates = _create_coordinates(ctx.attr.artifact)
|
||||
"""rule to download a Maven archive."""
|
||||
coordinates = _create_coordinates(ctx.attr.artifact)
|
||||
|
||||
name = ctx.name
|
||||
sha1 = ctx.attr.sha1
|
||||
name = ctx.name
|
||||
sha1 = ctx.attr.sha1
|
||||
|
||||
parts = ctx.attr.artifact.split(':')
|
||||
# TODO(davido): Only releases for now, implement handling snapshots
|
||||
jar, url = _maven_release(ctx, parts)
|
||||
parts = ctx.attr.artifact.split(":")
|
||||
|
||||
binjar = jar + '.jar'
|
||||
binjar_path = ctx.path('/'.join(['jar', binjar]))
|
||||
binurl = url + '.jar'
|
||||
# TODO(davido): Only releases for now, implement handling snapshots
|
||||
jar, url = _maven_release(ctx, parts)
|
||||
|
||||
python = ctx.which("python")
|
||||
script = ctx.path(ctx.attr._download_script)
|
||||
binjar = jar + ".jar"
|
||||
binjar_path = ctx.path("/".join(["jar", binjar]))
|
||||
binurl = url + ".jar"
|
||||
|
||||
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])
|
||||
python = ctx.which("python")
|
||||
script = ctx.path(ctx.attr._download_script)
|
||||
|
||||
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)
|
||||
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(
|
||||
attrs = {
|
||||
|
@ -32,92 +32,92 @@ PGMLIBS = [
|
||||
]
|
||||
|
||||
def _add_context(in_file, output):
|
||||
input_path = in_file.path
|
||||
return [
|
||||
'unzip -qd %s %s' % (output, input_path)
|
||||
]
|
||||
input_path = in_file.path
|
||||
return [
|
||||
"unzip -qd %s %s" % (output, input_path),
|
||||
]
|
||||
|
||||
def _add_file(in_file, output):
|
||||
output_path = output
|
||||
input_path = in_file.path
|
||||
short_path = in_file.short_path
|
||||
n = in_file.basename
|
||||
output_path = output
|
||||
input_path = in_file.path
|
||||
short_path = in_file.short_path
|
||||
n = in_file.basename
|
||||
|
||||
if short_path.startswith('gerrit-'):
|
||||
n = short_path.split('/')[0] + '-' + n
|
||||
if short_path.startswith("gerrit-"):
|
||||
n = short_path.split("/")[0] + "-" + n
|
||||
|
||||
output_path += n
|
||||
return [
|
||||
'test -L %s || ln -s $(pwd)/%s %s' % (output_path, input_path, output_path)
|
||||
]
|
||||
output_path += n
|
||||
return [
|
||||
"test -L %s || ln -s $(pwd)/%s %s" % (output_path, input_path, output_path),
|
||||
]
|
||||
|
||||
def _make_war(input_dir, output):
|
||||
return '(%s)' % ' && '.join([
|
||||
'root=$(pwd)',
|
||||
'TZ=UTC',
|
||||
'export TZ',
|
||||
'cd %s' % input_dir,
|
||||
"find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
|
||||
'zip -X -9qr ${root}/%s .' % (output.path),
|
||||
])
|
||||
return "(%s)" % " && ".join([
|
||||
"root=$(pwd)",
|
||||
"TZ=UTC",
|
||||
"export TZ",
|
||||
"cd %s" % input_dir,
|
||||
"find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
|
||||
"zip -X -9qr ${root}/%s ." % (output.path),
|
||||
])
|
||||
|
||||
def _war_impl(ctx):
|
||||
war = ctx.outputs.war
|
||||
build_output = war.path + '.build_output'
|
||||
inputs = []
|
||||
war = ctx.outputs.war
|
||||
build_output = war.path + ".build_output"
|
||||
inputs = []
|
||||
|
||||
# Create war layout
|
||||
cmd = [
|
||||
'set -e;rm -rf ' + build_output,
|
||||
'mkdir -p ' + build_output,
|
||||
'mkdir -p %s/WEB-INF/lib' % build_output,
|
||||
'mkdir -p %s/WEB-INF/pgm-lib' % build_output,
|
||||
]
|
||||
# Create war layout
|
||||
cmd = [
|
||||
"set -e;rm -rf " + build_output,
|
||||
"mkdir -p " + build_output,
|
||||
"mkdir -p %s/WEB-INF/lib" % build_output,
|
||||
"mkdir -p %s/WEB-INF/pgm-lib" % build_output,
|
||||
]
|
||||
|
||||
# Add lib
|
||||
transitive_lib_deps = depset()
|
||||
for l in ctx.attr.libs:
|
||||
if hasattr(l, 'java'):
|
||||
transitive_lib_deps += l.java.transitive_runtime_deps
|
||||
elif hasattr(l, 'files'):
|
||||
transitive_lib_deps += l.files
|
||||
# Add lib
|
||||
transitive_lib_deps = depset()
|
||||
for l in ctx.attr.libs:
|
||||
if hasattr(l, "java"):
|
||||
transitive_lib_deps += l.java.transitive_runtime_deps
|
||||
elif hasattr(l, "files"):
|
||||
transitive_lib_deps += l.files
|
||||
|
||||
for dep in transitive_lib_deps:
|
||||
cmd += _add_file(dep, build_output + '/WEB-INF/lib/')
|
||||
inputs.append(dep)
|
||||
for dep in transitive_lib_deps:
|
||||
cmd += _add_file(dep, build_output + "/WEB-INF/lib/")
|
||||
inputs.append(dep)
|
||||
|
||||
# Add pgm lib
|
||||
transitive_pgmlib_deps = depset()
|
||||
for l in ctx.attr.pgmlibs:
|
||||
transitive_pgmlib_deps += l.java.transitive_runtime_deps
|
||||
# Add pgm lib
|
||||
transitive_pgmlib_deps = depset()
|
||||
for l in ctx.attr.pgmlibs:
|
||||
transitive_pgmlib_deps += l.java.transitive_runtime_deps
|
||||
|
||||
for dep in transitive_pgmlib_deps:
|
||||
if dep not in inputs:
|
||||
cmd += _add_file(dep, build_output + '/WEB-INF/pgm-lib/')
|
||||
inputs.append(dep)
|
||||
for dep in transitive_pgmlib_deps:
|
||||
if dep not in inputs:
|
||||
cmd += _add_file(dep, build_output + "/WEB-INF/pgm-lib/")
|
||||
inputs.append(dep)
|
||||
|
||||
# Add context
|
||||
transitive_context_deps = depset()
|
||||
if ctx.attr.context:
|
||||
for jar in ctx.attr.context:
|
||||
if hasattr(jar, 'java'):
|
||||
transitive_context_deps += jar.java.transitive_runtime_deps
|
||||
elif hasattr(jar, 'files'):
|
||||
transitive_context_deps += jar.files
|
||||
for dep in transitive_context_deps:
|
||||
cmd += _add_context(dep, build_output)
|
||||
inputs.append(dep)
|
||||
# Add context
|
||||
transitive_context_deps = depset()
|
||||
if ctx.attr.context:
|
||||
for jar in ctx.attr.context:
|
||||
if hasattr(jar, "java"):
|
||||
transitive_context_deps += jar.java.transitive_runtime_deps
|
||||
elif hasattr(jar, "files"):
|
||||
transitive_context_deps += jar.files
|
||||
for dep in transitive_context_deps:
|
||||
cmd += _add_context(dep, build_output)
|
||||
inputs.append(dep)
|
||||
|
||||
# Add zip war
|
||||
cmd.append(_make_war(build_output, war))
|
||||
# Add zip war
|
||||
cmd.append(_make_war(build_output, war))
|
||||
|
||||
ctx.action(
|
||||
inputs = inputs,
|
||||
outputs = [war],
|
||||
mnemonic = 'WAR',
|
||||
command = '\n'.join(cmd),
|
||||
use_default_shell_env = True,
|
||||
)
|
||||
ctx.action(
|
||||
inputs = inputs,
|
||||
outputs = [war],
|
||||
mnemonic = "WAR",
|
||||
command = "\n".join(cmd),
|
||||
use_default_shell_env = True,
|
||||
)
|
||||
|
||||
# context: go to the root directory
|
||||
# libs: go to the WEB-INF/lib directory
|
||||
@ -132,25 +132,25 @@ _pkg_war = rule(
|
||||
implementation = _war_impl,
|
||||
)
|
||||
|
||||
def pkg_war(name, ui = 'ui_optdbg', context = [], doc = False, **kwargs):
|
||||
doc_ctx = []
|
||||
doc_lib = []
|
||||
ui_deps = []
|
||||
if ui == 'polygerrit' or ui == 'ui_optdbg' or ui == 'ui_optdbg_r':
|
||||
ui_deps.append('//polygerrit-ui/app:polygerrit_ui')
|
||||
if ui and ui != 'polygerrit':
|
||||
ui_deps.append('//gerrit-gwtui:%s' % ui)
|
||||
if doc:
|
||||
doc_ctx.append('//Documentation:html')
|
||||
doc_lib.append('//Documentation:index')
|
||||
def pkg_war(name, ui = "ui_optdbg", context = [], doc = False, **kwargs):
|
||||
doc_ctx = []
|
||||
doc_lib = []
|
||||
ui_deps = []
|
||||
if ui == "polygerrit" or ui == "ui_optdbg" or ui == "ui_optdbg_r":
|
||||
ui_deps.append("//polygerrit-ui/app:polygerrit_ui")
|
||||
if ui and ui != "polygerrit":
|
||||
ui_deps.append("//gerrit-gwtui:%s" % ui)
|
||||
if doc:
|
||||
doc_ctx.append("//Documentation:html")
|
||||
doc_lib.append("//Documentation:index")
|
||||
|
||||
_pkg_war(
|
||||
name = name,
|
||||
libs = LIBS + doc_lib,
|
||||
pgmlibs = PGMLIBS,
|
||||
context = doc_ctx + context + ui_deps + [
|
||||
'//gerrit-main:main_bin_deploy.jar',
|
||||
'//gerrit-war:webapp_assets',
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
_pkg_war(
|
||||
name = name,
|
||||
libs = LIBS + doc_lib,
|
||||
pgmlibs = PGMLIBS,
|
||||
context = doc_ctx + context + ui_deps + [
|
||||
"//gerrit-main:main_bin_deploy.jar",
|
||||
"//gerrit-war:webapp_assets",
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
|
@ -1,12 +1,12 @@
|
||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||
load(
|
||||
"//tools/bzl:gwt.bzl",
|
||||
"GWT_COMPILER_ARGS",
|
||||
"GWT_JVM_ARGS",
|
||||
"GWT_PLUGIN_DEPS",
|
||||
"GWT_PLUGIN_DEPS_NEVERLINK",
|
||||
"GWT_TRANSITIVE_DEPS",
|
||||
"GWT_COMPILER_ARGS",
|
||||
"PLUGIN_DEPS_NEVERLINK",
|
||||
"GWT_JVM_ARGS",
|
||||
"gwt_binary",
|
||||
)
|
||||
|
||||
@ -20,78 +20,80 @@ PLUGIN_TEST_DEPS = [
|
||||
]
|
||||
|
||||
def gerrit_plugin(
|
||||
name,
|
||||
deps = [],
|
||||
provided_deps = [],
|
||||
srcs = [],
|
||||
gwt_module = [],
|
||||
resources = [],
|
||||
manifest_entries = [],
|
||||
target_suffix = "",
|
||||
**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]
|
||||
|
||||
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:
|
||||
name,
|
||||
deps = [],
|
||||
provided_deps = [],
|
||||
srcs = [],
|
||||
gwt_module = [],
|
||||
resources = [],
|
||||
manifest_entries = [],
|
||||
target_suffix = "",
|
||||
**kwargs):
|
||||
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,
|
||||
name = name + "__plugin",
|
||||
srcs = srcs,
|
||||
resources = resources,
|
||||
deps = provided_deps + deps + GWT_PLUGIN_DEPS_NEVERLINK + PLUGIN_DEPS_NEVERLINK,
|
||||
visibility = ["//visibility:public"],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# 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)" % 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'],
|
||||
)
|
||||
static_jars = []
|
||||
if gwt_module:
|
||||
static_jars = [":%s-static" % 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(
|
||||
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)" % 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"],
|
||||
)
|
||||
|
@ -25,73 +25,86 @@ sh_bang_template = (" && ".join([
|
||||
]))
|
||||
|
||||
def maven_package(
|
||||
version,
|
||||
repository = None,
|
||||
url = None,
|
||||
jar = {},
|
||||
src = {},
|
||||
doc = {},
|
||||
war = {}):
|
||||
version,
|
||||
repository = None,
|
||||
url = None,
|
||||
jar = {},
|
||||
src = {},
|
||||
doc = {},
|
||||
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(
|
||||
name = 'gen_api_deploy',
|
||||
cmd = sh_bang_template % (
|
||||
' '.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,
|
||||
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,
|
||||
)
|
||||
|
||||
war_cmd = mvn_cmd[:]
|
||||
war_targets = []
|
||||
for a,t in sorted(war.items()):
|
||||
war_cmd.append('-s %s:war:$(location %s)' % (a,t))
|
||||
war_targets.append(t)
|
||||
if repository and url:
|
||||
native.genrule(
|
||||
name = "gen_api_deploy",
|
||||
cmd = sh_bang_template % (
|
||||
" ".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(
|
||||
name = 'gen_war_install',
|
||||
cmd = sh_bang_template % (' '.join(build_cmd + war_targets),
|
||||
' '.join(war_cmd + ['-a', 'install'])),
|
||||
srcs = war_targets,
|
||||
outs = ['war_install.sh'],
|
||||
executable = True,
|
||||
)
|
||||
war_cmd = mvn_cmd[:]
|
||||
war_targets = []
|
||||
for a, t in sorted(war.items()):
|
||||
war_cmd.append("-s %s:war:$(location %s)" % (a, t))
|
||||
war_targets.append(t)
|
||||
|
||||
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,
|
||||
name = "gen_war_install",
|
||||
cmd = sh_bang_template % (
|
||||
" ".join(build_cmd + war_targets),
|
||||
" ".join(war_cmd + ["-a", "install"]),
|
||||
),
|
||||
srcs = war_targets,
|
||||
outs = ["war_install.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,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user