Format .bzl files with Bazel Buildifier
Change-Id: I3ab30565e5ac110a18cbe3d34f76307801c30373
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl
index df68e62..1aa9d5b 100644
--- a/tools/bzl/js.bzl
+++ b/tools/bzl/js.bzl
@@ -1,23 +1,22 @@
NPMJS = "NPMJS"
+
GERRIT = "GERRIT:"
NPM_VERSIONS = {
- "bower": '1.7.9',
- 'crisper': '2.0.2',
- 'vulcanize': '1.14.8',
+ "bower": "1.7.9",
+ "crisper": "2.0.2",
+ "vulcanize": "1.14.8",
}
NPM_SHA1S = {
- "bower": 'b7296c2393e0d75edaa6ca39648132dd255812b0',
- "crisper": '7183c58cea33632fb036c91cefd1b43e390d22a2',
- 'vulcanize': '679107f251c19ab7539529b1e3fdd40829e6fc63',
+ "bower": "b7296c2393e0d75edaa6ca39648132dd255812b0",
+ "crisper": "7183c58cea33632fb036c91cefd1b43e390d22a2",
+ "vulcanize": "679107f251c19ab7539529b1e3fdd40829e6fc63",
}
-
def _npm_tarball(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
@@ -47,14 +46,14 @@
ctx.file("BUILD", "package(default_visibility=['//visibility:public'])\nfilegroup(name='tarball', srcs=['%s'])" % base, False)
npm_binary = repository_rule(
- implementation=_npm_binary_impl,
- local=True,
- attrs={
- # Label resolves within repo of the .bzl file.
- "_download_script": attr.label(default=Label("//tools:download_file.py")),
- "repository": attr.string(default=NPMJS),
- })
-
+ attrs = {
+ # Label resolves within repo of the .bzl file.
+ "_download_script": attr.label(default = Label("//tools:download_file.py")),
+ "repository": attr.string(default = NPMJS),
+ },
+ local = True,
+ implementation = _npm_binary_impl,
+)
# for use in repo rules.
def _run_npm_binary_str(ctx, tarball, args):
@@ -64,7 +63,6 @@
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
@@ -106,26 +104,24 @@
"filegroup(name = 'version_json', srcs = ['%s'], visibility=['//visibility:public'])" % version_name,
]), False)
-
def _bash(ctx, cmd):
cmd_list = ["/bin/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,
- attrs={
- "_bower_archive": attr.label(default=Label("@bower//:%s" % _npm_tarball("bower"))),
- "_run_npm": attr.label(default=Label("//tools/js:run_npm_binary.py")),
- "_download_bower": attr.label(default=Label("//tools/js:download_bower.py")),
- "sha1": attr.string(mandatory=True),
- "version": attr.string(mandatory=True),
- "package": attr.string(mandatory=True),
- "semver": attr.string(),
- })
-
+bower_archive = repository_rule(
+ _bower_archive,
+ attrs = {
+ "_bower_archive": attr.label(default = Label("@bower//:%s" % _npm_tarball("bower"))),
+ "_run_npm": attr.label(default = Label("//tools/js:run_npm_binary.py")),
+ "_download_bower": attr.label(default = Label("//tools/js:download_bower.py")),
+ "sha1": attr.string(mandatory = True),
+ "version": attr.string(mandatory = True),
+ "package": attr.string(mandatory = True),
+ "semver": attr.string(),
+ },
+)
def _bower_component_impl(ctx):
transitive_zipfiles = set([ctx.file.zipfile])
@@ -149,15 +145,13 @@
transitive_licenses=transitive_licenses,
)
-
_common_attrs = {
- "deps": attr.label_list(providers=[
- "transitive_zipfiles",
- "transitive_versions",
- "transitive_licenses",
- ])
- }
-
+ "deps": attr.label_list(providers = [
+ "transitive_zipfiles",
+ "transitive_versions",
+ "transitive_licenses",
+ ]),
+}
def _js_component(ctx):
dir = ctx.outputs.zip.path + ".dir"
@@ -188,31 +182,28 @@
transitive_versions=set([]),
transitive_licenses=licenses)
-
js_component = rule(
- _js_component,
- attrs=_common_attrs + {
- "srcs": attr.label_list(allow_files=[".js"]),
- "license": attr.label(allow_single_file=True),
- },
- outputs={
- "zip": "%{name}.zip",
- }
+ _js_component,
+ attrs = _common_attrs + {
+ "srcs": attr.label_list(allow_files = [".js"]),
+ "license": attr.label(allow_single_file = True),
+ },
+ outputs = {
+ "zip": "%{name}.zip",
+ },
)
-
_bower_component = rule(
- _bower_component_impl,
- attrs=_common_attrs + {
- "zipfile": attr.label(allow_single_file=[".zip"]),
- "license": attr.label(allow_single_file=True),
- "version_json": attr.label(allow_files=[".json"]),
+ _bower_component_impl,
+ attrs = _common_attrs + {
+ "zipfile": attr.label(allow_single_file = [".zip"]),
+ "license": attr.label(allow_single_file = True),
+ "version_json": attr.label(allow_files = [".json"]),
- # If set, define by hand, and don't regenerate this entry in bower2bazel.
- "seed": attr.bool(default=False)
- })
-
-
+ # If set, define by hand, and don't regenerate this entry in bower2bazel.
+ "seed": attr.bool(default = False),
+ },
+)
# TODO(hanwen): make license mandatory.
def bower_component(name, license=None, **kwargs):
@@ -226,7 +217,6 @@
version_json="@%s//:version_json" % name,
**kwargs)
-
def _bower_component_bundle_impl(ctx):
"""A bunch of bower components zipped up."""
zips = set([])
@@ -270,14 +260,13 @@
transitive_versions=versions,
transitive_licenses=licenses)
-
bower_component_bundle = rule(
- _bower_component_bundle_impl,
- attrs=_common_attrs,
- outputs={
- "zip": "%{name}.zip",
- "version_json": "%{name}-versions.json",
- }
+ _bower_component_bundle_impl,
+ attrs = _common_attrs,
+ outputs = {
+ "zip": "%{name}.zip",
+ "version_json": "%{name}-versions.json",
+ },
)
def _vulcanize_impl(ctx):
@@ -345,33 +334,39 @@
command = hermetic_npm_command,
**node_tweaks)
-
-
_vulcanize_rule = rule(
- _vulcanize_impl,
- attrs = {
- "deps": attr.label_list(providers=["transitive_zipfiles"]),
- "app": attr.label(mandatory=True, allow_single_file=True),
- "srcs": attr.label_list(allow_files=[".js", ".html", ".txt", ".css", ".ico"]),
-
- "pkg": attr.string(mandatory=True),
- "_run_npm": attr.label(
- default=Label("//tools/js:run_npm_binary.py"),
- allow_single_file=True
- ),
- "_vulcanize_archive": attr.label(
- default=Label("@vulcanize//:%s" % _npm_tarball("vulcanize")),
- allow_single_file=True
- ),
- "_crisper_archive": attr.label(
- default=Label("@crisper//:%s" % _npm_tarball("crisper")),
- allow_single_file=True
- ),
- },
- outputs = {
- "html": "%{name}.html",
- "js": "%{name}.js",
- }
+ _vulcanize_impl,
+ attrs = {
+ "deps": attr.label_list(providers = ["transitive_zipfiles"]),
+ "app": attr.label(
+ mandatory = True,
+ allow_single_file = True,
+ ),
+ "srcs": attr.label_list(allow_files = [
+ ".js",
+ ".html",
+ ".txt",
+ ".css",
+ ".ico",
+ ]),
+ "pkg": attr.string(mandatory = True),
+ "_run_npm": attr.label(
+ default = Label("//tools/js:run_npm_binary.py"),
+ allow_single_file = True,
+ ),
+ "_vulcanize_archive": attr.label(
+ default = Label("@vulcanize//:%s" % _npm_tarball("vulcanize")),
+ allow_single_file = True,
+ ),
+ "_crisper_archive": attr.label(
+ default = Label("@crisper//:%s" % _npm_tarball("crisper")),
+ allow_single_file = True,
+ ),
+ },
+ outputs = {
+ "html": "%{name}.html",
+ "js": "%{name}.js",
+ },
)
def vulcanize(*args, **kwargs):