diff --git a/WORKSPACE b/WORKSPACE index eb0da9a65..04daf34db 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,3 +3,19 @@ workspace(name = "domain_registry") load("//java/google/registry:repositories.bzl", "domain_registry_repositories") domain_registry_repositories() + +git_repository( + name = "io_bazel_rules_closure", + remote = "https://github.com/bazelbuild/rules_closure.git", + tag = "0.1.0", +) + +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") + +closure_repositories( + omit_gson = True, + omit_guava = True, + omit_icu4j = True, + omit_jsr305 = True, + omit_jsr330_inject = True, +) diff --git a/java/google/registry/repositories.bzl b/java/google/registry/repositories.bzl index f456c61d6..6c2028bb1 100644 --- a/java/google/registry/repositories.bzl +++ b/java/google/registry/repositories.bzl @@ -18,42 +18,6 @@ def domain_registry_repositories(): - native.maven_jar( - name = "aopalliance", - artifact = "aopalliance:aopalliance:1.0", - sha1 = "0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8", - ) - - native.maven_jar( - name = "asm", - artifact = "org.ow2.asm:asm:5.0.3", - sha1 = "dcc2193db20e19e1feca8b1240dbbc4e190824fa", - ) - - native.maven_jar( - name = "asm_analysis", - artifact = "org.ow2.asm:asm-analysis:5.0.3", - sha1 = "c7126aded0e8e13fed5f913559a0dd7b770a10f3", - ) - - native.maven_jar( - name = "asm_commons", - artifact = "org.ow2.asm:asm-commons:5.0.3", - sha1 = "a7111830132c7f87d08fe48cb0ca07630f8cb91c", - ) - - native.maven_jar( - name = "asm_util", - artifact = "org.ow2.asm:asm-util:5.0.3", - sha1 = "1512e5571325854b05fb1efce1db75fcced54389", - ) - - native.maven_jar( - name = "args4j", - artifact = "args4j:args4j:2.0.26", - sha1 = "01ebb18ebb3b379a74207d5af4ea7c8338ebd78b", - ) - native.maven_jar( name = "appengine_api_sdk", artifact = "com.google.appengine:appengine-api-1.0-sdk:1.9.30", @@ -168,26 +132,6 @@ def domain_registry_repositories(): sha1 = "80dd3b0d5591580c429b0e2529706f6be5bddc0f", ) - native.maven_jar( - name = "closure_compiler", - artifact = "com.google.javascript:closure-compiler:v20160208", - sha1 = "5a2f4be6cf41e27ed7119d26cb8f106300d87d91", - ) - - native.new_http_archive( - name = "closure_library", - build_file = "third_party/closure/library/closure_library.BUILD", - sha256 = "8f610300e4930190137505a574a54d12346426f2a7b4f179026e41674e452a86", - strip_prefix = "closure-library-20160208", - url = "https://github.com/google/closure-library/archive/20160208.zip", - ) - - native.maven_jar( - name = "closure_stylesheets", - artifact = "com.google.closure-stylesheets:closure-stylesheets:20160212", - sha1 = "f0e8625a2cfe0f501b28f5e6438b836358da8a97", - ) - native.maven_jar( name = "dagger", artifact = "com.google.dagger:dagger:2.4", @@ -326,24 +270,6 @@ def domain_registry_repositories(): sha1 = "ce5b880b206de3f76d364988a6308c68c726f74a", ) - native.maven_jar( - name = "guice", - artifact = "com.google.inject:guice:3.0", - sha1 = "9d84f15fe35e2c716a02979fb62f50a29f38aefa", - ) - - native.maven_jar( - name = "guice_assistedinject", - artifact = "com.google.inject.extensions:guice-assistedinject:3.0", - sha1 = "544449ddb19f088dcde44f055d30a08835a954a7", - ) - - native.maven_jar( - name = "guice_multibindings", - artifact = "com.google.inject.extensions:guice-multibindings:3.0", - sha1 = "5e670615a927571234df68a8b1fe1a16272be555", - ) - native.maven_jar( name = "hamcrest_core", artifact = "org.hamcrest:hamcrest-core:1.3", @@ -488,14 +414,6 @@ def domain_registry_repositories(): sha1 = "79a8984096fc6591c1e3690e07d41be506356fa5", ) - # XXX: new_http_archive() doesn't maintain the executable bit. - # https://github.com/bazelbuild/bazel/issues/984 - native.http_file( - name = "phantomjs", - sha256 = "86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f", - url = "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2", - ) - native.maven_jar( name = "protobuf_java", artifact = "com.google.protobuf:protobuf-java:2.6.1", @@ -526,18 +444,6 @@ def domain_registry_repositories(): sha1 = "862a5bc736005d68727d1387844d09d62efdb6cb", ) - native.maven_jar( - name = "soy", - artifact = "com.google.template:soy:2016-01-12", - sha1 = "adadc37aecf1042de7c9c6a6eb8f34719500ed69", - ) - - native.http_file( - name = "soyutils_usegoog", - sha256 = "fdb0e318949c1af668038df1d85d45353a00ff585f321c86efe91ac2a10cc91f", - url = "https://repo1.maven.org/maven2/com/google/template/soy/2016-01-12/soy-2016-01-12-soyutils_usegoog.js", - ) - native.maven_jar( name = "sshd_core", artifact = "org.apache.sshd:sshd-core:0.7.0", diff --git a/java/google/registry/tools/BUILD b/java/google/registry/tools/BUILD index b41ceb15d..9e2e3715d 100644 --- a/java/google/registry/tools/BUILD +++ b/java/google/registry/tools/BUILD @@ -78,7 +78,7 @@ java_library( "//third_party/java/appengine:appengine-remote-api", - "//third_party/closure/templates", + "@io_bazel_rules_closure//closure/templates", ], ) diff --git a/java/google/registry/tools/soy/BUILD b/java/google/registry/tools/soy/BUILD index b5b39d2a4..49a0af03f 100644 --- a/java/google/registry/tools/soy/BUILD +++ b/java/google/registry/tools/soy/BUILD @@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/templates:closure_template_java_library.bzl", "closure_template_java_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_template_java_library") closure_template_java_library( diff --git a/java/google/registry/ui/BUILD b/java/google/registry/ui/BUILD index 11b5c51aa..93c759887 100644 --- a/java/google/registry/ui/BUILD +++ b/java/google/registry/ui/BUILD @@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/compiler:closure_js_binary.bzl", "closure_js_binary") -load("//third_party/closure/compiler:closure_js_deps.bzl", "closure_js_deps") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_deps") exports_files(["globals.txt"]) @@ -34,7 +33,7 @@ filegroup( ":assets_recursive", "//javascript/closure:js_files_recursive", "//javascript/template/soy:soy_usegoog_js_files", - "//java/google/registry/ui:deps-runfiles.js", + "//java/google/registry/ui:deps.js", "//java/google/registry/ui/css:registrar_bin.css", "//java/google/registry/ui/html:html_files", ], @@ -43,13 +42,14 @@ filegroup( filegroup( name = "runfiles_debug", srcs = [ - "deps-runfiles.js", - ":js_files_recursive", + "@closure_library//:js_files", + "brain_bin.js.map", + "deps.js", + "registrar_bin.js.map", ":runfiles", "//javascript/closure:js_files_recursive", "//javascript/template/soy:soy_usegoog_js_files", "//java/google/registry/ui/css:css_files", - "//third_party/javascript/closure:js_files_recursive", ], ) @@ -68,19 +68,12 @@ java_library( closure_js_deps( name = "deps", - srcs = [ + deps = [ "//java/google/registry/ui/js", "//java/google/registry/ui/js/registrar", ], ) -SOURCEMAP_SCRUB = (" -e 's@b....-out/[^/]*/bin/@@g'" + - " -e 's@b....-out/[^/]*/genfiles/@@g'" + - " -e 's@\"java/@\"/assets/sources/java/@g'" + - " -e 's@\"javascript/@\"/assets/sources/javascript/@g'" + - " -e 's@\"third_party/@\"/assets/sources/third_party/@g'" + - " -e 's@\"external/@\"/assets/sources/external/@g'") - ################################################################################ ## Registrar Console @@ -91,23 +84,14 @@ SOURCEMAP_SCRUB = (" -e 's@b....-out/[^/]*/bin/@@g'" + # non-union minified equivalents. closure_js_binary( name = "registrar_bin", - externs_list = ["//java/google/registry/ui/externs"], - main = "registry.registrar.main", + css = "//java/google/registry/ui/css:registrar_bin", + entry_points = ["goog:registry.registrar.main"], deps = [ - "//java/google/registry/ui/css:registrar_bin", + "//java/google/registry/ui/externs", "//java/google/registry/ui/js/registrar", ], ) -# Mangle all the paths in the generated sourcemap so they're absolute; assuming -# the codebase is available under /assets/sources/. -genrule( - name = "registrar_bin_sourcemap", - srcs = ["registrar_bin.sourcemap"], - outs = ["registrar_bin.js.map"], - cmd = "sed $(location registrar_bin.sourcemap) " + SOURCEMAP_SCRUB + " >$@", -) - # The webserver should provide this to trusted admin users, rather than # registrar_bin.js. This is what makes debugging in production possible. genrule( @@ -125,12 +109,12 @@ genrule( # an extra underscore. closure_js_binary( name = "registrar_dbg", + css = "//java/google/registry/ui/css:registrar_dbg", debug = 1, - externs_list = ["//java/google/registry/ui/externs"], + entry_points = ["goog:registry.registrar.main"], formatting = "PRETTY_PRINT", - main = "registry.registrar.main", deps = [ - "//java/google/registry/ui/css:registrar_dbg", + "//java/google/registry/ui/externs", "//java/google/registry/ui/js/registrar", ], ) @@ -140,16 +124,11 @@ closure_js_binary( closure_js_binary( name = "brain_bin", - externs_list = ["//java/google/registry/ui/externs"], - main = "registry.registrar.BrainFrame.main", - deps = ["//java/google/registry/ui/js/registrar"], -) - -genrule( - name = "brain_bin_sourcemap", - srcs = ["brain_bin.sourcemap"], - outs = ["brain_bin.js.map"], - cmd = "sed $(location brain_bin.sourcemap) " + SOURCEMAP_SCRUB + " >$@", + entry_points = ["goog:registry.registrar.BrainFrame.main"], + deps = [ + "//java/google/registry/ui/externs", + "//java/google/registry/ui/js/registrar", + ], ) genrule( diff --git a/java/google/registry/ui/assets/html/insecure-brainframe.html b/java/google/registry/ui/assets/html/insecure-brainframe.html index 927b2077b..f00ebc4b1 100644 --- a/java/google/registry/ui/assets/html/insecure-brainframe.html +++ b/java/google/registry/ui/assets/html/insecure-brainframe.html @@ -2,8 +2,9 @@ + - +
diff --git a/java/google/registry/ui/css/BUILD b/java/google/registry/ui/css/BUILD index 12e0bf1e2..b94c26f03 100644 --- a/java/google/registry/ui/css/BUILD +++ b/java/google/registry/ui/css/BUILD @@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/stylesheets:closure_css_library.bzl", "closure_css_library") -load("//third_party/closure/stylesheets:closure_css_binary.bzl", "closure_css_binary") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_library", "closure_css_binary") filegroup( diff --git a/java/google/registry/ui/externs/BUILD b/java/google/registry/ui/externs/BUILD index e6a64b785..5bb12f4d4 100644 --- a/java/google/registry/ui/externs/BUILD +++ b/java/google/registry/ui/externs/BUILD @@ -2,10 +2,12 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") -filegroup( + +closure_js_library( name = "externs", - srcs = glob(["*.js"]), + externs = glob(["*.js"]), ) filegroup( diff --git a/java/google/registry/ui/js/BUILD b/java/google/registry/ui/js/BUILD index 8d8574e5d..2d2baf479 100644 --- a/java/google/registry/ui/js/BUILD +++ b/java/google/registry/ui/js/BUILD @@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") filegroup( diff --git a/java/google/registry/ui/js/registrar/BUILD b/java/google/registry/ui/js/registrar/BUILD index ac3512967..5544e2110 100644 --- a/java/google/registry/ui/js/registrar/BUILD +++ b/java/google/registry/ui/js/registrar/BUILD @@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") filegroup( diff --git a/java/google/registry/ui/server/BUILD b/java/google/registry/ui/server/BUILD index c11c2818a..20bb3b341 100644 --- a/java/google/registry/ui/server/BUILD +++ b/java/google/registry/ui/server/BUILD @@ -27,6 +27,6 @@ java_library( "//third_party/java/re2j", "//third_party/java/servlet/servlet_api", - "//third_party/closure/templates", + "@io_bazel_rules_closure//closure/templates", ], ) diff --git a/java/google/registry/ui/server/api/BUILD b/java/google/registry/ui/server/api/BUILD index 618e3f250..7736648e8 100644 --- a/java/google/registry/ui/server/api/BUILD +++ b/java/google/registry/ui/server/api/BUILD @@ -21,6 +21,6 @@ java_library( "//third_party/java/jsr305_annotations", "//third_party/java/servlet/servlet_api", - "//third_party/closure/templates", + "@io_bazel_rules_closure//closure/templates", ], ) diff --git a/java/google/registry/ui/server/registrar/BUILD b/java/google/registry/ui/server/registrar/BUILD index 880d433c9..4f92305ab 100644 --- a/java/google/registry/ui/server/registrar/BUILD +++ b/java/google/registry/ui/server/registrar/BUILD @@ -40,6 +40,6 @@ java_library( "//third_party/java/objectify:objectify-v4_1", "//third_party/java/servlet/servlet_api", - "//third_party/closure/templates", + "@io_bazel_rules_closure//closure/templates", ], ) diff --git a/java/google/registry/ui/soy/BUILD b/java/google/registry/ui/soy/BUILD index 6e661dbd6..427537250 100644 --- a/java/google/registry/ui/soy/BUILD +++ b/java/google/registry/ui/soy/BUILD @@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/templates:closure_template_java_library.bzl", "closure_template_java_library") -load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_template_java_library", "closure_template_js_library") filegroup( diff --git a/java/google/registry/ui/soy/api/BUILD b/java/google/registry/ui/soy/api/BUILD index 0dd96abd3..859800c5a 100644 --- a/java/google/registry/ui/soy/api/BUILD +++ b/java/google/registry/ui/soy/api/BUILD @@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/templates:closure_template_java_library.bzl", "closure_template_java_library") -load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_template_java_library", "closure_template_js_library") filegroup( diff --git a/java/google/registry/ui/soy/registrar/BUILD b/java/google/registry/ui/soy/registrar/BUILD index 3ef8aa903..8311b0785 100644 --- a/java/google/registry/ui/soy/registrar/BUILD +++ b/java/google/registry/ui/soy/registrar/BUILD @@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"]) licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/templates:closure_template_java_library.bzl", "closure_template_java_library") -load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_template_java_library", "closure_template_js_library") filegroup( diff --git a/java/google/registry/ui/soy/registrar/Console.soy b/java/google/registry/ui/soy/registrar/Console.soy index e03f753e9..ee42508ff 100644 --- a/java/google/registry/ui/soy/registrar/Console.soy +++ b/java/google/registry/ui/soy/registrar/Console.soy @@ -38,9 +38,10 @@ {case google.registry.ui.ConsoleDebug.DEBUG} {case google.registry.ui.ConsoleDebug.RAW} + - + {/switch} {if isNonnull(DEBUG)} diff --git a/javascript/closure/BUILD b/javascript/closure/BUILD index 3db395258..3ac45d365 100644 --- a/javascript/closure/BUILD +++ b/javascript/closure/BUILD @@ -1,10 +1,15 @@ package(default_visibility = ["//visibility:public"]) -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") closure_js_library( name = "closure", - exports = ["//third_party/closure/library"], + exports = ["@io_bazel_rules_closure//closure/library"], +) + +closure_js_library( + name = "testing", + exports = ["@io_bazel_rules_closure//closure/library:testing"], ) filegroup( diff --git a/javatests/google/registry/server/RegistryTestServer.java b/javatests/google/registry/server/RegistryTestServer.java index bcc70ef85..3dcd2b36c 100644 --- a/javatests/google/registry/server/RegistryTestServer.java +++ b/javatests/google/registry/server/RegistryTestServer.java @@ -33,8 +33,8 @@ public final class RegistryTestServer { .put("/error.html", Paths.get("java/google/registry/ui/html/error.html")) .put("/assets/js/*", Paths.get("java/google/registry/ui")) .put("/assets/css/*", Paths.get("java/google/registry/ui/css")) - .put("/assets/sources/deps-runfiles.js", - Paths.get("java/google/registry/ui/deps-runfiles.js")) + .put("/assets/sources/deps.js", + Paths.get("java/google/registry/ui/deps.js")) .put("/assets/sources/*", Paths.get("")) .put("/assets/*", Paths.get("java/google/registry/ui/assets")) .build(); diff --git a/javatests/google/registry/ui/js/BUILD b/javatests/google/registry/ui/js/BUILD index f83632c75..3271c8d15 100644 --- a/javatests/google/registry/ui/js/BUILD +++ b/javatests/google/registry/ui/js/BUILD @@ -5,14 +5,16 @@ package( licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") -load("//third_party/closure/testing:closure_js_test.bzl", "closure_js_test") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test") closure_js_library( name = "testing", srcs = ["testing.js"], - deps = ["//javascript/closure"], + deps = [ + "//javascript/closure", + "//javascript/closure:testing", + ], ) closure_js_test( diff --git a/javatests/google/registry/ui/js/registrar/BUILD b/javatests/google/registry/ui/js/registrar/BUILD index 68eadc6f6..7cc39fd2f 100644 --- a/javatests/google/registry/ui/js/registrar/BUILD +++ b/javatests/google/registry/ui/js/registrar/BUILD @@ -5,8 +5,7 @@ package( licenses(["notice"]) # Apache 2.0 -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") -load("//third_party/closure/testing:closure_js_test.bzl", "closure_js_test") +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test") closure_js_library( @@ -14,6 +13,7 @@ closure_js_library( srcs = ["console_test_util.js"], deps = [ "//javascript/closure", + "//javascript/closure:testing", "//java/google/registry/ui/js", "//java/google/registry/ui/js/registrar", ], diff --git a/third_party/closure/compiler/BUILD b/third_party/closure/compiler/BUILD deleted file mode 100644 index 25cda1d7c..000000000 --- a/third_party/closure/compiler/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache License 2.0 - -java_binary( - name = "compiler", - jvm_flags = ["-client"], - main_class = "com.google.javascript.jscomp.CommandLineRunner", - runtime_deps = ["@closure_compiler//jar"], -) diff --git a/third_party/closure/compiler/closure_js_binary.bzl b/third_party/closure/compiler/closure_js_binary.bzl deleted file mode 100644 index 21d1b25d0..000000000 --- a/third_party/closure/compiler/closure_js_binary.bzl +++ /dev/null @@ -1,96 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Rule for building JavaScript binaries with Closure Compiler. -""" - -load("//third_party/closure/compiler/private:defs.bzl", - "JS_LANGUAGE_DEFAULT", - "JS_LIBRARY_ATTRS", - "JS_PEDANTIC_ARGS", - "JS_HIDE_WARNING_ARGS", - "check_js_language", - "collect_js_srcs", - "determine_js_language", - "is_using_closure_library") - -def _impl(ctx): - srcs, externs = collect_js_srcs(ctx) - check_js_language(ctx.attr.language_in) - check_js_language(ctx.attr.language_out) - dependent_language = determine_js_language(ctx) - if ctx.attr.language_in != dependent_language: - fail("language_in was %s but dependencies use %s" % ( - ctx.attr.language_in, dependent_language)) - args = [ - "--js_output_file=%s" % ctx.outputs.out.path, - "--create_source_map=%s" % ctx.outputs.srcmap.path, - "--language_in=%s" % ctx.attr.language_in, - "--language_out=%s" % ctx.attr.language_out, - "--compilation_level=" + ctx.attr.compilation_level, - "--warning_level=VERBOSE", - "--new_type_inf", - "--generate_exports", - ] - args += JS_HIDE_WARNING_ARGS - if ctx.attr.formatting: - args += ["--formatting=" + ctx.attr.formatting] - if ctx.attr.debug: - args += ["--debug"] - else: - if is_using_closure_library(srcs): - args += ["--define=goog.DEBUG=false"] - if ctx.attr.main: - args += [ - "--dependency_mode=STRICT", - "--entry_point=goog:%s" % ctx.attr.main, - ] - else: - args += ["--dependency_mode=LOOSE"] - if ctx.attr.pedantic: - args += JS_PEDANTIC_ARGS - args += ["--use_types_for_optimization"] - args += ctx.attr.defs - args += ["--externs=%s" % extern.path for extern in externs] - args += ["--js=%s" % src.path for src in srcs] - ctx.action( - inputs=list(srcs) + list(externs), - outputs=[ctx.outputs.out, ctx.outputs.srcmap], - executable=ctx.executable._compiler, - arguments=args, - mnemonic="JSCompile", - progress_message="Compiling %d JavaScript files to %s" % ( - len(srcs) + len(externs), - ctx.outputs.out.short_path)) - return struct(files=set([ctx.outputs.out])) - -closure_js_binary = rule( - implementation=_impl, - attrs=JS_LIBRARY_ATTRS + { - "main": attr.string(), - "compilation_level": attr.string(default="ADVANCED"), - "defs": attr.string_list(), - "pedantic": attr.bool(default=False), - "debug": attr.bool(default=False), - "formatting": attr.string(), - "language_in": attr.string(default=JS_LANGUAGE_DEFAULT), - "language_out": attr.string(default="ECMASCRIPT3"), - "_compiler": attr.label( - default=Label("//third_party/closure/compiler"), - executable=True), - }, - outputs={"out": "%{name}.js", - "srcmap": "%{name}.sourcemap"}) diff --git a/third_party/closure/compiler/closure_js_check_test.bzl b/third_party/closure/compiler/closure_js_check_test.bzl deleted file mode 100644 index 1ef94cf78..000000000 --- a/third_party/closure/compiler/closure_js_check_test.bzl +++ /dev/null @@ -1,69 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Test rule for validating JavaScript types but not producing a compiled file. -""" - -load("//third_party/closure/compiler/private:defs.bzl", - "JS_LANGUAGE_DEFAULT", - "JS_LIBRARY_ATTRS", - "JS_PEDANTIC_ARGS", - "JS_HIDE_WARNING_ARGS", - "check_js_language", - "collect_js_srcs", - "determine_js_language", - "is_using_closure_library") - -def _impl(ctx): - srcs, externs = collect_js_srcs(ctx) - args = [ - "third_party/closure/compiler/compiler", - "--checks-only", - "--language_in=%s" % determine_js_language(ctx), - "--compilation_level=" + ctx.attr.compilation_level, - "--warning_level=VERBOSE", - "--new_type_inf", - ] - if is_using_closure_library(srcs): - args += ["--dependency_mode=LOOSE"] - if ctx.attr.pedantic: - args += JS_PEDANTIC_ARGS - args += JS_HIDE_WARNING_ARGS - args += ctx.attr.defs - args += ["--externs='%s'" % extern.path for extern in externs] - args += ["--js='%s'" % src.path for src in srcs] - ctx.file_action( - executable=True, - output=ctx.outputs.executable, - content="#!/bin/sh\nexec " + " \\\n ".join(args) + "\n") - return struct(files=set([ctx.outputs.executable]), - runfiles=ctx.runfiles( - files=list(srcs) + list(externs), - transitive_files=ctx.attr._compiler.data_runfiles.files, - collect_data=True)) - -closure_js_check_test = rule( - test=True, - implementation=_impl, - attrs=JS_LIBRARY_ATTRS + { - "compilation_level": attr.string(default="ADVANCED"), - "defs": attr.string_list(), - "pedantic": attr.bool(default=False), - "language": attr.string(default=JS_LANGUAGE_DEFAULT), - "_compiler": attr.label( - default=Label("//third_party/closure/compiler"), - executable=True), - }) diff --git a/third_party/closure/compiler/closure_js_deps.bzl b/third_party/closure/compiler/closure_js_deps.bzl deleted file mode 100644 index 51714c033..000000000 --- a/third_party/closure/compiler/closure_js_deps.bzl +++ /dev/null @@ -1,54 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Build definitions for JavaScript dependency files. - -Generating this file is important because the deps-runfiles.js file tells the -Closure Library how to send requests to the web server to load goog.require'd -namespaces. -""" - -load("//third_party/closure/compiler/private:defs.bzl", - "JS_FILE_TYPE", - "make_js_deps_runfiles") - -def _impl(ctx): - srcs = set(order="compile") - for src in ctx.attr.srcs: - srcs += src.transitive_js_srcs - ctx.action( - inputs=list(srcs), - outputs=[ctx.outputs.out], - arguments=(["--output_file=%s" % (ctx.outputs.out.path)] + - [src.path for src in srcs]), - executable=ctx.executable._depswriter, - progress_message="Calculating %d JavaScript deps to %s" % ( - len(srcs), ctx.outputs.out.short_path)) - make_js_deps_runfiles(ctx, srcs) - return struct(files=set([ctx.outputs.out, ctx.outputs.runfiles])) - -closure_js_deps = rule( - implementation=_impl, - attrs={ - "srcs": attr.label_list( - allow_files=False, - providers=["transitive_js_srcs"]), - "_depswriter": attr.label( - default=Label("@closure_library//:depswriter"), - executable=True), - }, - outputs={"out": "%{name}.js", - "runfiles": "%{name}-runfiles.js"}) diff --git a/third_party/closure/compiler/closure_js_library.bzl b/third_party/closure/compiler/closure_js_library.bzl deleted file mode 100644 index e4370cfd8..000000000 --- a/third_party/closure/compiler/closure_js_library.bzl +++ /dev/null @@ -1,40 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Build definitions for Closure JavaScript libraries. -""" - -load("//third_party/closure/compiler/private:defs.bzl", - "JS_LANGUAGE_DEFAULT", - "JS_DEPS_ATTR", - "JS_LIBRARY_ATTRS", - "collect_js_srcs", - "determine_js_language") - -def _impl(ctx): - srcs, externs = collect_js_srcs(ctx) - return struct(files=set(ctx.files.srcs), - js_language=determine_js_language(ctx), - js_exports=ctx.files.exports, - transitive_js_srcs=srcs, - transitive_js_externs=externs) - -closure_js_library = rule( - implementation=_impl, - attrs=JS_LIBRARY_ATTRS + { - "exports": JS_DEPS_ATTR, - "language": attr.string(default=JS_LANGUAGE_DEFAULT), - }) diff --git a/third_party/closure/compiler/private/BUILD b/third_party/closure/compiler/private/BUILD deleted file mode 100644 index 55ea7cfc9..000000000 --- a/third_party/closure/compiler/private/BUILD +++ /dev/null @@ -1 +0,0 @@ -package(default_visibility = ["//third_party/closure:__subpackages__"]) diff --git a/third_party/closure/compiler/private/defs.bzl b/third_party/closure/compiler/private/defs.bzl deleted file mode 100644 index 41e16e33f..000000000 --- a/third_party/closure/compiler/private/defs.bzl +++ /dev/null @@ -1,173 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Common build definitions for Closure Compiler build definitions. -""" - -JS_LANGUAGE_DEFAULT = "ECMASCRIPT6_STRICT" -JS_FILE_TYPE = FileType([".js"]) -JS_TEST_FILE_TYPE = FileType(["_test.js"]) -_CLOSURE_ROOT = "external/closure_library/closure/goog" -_CLOSURE_REL = "../../../.." - -JS_LANGUAGES = set([ - "ANY", - "ECMASCRIPT3", - "ECMASCRIPT5", - "ECMASCRIPT5_STRICT", - "ECMASCRIPT6", - "ECMASCRIPT6_STRICT", - "ECMASCRIPT6_TYPED", -]) - -JS_DEPS_ATTR = attr.label_list( - allow_files=False, - providers=["js_language", - "js_exports", - "transitive_js_srcs", - "transitive_js_externs"]) - -JS_LIBRARY_ATTRS = { - "srcs": attr.label_list(allow_files=JS_FILE_TYPE), - "externs_list": attr.label_list(allow_files=JS_FILE_TYPE), - "deps": JS_DEPS_ATTR, -} - -JS_PEDANTIC_ARGS = [ - "--jscomp_error=*", - "--jscomp_warning=deprecated", - "--jscomp_warning=unnecessaryCasts", -] - -JS_HIDE_WARNING_ARGS = [ - "--hide_warnings_for=.soy.js", - "--hide_warnings_for=external/closure_library/", - "--hide_warnings_for=external/soyutils_usegoog/", -] - -def collect_js_srcs(ctx): - srcs = set(order="compile") - externs = set(order="compile") - for dep in ctx.attr.deps: - srcs += dep.js_exports - srcs += dep.transitive_js_srcs - externs += dep.transitive_js_externs - srcs += JS_FILE_TYPE.filter(ctx.files.srcs) - externs += JS_FILE_TYPE.filter(ctx.files.externs_list) - return srcs, externs - -def check_js_language(language): - if language not in JS_LANGUAGES: - fail("Invalid JS language '%s', expected one of %s" % ( - language, ', '.join(list(JS_LANGUAGES)))) - return language - -def determine_js_language(ctx): - language = None - if hasattr(ctx.attr, 'language'): - language = check_js_language(ctx.attr.language) - for dep in ctx.attr.deps: - language = _mix_js_languages(language, dep.js_language) - if hasattr(ctx.attr, 'exports'): - for dep in ctx.attr.deps: - language = _mix_js_languages(language, dep.js_language) - return language or JS_LANGUAGE_DEFAULT - -def make_js_deps_runfiles(ctx, srcs): - ctx.action( - inputs=list(srcs), - outputs=[ctx.outputs.runfiles], - arguments=(["--output_file=%s" % ctx.outputs.runfiles.path] + - ["--root_with_prefix=%s %s" % (r, _make_prefix(p)) - for r, p in _find_roots( - [(src.dirname, src.short_path) for src in srcs])]), - executable=ctx.executable._depswriter, - progress_message="Calculating %d JavaScript runfile deps to %s" % ( - len(srcs), ctx.outputs.runfiles.short_path)) - -def is_using_closure_library(srcs): - return _contains_file(srcs, "external/closure_library/closure/goog/base.js") - -_JS_LANGUAGE_COMPATIBILITY = set([ - ("ECMASCRIPT5", "ECMASCRIPT3"), - ("ECMASCRIPT5", "ECMASCRIPT5_STRICT"), - ("ECMASCRIPT6", "ECMASCRIPT3"), - ("ECMASCRIPT6", "ECMASCRIPT5"), - ("ECMASCRIPT6", "ECMASCRIPT5_STRICT"), - ("ECMASCRIPT6", "ECMASCRIPT6_STRICT"), - ("ECMASCRIPT6_STRICT", "ECMASCRIPT5_STRICT"), - ("ECMASCRIPT6_TYPED", "ECMASCRIPT6_STRICT"), - ("ECMASCRIPT6_TYPED", "ECMASCRIPT5_STRICT"), -]) - -_JS_LANGUAGE_DECAY = { - ("ECMASCRIPT5_STRICT", "ECMASCRIPT3"): "ECMASCRIPT5", - ("ECMASCRIPT5_STRICT", "ECMASCRIPT5"): "ECMASCRIPT5", - ("ECMASCRIPT6_STRICT", "ECMASCRIPT3"): "ECMASCRIPT6", - ("ECMASCRIPT6_STRICT", "ECMASCRIPT5"): "ECMASCRIPT6", - ("ECMASCRIPT6_STRICT", "ECMASCRIPT6"): "ECMASCRIPT6", -} - -def _mix_js_languages(current, dependent): - if not current: - return dependent - if current == dependent: - return current - if current == "ANY": - return dependent - if dependent == "ANY": - return current - if (current, dependent) in _JS_LANGUAGE_COMPATIBILITY: - return current - decay = _JS_LANGUAGE_DECAY[(current, dependent)] - if decay: - print("Dependency causing JS strictness to decay from %s to %s :(" % ( - current, decay)) - return dependent - decay = _JS_LANGUAGE_DECAY[(dependent, current)] - if decay: - return dependent - fail("Can not link an %s library against an %s one." % (dependent, current)) - -def _find_roots(dirs): - roots = {} - for _, d, p in sorted([(len(d.split("/")), d, p) for d, p in dirs]): - parts = d.split("/") - want = True - for i in range(len(parts)): - if "/".join(parts[:i + 1]) in roots: - want = False - break - if want: - roots[d] = p - return roots.items() - -def _make_prefix(prefix): - prefix = "/".join(prefix.split("/")[:-1]) - if not prefix: - return _CLOSURE_REL - elif prefix == _CLOSURE_ROOT: - return "." - elif prefix.startswith(_CLOSURE_ROOT + "/"): - return prefix[len(_CLOSURE_ROOT) + 1:] - else: - return _CLOSURE_REL + "/" + prefix - -def _contains_file(srcs, path): - for src in srcs: - if src.short_path == path: - return True - return False diff --git a/third_party/closure/library/BUILD b/third_party/closure/library/BUILD deleted file mode 100644 index a72b2f4b9..000000000 --- a/third_party/closure/library/BUILD +++ /dev/null @@ -1,16 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache License 2.0 - -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") -load("//third_party/closure/stylesheets:closure_css_library.bzl", "closure_css_library") - -closure_js_library( - name = "library", - srcs = ["@closure_library//:js_files"], -) - -closure_css_library( - name = "css", - srcs = ["@closure_library//:css_files"], -) diff --git a/third_party/closure/library/closure_library.BUILD b/third_party/closure/library/closure_library.BUILD deleted file mode 100644 index bc5a2c018..000000000 --- a/third_party/closure/library/closure_library.BUILD +++ /dev/null @@ -1,31 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "js_files", - srcs = glob( - [ - "closure/goog/**/*.js", - "third_party/closure/goog/**/*.js", - ], - exclude = [ - "closure/goog/**/*_test.js", - "closure/goog/demos/**/*.js", - "third_party/closure/goog/**/*_test.js", - ], - ), -) - -filegroup( - name = "css_files", - srcs = glob(["closure/goog/css/**/*.css"]), -) - -py_binary( - name = "depswriter", - srcs = [ - "closure/bin/build/depswriter.py", - "closure/bin/build/source.py", - "closure/bin/build/treescan.py", - ], - main = "closure/bin/build/depswriter.py", -) diff --git a/third_party/closure/stylesheets/BUILD b/third_party/closure/stylesheets/BUILD deleted file mode 100644 index a8e3714d8..000000000 --- a/third_party/closure/stylesheets/BUILD +++ /dev/null @@ -1,16 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache License 2.0 - -java_binary( - name = "stylesheets", - jvm_flags = ["-client"], - main_class = "com.google.common.css.compiler.commandline.ClosureCommandLineCompiler", - runtime_deps = [ - "@args4j//jar", - "@closure_stylesheets//jar", - "@gson//jar", - "@guava//jar", - "//third_party/java/jsr305_annotations", - ], -) diff --git a/third_party/closure/stylesheets/closure_css_binary.bzl b/third_party/closure/stylesheets/closure_css_binary.bzl deleted file mode 100644 index ecd40adff..000000000 --- a/third_party/closure/stylesheets/closure_css_binary.bzl +++ /dev/null @@ -1,78 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Build definitions for CSS compiled by the Closure Stylesheets. -""" - -_CSS_FILE_TYPE = FileType([".css", ".gss"]) -_JS_FILE_TYPE = FileType([".js"]) - -def _impl(ctx): - srcs = set(order="compile") - for dep in ctx.attr.deps: - srcs += dep.transitive_css_srcs - srcs += _CSS_FILE_TYPE.filter(ctx.files.srcs) - js_srcs = set(order="compile") - js_srcs += ctx.attr._library.transitive_js_srcs - js_srcs += _JS_FILE_TYPE.filter([ctx.outputs.js]) - js_externs = set(order="compile") - js_externs += ctx.attr._library.transitive_js_externs - args = [ - "--output-file", - ctx.outputs.out.path, - "--output-renaming-map", - ctx.outputs.js.path, - "--output-renaming-map-format", - "CLOSURE_COMPILED_SPLIT_HYPHENS", - ] - if ctx.attr.debug: - args += ["--rename", "DEBUG", "--pretty-print"] - else: - args += ["--rename", "CLOSURE"] - args += ctx.attr.defs - args += [src.path for src in srcs] - ctx.action( - inputs=list(srcs), - outputs=[ctx.outputs.out, ctx.outputs.js], - arguments=args, - executable=ctx.executable._compiler, - progress_message="Compiling %d stylesheets to %s" % ( - len(srcs), ctx.outputs.out.short_path)) - return struct(files=set([ctx.outputs.out]), - js_language="ANY", - js_exports=set(order="compile"), - transitive_js_srcs=js_srcs, - transitive_js_externs=js_externs) - -closure_css_binary = rule( - implementation=_impl, - attrs={ - "srcs": attr.label_list(allow_files=_CSS_FILE_TYPE), - "deps": attr.label_list( - allow_files=False, - providers=["transitive_css_srcs"]), - "defs": attr.string_list(), - "debug": attr.bool(default=False), - "_compiler": attr.label( - default=Label("//third_party/closure/stylesheets"), - executable=True), - "_library": attr.label( - default=Label("//third_party/closure/library"), - providers=["transitive_js_srcs", - "transitive_js_externs"]), - }, - outputs={"out": "%{name}.css", - "js": "%{name}.css.js"}) diff --git a/third_party/closure/stylesheets/closure_css_library.bzl b/third_party/closure/stylesheets/closure_css_library.bzl deleted file mode 100644 index d6b4fb664..000000000 --- a/third_party/closure/stylesheets/closure_css_library.bzl +++ /dev/null @@ -1,34 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Build definitions for Closure Stylesheet libraries. -""" - -_CSS_FILE_TYPE = FileType([".css", ".gss"]) - -def _impl(ctx): - srcs = set(order="compile") - for dep in ctx.attr.deps: - srcs += dep.transitive_css_srcs - srcs += _CSS_FILE_TYPE.filter(ctx.files.srcs) - return struct(files=set(), transitive_css_srcs=srcs) - -closure_css_library = rule( - implementation=_impl, - attrs={ - "srcs": attr.label_list(allow_files=_CSS_FILE_TYPE), - "deps": attr.label_list(providers=["transitive_css_srcs"]) - }) diff --git a/third_party/closure/templates/BUILD b/third_party/closure/templates/BUILD deleted file mode 100644 index 01482d286..000000000 --- a/third_party/closure/templates/BUILD +++ /dev/null @@ -1,50 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache License 2.0 - -load("//third_party/closure/compiler:closure_js_library.bzl", "closure_js_library") - -java_library( - name = "templates", - exports = ["@soy//jar"], - runtime_deps = [ - "@aopalliance//jar", - "@asm//jar", - "@asm_analysis//jar", - "@asm_commons//jar", - "@asm_util//jar", - "@guava//jar", - "@guice//jar", - "@guice_assistedinject//jar", - "@guice_multibindings//jar", - "@icu4j//jar", - "//third_party/java/jsr305_annotations", - "//third_party/java/jsr330_inject", - ], -) - -closure_js_library( - name = "soyutils_usegoog", - srcs = ["@soyutils_usegoog//file"], - deps = ["//third_party/closure/library"], -) - -java_binary( - name = "SoyParseInfoGenerator", - jvm_flags = ["-client"], - main_class = "com.google.template.soy.SoyParseInfoGenerator", - runtime_deps = [ - "@args4j//jar", - ":templates", - ], -) - -java_binary( - name = "SoyToJsSrcCompiler", - jvm_flags = ["-client"], - main_class = "com.google.template.soy.SoyToJsSrcCompiler", - runtime_deps = [ - "@args4j//jar", - ":templates", - ], -) diff --git a/third_party/closure/templates/closure_template_java_library.bzl b/third_party/closure/templates/closure_template_java_library.bzl deleted file mode 100644 index 69cf9ebdb..000000000 --- a/third_party/closure/templates/closure_template_java_library.bzl +++ /dev/null @@ -1,185 +0,0 @@ -# -*- mode:python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Utilities for compiling Closure Templates to Java. -""" - - -# Generates a java_library with the SoyFileInfo and SoyTemplateInfo -# for all templates. -# -# For each Soy input called abc_def.soy, a Java class AbcDefSoyInfo will be -# generated. For a template in that file called foo.barBaz, you can reference -# its info as AbcDefSoyInfo.BAR_BAZ. -# -# srcs: an explicit file list of soy files to scan. -# java_package: the package for the Java files that are generated. If not -# given, defaults to the package from which this function was invoked. -# deps: Soy files that these templates depend on, in order for -# templates to include the parameters of templates they call. -# filegroup_name: will create a filegroup suitable for use as a -# dependency by another soy_java_wrappers rule -# extra_srcs: any build rule that provides Soy files that should be used -# as additional sources. For these, an extra_outs must be provided for each -# Java file expected. Useful for generating Java wrappers for Soy files not -# in the Java tree. -# extra_outs: extra output files from the dependencies that are requested; -# useful if for generating wrappers for files that are not in the Java tree -# allow_external_calls: Whether to allow external soy calls (i.e. calls to -# undefined templates). This parameter is passed to SoyParseInfoGenerator and -# it defaults to true. -# soycompilerbin: Optional Soy to ParseInfo compiler target. -def closure_template_java_library( - name, - java_package = None, - srcs = [], - deps = [], - filegroup_name = None, - extra_srcs = [], - extra_outs = [], - allow_external_calls = 1, - soycompilerbin = '//third_party/closure/templates:SoyParseInfoGenerator', - **kwargs): - - # Strip off the .soy suffix from the file name and camel-case it, preserving - # the case of directory names, if any. - outs = [(_soy__dirname(fn) + _soy__camel(_soy__filename(fn)[:-4]) - + 'SoyInfo.java') - for fn in srcs] - java_package = java_package or _soy__GetJavaPackageForCurrentDirectory() - - # TODO(gboyer): Stop generating the info for all the dependencies. - # First, generate the actual AbcSoyInfo.java files. - _gen_soy_java_wrappers( - name = name + '_files', - java_package = java_package, - srcs = srcs + extra_srcs, - deps = deps, - outs = outs + extra_outs, - allow_external_calls = allow_external_calls, - soycompilerbin = soycompilerbin, - **kwargs) - - # Now, wrap them in a Java library, and expose the Soy files as resources. - java_srcs = outs + extra_outs - native.java_library( - name = name, - srcs = java_srcs or None, - exports = ['//third_party/closure/templates'], - deps = [ - '//java/com/google/common/collect', - '//third_party/closure/templates', - ] if java_srcs else None, # b/13630760 - resources = srcs + extra_srcs, - **kwargs) - - if filegroup_name != None: - # Create a filegroup with all the dependencies. - native.filegroup( - name = filegroup_name, - srcs = srcs + extra_srcs + deps, - **kwargs) - - -# Generates SoyFileInfo and SoyTemplateInfo sources for Soy templates. -# -# - name: the name of a genrule which will contain Java sources -# - java_package: name of the java package, e.g. com.google.foo.template -# - srcs: all Soy file sources -# - deps: Soy files to parse but not to generate outputs for -# - outs: desired output files. for abc_def.soy, expect AbcDefSoyInfo.java -# - allow_external_calls: Whether to allow external calls, defaults to true. -# - soycompilerbin Optional Soy to ParseInfo compiler target. -def _gen_soy_java_wrappers(name, java_package, srcs, deps, outs, - allow_external_calls = 1, - soycompilerbin = '//third_party/closure/templates:SoyParseInfoGenerator', - **kwargs): - additional_flags = '' - targets = " ".join(["$(locations " + src + ")" for src in srcs]) - srcs_flag_file_name = name + '__srcs' - deps_flag_file_name = name + '__deps' - _soy__gen_file_list_arg_as_file( - out_name = srcs_flag_file_name, - targets = srcs, - flag = '--srcs', - ) - _soy__gen_file_list_arg_as_file( - out_name = deps_flag_file_name, - targets = deps, - flag = '--deps', - ) - native.genrule( - name = name, - tools = [soycompilerbin], - srcs = [srcs_flag_file_name, deps_flag_file_name] + srcs + deps, - message = "Generating SOY v2 Java files", - outs = outs, - cmd = '$(location %s)' % soycompilerbin + - ' --outputDirectory=$(@D)' + - ' --javaPackage=' + java_package + - ' --javaClassNameSource=filename' + - ' --allowExternalCalls=' + str(allow_external_calls) + - additional_flags + - # Include the sources and deps files as command line flags. - ' $$(cat $(location ' + srcs_flag_file_name + '))' + - ' $$(cat $(location ' + deps_flag_file_name + '))', - **kwargs) - - -# The output file for abc_def.soy is AbcDefSoyInfo.java. Handle camelcasing -# for both underscores and digits: css3foo_bar is Css3FooBarSoyInfo.java. -def _soy__camel(str): - last = '_' - result = '' - for ch in str: - if ch != '_': - if (last >= 'a' and last <= 'z') or (last >= 'A' and last <= 'Z'): - result += ch - else: - result += ch.upper() - last = ch - return result - - -def _soy__dirname(file): - return file[:file.rfind('/')+1] - - -def _soy__filename(file): - return file[file.rfind('/')+1:] - - -def _soy__gen_file_list_arg_as_file(out_name, targets, flag): - native.genrule( - name = out_name + '_gen', - srcs = targets, - outs = [out_name], - cmd = (("if [ -n \"$(SRCS)\" ] ; " + - "then echo -n '%s='$$(echo \"$(SRCS)\" | sed -e 's/ /,/g') > $@ ; " + - "fi ; " + - "touch $@") % flag), # touch the file, in case empty - visibility = ['//visibility:private']) - - -def _soy__GetJavaPackageForCurrentDirectory(): - """Returns the java package corresponding to the current directory.""" - directory = PACKAGE_NAME - idx = directory.find('/com/google') - if idx == -1: - fail( - None, - 'Unable to infer java package from directory [%s]' % (directory)) - return '.'.join(directory[idx + 1:].split('/')) diff --git a/third_party/closure/templates/closure_template_js_library.bzl b/third_party/closure/templates/closure_template_js_library.bzl deleted file mode 100644 index bf8152741..000000000 --- a/third_party/closure/templates/closure_template_js_library.bzl +++ /dev/null @@ -1,67 +0,0 @@ -# -*- mode:python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Utilities for compiling Closure Templates to JavaScript. -""" - -load("//third_party/closure/compiler:closure_js_library.bzl", - "closure_js_library") - -def closure_template_js_library( - name, - srcs, - deps = [], - testonly = 0, - visibility = None, - globals = None, - plugin_modules = [], - should_generate_js_doc = 1, - should_provide_require_soy_namespaces = 1, - should_generate_soy_msg_defs = 0, - soy_msgs_are_external = 0, - soycompilerbin = "//third_party/closure/templates:SoyToJsSrcCompiler"): - js_srcs = [src + ".js" for src in srcs] - cmd = ["$(location %s)" % soycompilerbin, - "--outputPathFormat='$(@D)/{INPUT_FILE_NAME}.js'"] - if soy_msgs_are_external: - cmd += ["--googMsgsAreExternal"] - if should_provide_require_soy_namespaces: - cmd += ["--shouldProvideRequireSoyNamespaces"] - if should_generate_soy_msg_defs: - cmd += "--shouldGenerateGoogMsgDefs" - if plugin_modules: - cmd += ["--pluginModules=%s" % ",".join(plugin_modules)] - cmd += ["$(location " + src + ")" for src in srcs] - if globals != None: - cmd += ["--compileTimeGlobalsFile='$(location %s)'" % globals] - srcs = srcs + [globals] - - native.genrule( - name = name + "_soy_js", - srcs = srcs, - testonly = testonly, - visibility = visibility, - message = "Generating SOY v2 JS files", - outs = js_srcs, - tools = [soycompilerbin], - cmd = " ".join(cmd), - ) - - closure_js_library( - name = name, - srcs = js_srcs, - deps = deps + ["//third_party/closure/templates:soyutils_usegoog"], - ) diff --git a/third_party/closure/testing/BUILD b/third_party/closure/testing/BUILD deleted file mode 100644 index abad34adc..000000000 --- a/third_party/closure/testing/BUILD +++ /dev/null @@ -1,26 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # Apache License 2.0 - -load("//third_party/closure/compiler:closure_js_check_test.bzl", "closure_js_check_test") - -exports_files([ - "phantomjs_jsunit_runner.js", - "phantomjs_runner.js", -]) - -closure_js_check_test( - name = "phantomjs_jsunit_runner_check", - srcs = ["phantomjs_jsunit_runner.js"], - pedantic = 1, - visibility = ["//visibility:private"], - deps = ["//third_party/closure/library"], -) - -closure_js_check_test( - name = "phantomjs_runner_check", - srcs = ["phantomjs_runner.js"], - externs_list = ["externs/phantom.js"], - pedantic = 1, - visibility = ["//visibility:private"], -) diff --git a/third_party/closure/testing/closure_js_test.bzl b/third_party/closure/testing/closure_js_test.bzl deleted file mode 100644 index fae6db533..000000000 --- a/third_party/closure/testing/closure_js_test.bzl +++ /dev/null @@ -1,116 +0,0 @@ -# -*- mode: python; -*- -# -# Copyright 2016 The Domain Registry Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Build rule for running Closure Library JsUnit tests in PhantomJS. -""" - -# XXX: It would be significantly faster and produce better stacktraces if we -# could avoid compilation by running in raw sources mode. This is not -# possible due to a resource loading bug in PhantomJS. -# https://github.com/ariya/phantomjs/issues/14028 - -load("//third_party/closure/compiler/private:defs.bzl", - "JS_HIDE_WARNING_ARGS", - "JS_LANGUAGE_DEFAULT", - "JS_LIBRARY_ATTRS", - "JS_PEDANTIC_ARGS", - "collect_js_srcs", - "determine_js_language") - -def _impl(ctx): - srcs, externs = collect_js_srcs(ctx) - srcs += [ctx.file._phantomjs_jsunit_runner] - args = [ - "--js_output_file=%s" % ctx.outputs.js.path, - "--language_in=%s" % determine_js_language(ctx), - "--language_out=ECMASCRIPT5_STRICT", - "--compilation_level=WHITESPACE_ONLY", - "--warning_level=VERBOSE", - "--dependency_mode=LOOSE", - "--formatting=PRETTY_PRINT", - "--new_type_inf", - "--debug", - ] - if ctx.attr.pedantic: - args += JS_PEDANTIC_ARGS - args += JS_HIDE_WARNING_ARGS - args += ["--externs=%s" % extern.path for extern in externs] - args += ["--js=%s" % src.path for src in srcs] - ctx.action( - inputs=list(srcs) + list(externs), - outputs=[ctx.outputs.js], - executable=ctx.executable._compiler, - arguments=args, - mnemonic="JSCompile", - progress_message="Compiling %d JavaScript files to %s" % ( - len(srcs) + len(externs), ctx.outputs.js.short_path)) - ctx.file_action( - executable=True, - output=ctx.outputs.executable, - content="\n".join([ - "#!/bin/sh", - "exec %s \\\n %s \\\n %s\n" % ( - ctx.file._phantomjs.short_path, - ctx.file._phantomjs_runner.short_path, - ctx.outputs.js.short_path), - ])) - return struct( - files=set([ctx.outputs.executable, - ctx.outputs.js]), - runfiles=ctx.runfiles(files=[ctx.file._phantomjs, - ctx.file._phantomjs_runner, - ctx.outputs.js], - collect_data=True)) - -_closure_js_test = rule( - test=True, - implementation=_impl, - attrs=JS_LIBRARY_ATTRS + { - "language": attr.string(default=JS_LANGUAGE_DEFAULT), - "pedantic": attr.bool(default=False), - "_compiler": attr.label( - default=Label("//third_party/closure/compiler"), - executable=True), - "_phantomjs": attr.label( - default=Label("//third_party/phantomjs"), - allow_files=True, - single_file=True), - "_phantomjs_runner": attr.label( - default=Label("//third_party/closure/testing:phantomjs_runner.js"), - allow_files=True, - single_file=True), - "_phantomjs_jsunit_runner": attr.label( - default=Label( - "//third_party/closure/testing:phantomjs_jsunit_runner.js"), - allow_files=True, - single_file=True), - }, - outputs={"js": "%{name}_dbg.js"}) - -# XXX: In compiled mode, we're forced to compile each test file individually, -# because tests might have overlapping global symbols. We compile in -# WHITESPACE_ONLY mode because other modes would be unreasonably slow. - -def closure_js_test(name, srcs, **kwargs): - if len(srcs) == 1: - _closure_js_test(name = name, srcs = srcs, **kwargs) - else: - tests = [] - for src in srcs: - test = name + '_' + src.replace('_test.js', '').replace('-', '_') - tests += [test] - _closure_js_test(name = test, srcs = [src], **kwargs) - native.test_suite(name = name, tests = tests) diff --git a/third_party/closure/testing/externs/phantom.js b/third_party/closure/testing/externs/phantom.js deleted file mode 100644 index ce5d4eb73..000000000 --- a/third_party/closure/testing/externs/phantom.js +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @fileoverview PhantomJS API definitions. We're only defining the parts of - * the API we plan on using. This file is necessary in order to have 100% - * strict type safety in {@code testrunner.js}. - * @externs - * @see http://phantomjs.org/api/ - */ - - -/** - * Fake namespace for PhantomJS types. - */ -var phantomjs = {}; - - - -/** - * @constructor - * @final - * @see https://github.com/ariya/phantomjs/blob/master/examples/stdin-stdout-stderr.js - */ -phantomjs.File = function() {}; - - -/** - * @param {string} text - * @const - */ -phantomjs.File.prototype.write = function(text) {}; - - -/** - * @param {string} text - * @const - */ -phantomjs.File.prototype.writeLine = function(text) {}; - - - -/** - * @constructor - * @final - * @see http://phantomjs.org/api/system/ - */ -phantomjs.System = function() {}; - - -/** - * @type {!Array