aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_rules
diff options
context:
space:
mode:
authorGravatar Michael Zhou <zhoumotongxue008@gmail.com>2016-02-17 22:15:13 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-02-17 22:54:10 +0000
commit650533fffccb97910338f335939de76922c9f679 (patch)
treeeda60de6bd6065466416aa3706a6fd1b2337529f /tools/build_rules
parent5854a721e9aa833965ce7de63f52dca87025a6b2 (diff)
Update Closure Tools dependencies and add arguments to closure_js_binary()
Update Closure Compiler to v20160208 Update Closure Library to v20160208 Update Closure Stylesheets to 1.1.0 Add "--language_in" and "--language_out" to closure_js_binary.bzl With these flags users can transpile their closure_js_binary() from ES6 to ES3. Change "--manage_closure_dependencies" to "--dependency_mode=LOOSE" because the former has been deprecated in Closure Compiler v20160208. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/910 MOS_MIGRATED_REVID=114898222
Diffstat (limited to 'tools/build_rules')
-rw-r--r--tools/build_rules/closure/closure_js_binary.bzl35
-rw-r--r--tools/build_rules/closure/closure_repositories.bzl14
2 files changed, 41 insertions, 8 deletions
diff --git a/tools/build_rules/closure/closure_js_binary.bzl b/tools/build_rules/closure/closure_js_binary.bzl
index 89af6721d4..447dd09cee 100644
--- a/tools/build_rules/closure/closure_js_binary.bzl
+++ b/tools/build_rules/closure/closure_js_binary.bzl
@@ -27,6 +27,8 @@ Example:
closure_js_binary(
name = "hello",
compilation_level = "simple",
+ language_in = "ecmascript6",
+ language_out = "ecmascript3",
externs = ["//third_party/javascript/google_cast/cast.js"],
deps = [
"@closure_library//:closure_library",
@@ -46,6 +48,21 @@ _COMPILATION_LEVELS = {
"advanced": ["--compilation_level=ADVANCED"]
}
+_SUPPORTED_LANGUAGES = {
+ "es3": ["ES3"],
+ "ecmascript3": ["ECMASCRIPT3"],
+ "es5": ["ES5"],
+ "ecmascript5": ["ECMASCRIPT5"],
+ "es5_strict": ["ES5_STRICT"],
+ "ecmascript5_strict": ["ECMASCRIPT5_STRICT"],
+ "es6": ["ES6"],
+ "ecmascript6": ["ECMASCRIPT6"],
+ "es6_strict": ["ES6_STRICT"],
+ "ecmascript6_strict": ["ECMASCRIPT6_STRICT"],
+ "es6_typed": ["ES6_TYPED"],
+ "ecmascript6_typed": ["ECMASCRIPT6_TYPED"],
+}
+
def _impl(ctx):
externs = set(order="compile")
srcs = set(order="compile")
@@ -57,7 +74,7 @@ def _impl(ctx):
"--closure_entry_point=%s" % ctx.attr.main,
"--js_output_file=%s" % ctx.outputs.out.path,
"--language_in=ECMASCRIPT5_STRICT",
- "--manage_closure_dependencies",
+ "--dependency_mode=LOOSE",
"--warning_level=VERBOSE",
] + (["--js=%s" % src.path for src in srcs] +
["--externs=%s" % extern.path for extern in externs])
@@ -69,6 +86,20 @@ def _impl(ctx):
fail("Invalid compilation_level '%s', expected one of %s" %
(ctx.attr.compilation_level, _COMPILATION_LEVELS.keys()))
+ # Set the language in.
+ if ctx.attr.language_in in _SUPPORTED_LANGUAGES:
+ args += "--language_in=" + _SUPPORTED_LANGUAGES[ctx.attr.language_in]
+ else:
+ fail("Invalid language_in '%s', expected one of %s" %
+ (ctx.attr.language_in, _SUPPORTED_LANGUAGES.keys()))
+
+ # Set the language out.
+ if ctx.attr.language_out in _SUPPORTED_LANGUAGES:
+ args += "--language_out=" + _SUPPORTED_LANGUAGES[ctx.attr.language_out]
+ else:
+ fail("Invalid language_out '%s', expected one of %s" %
+ (ctx.attr.language_out, _SUPPORTED_LANGUAGES.keys()))
+
ctx.action(
inputs=list(srcs) + list(externs),
outputs=[ctx.outputs.out],
@@ -85,6 +116,8 @@ closure_js_binary = rule(
providers=["transitive_js_externs", "transitive_js_srcs"]),
"main": attr.string(default="%{name}"),
"compilation_level": attr.string(default="advanced"),
+ "language_in": attr.string(default="ecmascript6"),
+ "language_out": attr.string(default="ecmascript3"),
"_closure_compiler": attr.label(
default=Label("//external:closure_compiler_"),
executable=True),
diff --git a/tools/build_rules/closure/closure_repositories.bzl b/tools/build_rules/closure/closure_repositories.bzl
index 29ab5f1a53..56c12996dd 100644
--- a/tools/build_rules/closure/closure_repositories.bzl
+++ b/tools/build_rules/closure/closure_repositories.bzl
@@ -79,21 +79,21 @@ def closure_repositories():
native.new_http_archive(
name = "closure_compiler",
build_file_content = CLOSURE_COMPILER_BUILD_FILE,
- sha256 = "e4e0cb49ad21ec26dd47693bdbd48f67aefe2d94fe8d9239312d2bcc74986538",
- url = "http://dl.google.com/closure-compiler/compiler-20150729.zip",
+ sha256 = "215ba5df026e5d92bda6634463a9c634d38a1aa4b6dab336da5c52e884cbde95",
+ url = "https://dl.google.com/closure-compiler/compiler-latest.zip",
)
- native.new_git_repository(
+ native.new_http_archive(
name = "closure_library",
build_file_content = CLOSURE_LIBRARY_BUILD_FILE,
- commit = "748b32441093c1474db2e0b3d074250e0bc47778",
- remote = "https://github.com/google/closure-library.git",
+ sha256 = "8f610300e4930190137505a574a54d12346426f2a7b4f179026e41674e452a86",
+ url = "https://github.com/google/closure-library/archive/20160208.zip",
)
native.http_jar(
name = "closure_stylesheets",
- sha256 = "8b2ae8ec3733171ec0c2e6536566df0b3c6da3e59b4784993bc9e73125d29c82",
- url = "https://closure-stylesheets.googlecode.com/files/closure-stylesheets-20111230.jar",
+ sha256 = "5308cb46f7677b9995237ade57770d27592aff69359d29be571220a2bf10e724",
+ url = "https://github.com/google/closure-stylesheets/releases/download/v1.1.0/closure-stylesheets.jar",
)
native.new_http_archive(