mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Migrate Domain Registry to Closure Rules 0.1.0
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122525197
This commit is contained in:
parent
1abd2a6314
commit
e1cf51ebb3
43 changed files with 69 additions and 1871 deletions
16
WORKSPACE
16
WORKSPACE
|
@ -3,3 +3,19 @@ workspace(name = "domain_registry")
|
||||||
load("//java/google/registry:repositories.bzl", "domain_registry_repositories")
|
load("//java/google/registry:repositories.bzl", "domain_registry_repositories")
|
||||||
|
|
||||||
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,
|
||||||
|
)
|
||||||
|
|
|
@ -18,42 +18,6 @@
|
||||||
|
|
||||||
def domain_registry_repositories():
|
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(
|
native.maven_jar(
|
||||||
name = "appengine_api_sdk",
|
name = "appengine_api_sdk",
|
||||||
artifact = "com.google.appengine:appengine-api-1.0-sdk:1.9.30",
|
artifact = "com.google.appengine:appengine-api-1.0-sdk:1.9.30",
|
||||||
|
@ -168,26 +132,6 @@ def domain_registry_repositories():
|
||||||
sha1 = "80dd3b0d5591580c429b0e2529706f6be5bddc0f",
|
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(
|
native.maven_jar(
|
||||||
name = "dagger",
|
name = "dagger",
|
||||||
artifact = "com.google.dagger:dagger:2.4",
|
artifact = "com.google.dagger:dagger:2.4",
|
||||||
|
@ -326,24 +270,6 @@ def domain_registry_repositories():
|
||||||
sha1 = "ce5b880b206de3f76d364988a6308c68c726f74a",
|
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(
|
native.maven_jar(
|
||||||
name = "hamcrest_core",
|
name = "hamcrest_core",
|
||||||
artifact = "org.hamcrest:hamcrest-core:1.3",
|
artifact = "org.hamcrest:hamcrest-core:1.3",
|
||||||
|
@ -488,14 +414,6 @@ def domain_registry_repositories():
|
||||||
sha1 = "79a8984096fc6591c1e3690e07d41be506356fa5",
|
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(
|
native.maven_jar(
|
||||||
name = "protobuf_java",
|
name = "protobuf_java",
|
||||||
artifact = "com.google.protobuf:protobuf-java:2.6.1",
|
artifact = "com.google.protobuf:protobuf-java:2.6.1",
|
||||||
|
@ -526,18 +444,6 @@ def domain_registry_repositories():
|
||||||
sha1 = "862a5bc736005d68727d1387844d09d62efdb6cb",
|
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(
|
native.maven_jar(
|
||||||
name = "sshd_core",
|
name = "sshd_core",
|
||||||
artifact = "org.apache.sshd:sshd-core:0.7.0",
|
artifact = "org.apache.sshd:sshd-core:0.7.0",
|
||||||
|
|
|
@ -78,7 +78,7 @@ java_library(
|
||||||
|
|
||||||
"//third_party/java/appengine:appengine-remote-api",
|
"//third_party/java/appengine:appengine-remote-api",
|
||||||
|
|
||||||
"//third_party/closure/templates",
|
"@io_bazel_rules_closure//closure/templates",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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(
|
closure_template_java_library(
|
||||||
|
|
|
@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
|
||||||
load("//third_party/closure/compiler:closure_js_binary.bzl", "closure_js_binary")
|
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_deps")
|
||||||
load("//third_party/closure/compiler:closure_js_deps.bzl", "closure_js_deps")
|
|
||||||
|
|
||||||
exports_files(["globals.txt"])
|
exports_files(["globals.txt"])
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ filegroup(
|
||||||
":assets_recursive",
|
":assets_recursive",
|
||||||
"//javascript/closure:js_files_recursive",
|
"//javascript/closure:js_files_recursive",
|
||||||
"//javascript/template/soy:soy_usegoog_js_files",
|
"//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/css:registrar_bin.css",
|
||||||
"//java/google/registry/ui/html:html_files",
|
"//java/google/registry/ui/html:html_files",
|
||||||
],
|
],
|
||||||
|
@ -43,13 +42,14 @@ filegroup(
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "runfiles_debug",
|
name = "runfiles_debug",
|
||||||
srcs = [
|
srcs = [
|
||||||
"deps-runfiles.js",
|
"@closure_library//:js_files",
|
||||||
":js_files_recursive",
|
"brain_bin.js.map",
|
||||||
|
"deps.js",
|
||||||
|
"registrar_bin.js.map",
|
||||||
":runfiles",
|
":runfiles",
|
||||||
"//javascript/closure:js_files_recursive",
|
"//javascript/closure:js_files_recursive",
|
||||||
"//javascript/template/soy:soy_usegoog_js_files",
|
"//javascript/template/soy:soy_usegoog_js_files",
|
||||||
"//java/google/registry/ui/css:css_files",
|
"//java/google/registry/ui/css:css_files",
|
||||||
"//third_party/javascript/closure:js_files_recursive",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,19 +68,12 @@ java_library(
|
||||||
|
|
||||||
closure_js_deps(
|
closure_js_deps(
|
||||||
name = "deps",
|
name = "deps",
|
||||||
srcs = [
|
deps = [
|
||||||
"//java/google/registry/ui/js",
|
"//java/google/registry/ui/js",
|
||||||
"//java/google/registry/ui/js/registrar",
|
"//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
|
## Registrar Console
|
||||||
|
|
||||||
|
@ -91,23 +84,14 @@ SOURCEMAP_SCRUB = (" -e 's@b....-out/[^/]*/bin/@@g'" +
|
||||||
# non-union minified equivalents.
|
# non-union minified equivalents.
|
||||||
closure_js_binary(
|
closure_js_binary(
|
||||||
name = "registrar_bin",
|
name = "registrar_bin",
|
||||||
externs_list = ["//java/google/registry/ui/externs"],
|
css = "//java/google/registry/ui/css:registrar_bin",
|
||||||
main = "registry.registrar.main",
|
entry_points = ["goog:registry.registrar.main"],
|
||||||
deps = [
|
deps = [
|
||||||
"//java/google/registry/ui/css:registrar_bin",
|
"//java/google/registry/ui/externs",
|
||||||
"//java/google/registry/ui/js/registrar",
|
"//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
|
# The webserver should provide this to trusted admin users, rather than
|
||||||
# registrar_bin.js. This is what makes debugging in production possible.
|
# registrar_bin.js. This is what makes debugging in production possible.
|
||||||
genrule(
|
genrule(
|
||||||
|
@ -125,12 +109,12 @@ genrule(
|
||||||
# an extra underscore.
|
# an extra underscore.
|
||||||
closure_js_binary(
|
closure_js_binary(
|
||||||
name = "registrar_dbg",
|
name = "registrar_dbg",
|
||||||
|
css = "//java/google/registry/ui/css:registrar_dbg",
|
||||||
debug = 1,
|
debug = 1,
|
||||||
externs_list = ["//java/google/registry/ui/externs"],
|
entry_points = ["goog:registry.registrar.main"],
|
||||||
formatting = "PRETTY_PRINT",
|
formatting = "PRETTY_PRINT",
|
||||||
main = "registry.registrar.main",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//java/google/registry/ui/css:registrar_dbg",
|
"//java/google/registry/ui/externs",
|
||||||
"//java/google/registry/ui/js/registrar",
|
"//java/google/registry/ui/js/registrar",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -140,16 +124,11 @@ closure_js_binary(
|
||||||
|
|
||||||
closure_js_binary(
|
closure_js_binary(
|
||||||
name = "brain_bin",
|
name = "brain_bin",
|
||||||
externs_list = ["//java/google/registry/ui/externs"],
|
entry_points = ["goog:registry.registrar.BrainFrame.main"],
|
||||||
main = "registry.registrar.BrainFrame.main",
|
deps = [
|
||||||
deps = ["//java/google/registry/ui/js/registrar"],
|
"//java/google/registry/ui/externs",
|
||||||
)
|
"//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 + " >$@",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
<!-- This can only be used by admins in a testing environment. -->
|
<!-- This can only be used by admins in a testing environment. -->
|
||||||
<!-- This iframe provides no isolation of Braintree from Console. -->
|
<!-- This iframe provides no isolation of Braintree from Console. -->
|
||||||
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
|
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
|
||||||
|
<script>var CLOSURE_NO_DEPS = true;</script>
|
||||||
<script src="/assets/sources/javascript/closure/base.js"></script>
|
<script src="/assets/sources/javascript/closure/base.js"></script>
|
||||||
<script src="/assets/sources/deps-runfiles.js"></script>
|
<script src="/assets/sources/deps.js"></script>
|
||||||
<body style="margin:0">
|
<body style="margin:0">
|
||||||
<form><div id="brainframe"></div></form>
|
<form><div id="brainframe"></div></form>
|
||||||
<script>goog.require('registry.registrar.BrainFrame.main');</script>
|
<script>goog.require('registry.registrar.BrainFrame.main');</script>
|
||||||
|
|
|
@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
|
||||||
load("//third_party/closure/stylesheets:closure_css_library.bzl", "closure_css_library")
|
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_css_library", "closure_css_binary")
|
||||||
load("//third_party/closure/stylesheets:closure_css_binary.bzl", "closure_css_binary")
|
|
||||||
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
|
@ -2,10 +2,12 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
|
||||||
|
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
|
||||||
|
|
||||||
filegroup(
|
|
||||||
|
closure_js_library(
|
||||||
name = "externs",
|
name = "externs",
|
||||||
srcs = glob(["*.js"]),
|
externs = glob(["*.js"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
|
@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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(
|
filegroup(
|
||||||
|
|
|
@ -2,7 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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(
|
filegroup(
|
||||||
|
|
|
@ -27,6 +27,6 @@ java_library(
|
||||||
"//third_party/java/re2j",
|
"//third_party/java/re2j",
|
||||||
"//third_party/java/servlet/servlet_api",
|
"//third_party/java/servlet/servlet_api",
|
||||||
|
|
||||||
"//third_party/closure/templates",
|
"@io_bazel_rules_closure//closure/templates",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,6 +21,6 @@ java_library(
|
||||||
"//third_party/java/jsr305_annotations",
|
"//third_party/java/jsr305_annotations",
|
||||||
"//third_party/java/servlet/servlet_api",
|
"//third_party/java/servlet/servlet_api",
|
||||||
|
|
||||||
"//third_party/closure/templates",
|
"@io_bazel_rules_closure//closure/templates",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,6 +40,6 @@ java_library(
|
||||||
"//third_party/java/objectify:objectify-v4_1",
|
"//third_party/java/objectify:objectify-v4_1",
|
||||||
"//third_party/java/servlet/servlet_api",
|
"//third_party/java/servlet/servlet_api",
|
||||||
|
|
||||||
"//third_party/closure/templates",
|
"@io_bazel_rules_closure//closure/templates",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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_js_library")
|
||||||
load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library")
|
|
||||||
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
|
@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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_js_library")
|
||||||
load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library")
|
|
||||||
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
|
@ -2,8 +2,7 @@ package(default_visibility = ["//java/google/registry:registry_project"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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_js_library")
|
||||||
load("//third_party/closure/templates:closure_template_js_library.bzl", "closure_template_js_library")
|
|
||||||
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
|
@ -38,9 +38,10 @@
|
||||||
{case google.registry.ui.ConsoleDebug.DEBUG}
|
{case google.registry.ui.ConsoleDebug.DEBUG}
|
||||||
<script src="/assets/js/registrar_dbg.js"></script>
|
<script src="/assets/js/registrar_dbg.js"></script>
|
||||||
{case google.registry.ui.ConsoleDebug.RAW}
|
{case google.registry.ui.ConsoleDebug.RAW}
|
||||||
|
<script>var CLOSURE_NO_DEPS = true;</script>
|
||||||
<script src="/assets/sources/external/closure_library/closure/goog/base.js">
|
<script src="/assets/sources/external/closure_library/closure/goog/base.js">
|
||||||
</script>
|
</script>
|
||||||
<script src="/assets/sources/deps-runfiles.js"></script>
|
<script src="/assets/sources/deps.js"></script>
|
||||||
<script>goog.require('registry.registrar.main');</script>
|
<script>goog.require('registry.registrar.main');</script>
|
||||||
{/switch}
|
{/switch}
|
||||||
{if isNonnull(DEBUG)}
|
{if isNonnull(DEBUG)}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
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(
|
closure_js_library(
|
||||||
name = "closure",
|
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(
|
filegroup(
|
||||||
|
|
|
@ -33,8 +33,8 @@ public final class RegistryTestServer {
|
||||||
.put("/error.html", Paths.get("java/google/registry/ui/html/error.html"))
|
.put("/error.html", Paths.get("java/google/registry/ui/html/error.html"))
|
||||||
.put("/assets/js/*", Paths.get("java/google/registry/ui"))
|
.put("/assets/js/*", Paths.get("java/google/registry/ui"))
|
||||||
.put("/assets/css/*", Paths.get("java/google/registry/ui/css"))
|
.put("/assets/css/*", Paths.get("java/google/registry/ui/css"))
|
||||||
.put("/assets/sources/deps-runfiles.js",
|
.put("/assets/sources/deps.js",
|
||||||
Paths.get("java/google/registry/ui/deps-runfiles.js"))
|
Paths.get("java/google/registry/ui/deps.js"))
|
||||||
.put("/assets/sources/*", Paths.get(""))
|
.put("/assets/sources/*", Paths.get(""))
|
||||||
.put("/assets/*", Paths.get("java/google/registry/ui/assets"))
|
.put("/assets/*", Paths.get("java/google/registry/ui/assets"))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -5,14 +5,16 @@ package(
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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", "closure_js_test")
|
||||||
load("//third_party/closure/testing:closure_js_test.bzl", "closure_js_test")
|
|
||||||
|
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
name = "testing",
|
name = "testing",
|
||||||
srcs = ["testing.js"],
|
srcs = ["testing.js"],
|
||||||
deps = ["//javascript/closure"],
|
deps = [
|
||||||
|
"//javascript/closure",
|
||||||
|
"//javascript/closure:testing",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
closure_js_test(
|
closure_js_test(
|
||||||
|
|
|
@ -5,8 +5,7 @@ package(
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
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", "closure_js_test")
|
||||||
load("//third_party/closure/testing:closure_js_test.bzl", "closure_js_test")
|
|
||||||
|
|
||||||
|
|
||||||
closure_js_library(
|
closure_js_library(
|
||||||
|
@ -14,6 +13,7 @@ closure_js_library(
|
||||||
srcs = ["console_test_util.js"],
|
srcs = ["console_test_util.js"],
|
||||||
deps = [
|
deps = [
|
||||||
"//javascript/closure",
|
"//javascript/closure",
|
||||||
|
"//javascript/closure:testing",
|
||||||
"//java/google/registry/ui/js",
|
"//java/google/registry/ui/js",
|
||||||
"//java/google/registry/ui/js/registrar",
|
"//java/google/registry/ui/js/registrar",
|
||||||
],
|
],
|
||||||
|
|
10
third_party/closure/compiler/BUILD
vendored
10
third_party/closure/compiler/BUILD
vendored
|
@ -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"],
|
|
||||||
)
|
|
|
@ -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"})
|
|
|
@ -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),
|
|
||||||
})
|
|
54
third_party/closure/compiler/closure_js_deps.bzl
vendored
54
third_party/closure/compiler/closure_js_deps.bzl
vendored
|
@ -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"})
|
|
|
@ -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),
|
|
||||||
})
|
|
1
third_party/closure/compiler/private/BUILD
vendored
1
third_party/closure/compiler/private/BUILD
vendored
|
@ -1 +0,0 @@
|
||||||
package(default_visibility = ["//third_party/closure:__subpackages__"])
|
|
173
third_party/closure/compiler/private/defs.bzl
vendored
173
third_party/closure/compiler/private/defs.bzl
vendored
|
@ -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
|
|
16
third_party/closure/library/BUILD
vendored
16
third_party/closure/library/BUILD
vendored
|
@ -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"],
|
|
||||||
)
|
|
|
@ -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",
|
|
||||||
)
|
|
16
third_party/closure/stylesheets/BUILD
vendored
16
third_party/closure/stylesheets/BUILD
vendored
|
@ -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",
|
|
||||||
],
|
|
||||||
)
|
|
|
@ -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"})
|
|
|
@ -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"])
|
|
||||||
})
|
|
50
third_party/closure/templates/BUILD
vendored
50
third_party/closure/templates/BUILD
vendored
|
@ -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",
|
|
||||||
],
|
|
||||||
)
|
|
|
@ -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('/'))
|
|
|
@ -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"],
|
|
||||||
)
|
|
26
third_party/closure/testing/BUILD
vendored
26
third_party/closure/testing/BUILD
vendored
|
@ -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"],
|
|
||||||
)
|
|
116
third_party/closure/testing/closure_js_test.bzl
vendored
116
third_party/closure/testing/closure_js_test.bzl
vendored
|
@ -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)
|
|
282
third_party/closure/testing/externs/phantom.js
vendored
282
third_party/closure/testing/externs/phantom.js
vendored
|
@ -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<string>}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
phantomjs.System.prototype.args;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {!phantomjs.File}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
phantomjs.System.prototype.stdout;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {!phantomjs.File}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
phantomjs.System.prototype.stderr;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/fs/
|
|
||||||
*/
|
|
||||||
phantomjs.FileSystem = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} path
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
phantomjs.FileSystem.prototype.exists = function(path) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} path
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
phantomjs.FileSystem.prototype.read = function(path) {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
phantomjs.WebPage = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {!phantomjs.Page}
|
|
||||||
*/
|
|
||||||
phantomjs.WebPage.prototype.create = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
phantomjs.PageSettings = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
phantomjs.PageSettings.prototype.resourceTimeout;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
phantomjs.Page = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} url
|
|
||||||
* @param {function(string)=} opt_callback
|
|
||||||
*/
|
|
||||||
phantomjs.Page.prototype.open = function(url, opt_callback) {};
|
|
||||||
|
|
||||||
|
|
||||||
phantomjs.Page.prototype.close = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {function(): T} callback
|
|
||||||
* @return {T}
|
|
||||||
* @template T
|
|
||||||
*/
|
|
||||||
phantomjs.Page.prototype.evaluate = function(callback) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {!phantomjs.PageSettings}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
phantomjs.Page.prototype.settings;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/webserver/
|
|
||||||
*/
|
|
||||||
phantomjs.Server = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
phantomjs.Server.prototype.port;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} port
|
|
||||||
* @param {function(!phantomjs.Server.Request,
|
|
||||||
* !phantomjs.Server.Response)} callback
|
|
||||||
*/
|
|
||||||
phantomjs.Server.prototype.listen = function(port, callback) {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/webserver/method/listen.html
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Request = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Request.prototype.url;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/webserver/method/listen.html
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Response = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} encoding
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Response.prototype.setEncoding = function(encoding) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} statusCode
|
|
||||||
* @param {!Object<string, string>=} opt_headers
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Response.prototype.writeHead =
|
|
||||||
function(statusCode, opt_headers) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} data
|
|
||||||
*/
|
|
||||||
phantomjs.Server.Response.prototype.write = function(data) {};
|
|
||||||
|
|
||||||
|
|
||||||
phantomjs.Server.Response.prototype.close = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
phantomjs.Server.Response.prototype.closeGracefully = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/webserver/
|
|
||||||
*/
|
|
||||||
phantomjs.WebServer = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {!phantomjs.Server}
|
|
||||||
*/
|
|
||||||
phantomjs.WebServer.prototype.create = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @final
|
|
||||||
* @see http://phantomjs.org/api/phantom/
|
|
||||||
*/
|
|
||||||
phantomjs.Phantom = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number=} opt_status
|
|
||||||
*/
|
|
||||||
phantomjs.Phantom.prototype.exit = function(opt_status) {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {!phantomjs.Phantom}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
var phantom;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} name
|
|
||||||
* @return {?}
|
|
||||||
*/
|
|
||||||
function require(name) {}
|
|
|
@ -1,30 +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 test runner in-browser code. This file loads Closure
|
|
||||||
* testing libraries and then polls for test completion and then sends a
|
|
||||||
* message to PhantomJS letting it know it can exit.
|
|
||||||
*/
|
|
||||||
|
|
||||||
goog.require('goog.testing.jsunit');
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
window.setInterval(function() {
|
|
||||||
if (window['G_testRunner'].isFinished()) {
|
|
||||||
window['callPhantom'](window['G_testRunner'].isSuccess());
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
})();
|
|
285
third_party/closure/testing/phantomjs_runner.js
vendored
285
third_party/closure/testing/phantomjs_runner.js
vendored
|
@ -1,285 +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 headless browser container for Closure unit tests.
|
|
||||||
* This program runs inside PhantomJS but not inside the browser itself. It
|
|
||||||
* starts an HTTP server that serves runfiles. It loads the generated test
|
|
||||||
* runner HTML file inside an ethereal browser. Once the page is loaded,
|
|
||||||
* this program communicates with the page to collect log data and monitor
|
|
||||||
* whether or not the tests succeeded.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var /** !phantomjs.WebPage */ webpage = require('webpage');
|
|
||||||
var /** !phantomjs.FileSystem */ fs = require('fs');
|
|
||||||
var /** !phantomjs.WebServer */ webserver = require('webserver');
|
|
||||||
var /** !phantomjs.System */ system = require('system');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location of virtual test page.
|
|
||||||
* @type {string}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
var VIRTUAL_PAGE = '/index.html';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path under which runfiles are served.
|
|
||||||
* @type {string}
|
|
||||||
* @const
|
|
||||||
*/
|
|
||||||
var RUNFILES_PREFIX = '/filez/';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Full URL of virtual page.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
var url;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HTML for virtual test page, hosted under {@code index.html}.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
var virtualPageHtml;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path of JS file to load.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
var js;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PhantomJS page object.
|
|
||||||
* @type {!phantomjs.Page}
|
|
||||||
*/
|
|
||||||
var page = webpage.create();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Guesses Content-Type header for {@code path}
|
|
||||||
* @param {string} path
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
function guessContentType(path) {
|
|
||||||
switch (path.substr(path.lastIndexOf('.') + 1)) {
|
|
||||||
case 'js':
|
|
||||||
return 'application/javascript;charset=utf-8';
|
|
||||||
case 'html':
|
|
||||||
return 'text/html;charset=utf-8';
|
|
||||||
case 'css':
|
|
||||||
return 'text/css;charset=utf-8';
|
|
||||||
case 'txt':
|
|
||||||
return 'text/plain;charset=utf-8';
|
|
||||||
case 'xml':
|
|
||||||
return 'application/xml;charset=utf-8';
|
|
||||||
case 'gif':
|
|
||||||
return 'image/gif';
|
|
||||||
case 'png':
|
|
||||||
return 'image/png';
|
|
||||||
case 'jpg':
|
|
||||||
case 'jpeg':
|
|
||||||
return 'image/jpeg';
|
|
||||||
default:
|
|
||||||
return 'application/octet-stream';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles request from web browser.
|
|
||||||
* @param {!phantomjs.Server.Request} request
|
|
||||||
* @param {!phantomjs.Server.Response} response
|
|
||||||
*/
|
|
||||||
function onRequest(request, response) {
|
|
||||||
var path = request.url;
|
|
||||||
system.stderr.writeLine('Serving ' + path);
|
|
||||||
if (path == VIRTUAL_PAGE) {
|
|
||||||
response.writeHead(200, {
|
|
||||||
'Cache': 'no-cache',
|
|
||||||
'Content-Type': 'text/html;charset=utf-8'
|
|
||||||
});
|
|
||||||
response.write(virtualPageHtml);
|
|
||||||
response.closeGracefully();
|
|
||||||
} else if (path.indexOf(RUNFILES_PREFIX) == 0) {
|
|
||||||
path = path.substr(RUNFILES_PREFIX.length);
|
|
||||||
if (!fs.exists(path)) {
|
|
||||||
send404(request, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var contentType = guessContentType(path);
|
|
||||||
if (contentType.indexOf('charset') != -1) {
|
|
||||||
response.setEncoding('binary');
|
|
||||||
}
|
|
||||||
response.writeHead(200, {
|
|
||||||
'Cache': 'no-cache',
|
|
||||||
'Content-Type': contentType
|
|
||||||
});
|
|
||||||
response.write(fs.read(path));
|
|
||||||
response.closeGracefully();
|
|
||||||
} else {
|
|
||||||
send404(request, response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a 404 Not Found response.
|
|
||||||
* @param {!phantomjs.Server.Request} request
|
|
||||||
* @param {!phantomjs.Server.Response} response
|
|
||||||
*/
|
|
||||||
function send404(request, response) {
|
|
||||||
system.stderr.writeLine('NOT FOUND ' + request.url);
|
|
||||||
response.writeHead(404, {
|
|
||||||
'Cache': 'no-cache',
|
|
||||||
'Content-Type': 'text/plain;charset=utf-8'
|
|
||||||
});
|
|
||||||
response.write('Not Found');
|
|
||||||
response.closeGracefully();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts text from inside page.
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
function extractText() {
|
|
||||||
var element = document.getElementById('blah');
|
|
||||||
if (element != null) {
|
|
||||||
return element.innerText;
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when log entries are emitted inside the browser.
|
|
||||||
* @param {string} message
|
|
||||||
* @param {?string} line
|
|
||||||
* @param {?string} source
|
|
||||||
*/
|
|
||||||
function onConsoleMessage(message, line, source) {
|
|
||||||
message = message.replace(/\r?\n/, '\n-> ');
|
|
||||||
if (line && source) {
|
|
||||||
system.stderr.writeLine('-> ' + source + ':' + line + '] ' + message);
|
|
||||||
} else {
|
|
||||||
system.stderr.writeLine('-> ' + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when headless web page is loaded.
|
|
||||||
* @param {string} status
|
|
||||||
*/
|
|
||||||
function onLoadFinished(status) {
|
|
||||||
if (status != 'success') {
|
|
||||||
system.stderr.writeLine('Load Failed');
|
|
||||||
phantom.exit(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when webpage shows an alert dialog.
|
|
||||||
* @param {string} message
|
|
||||||
*/
|
|
||||||
function onAlert(message) {
|
|
||||||
system.stderr.writeLine('Alert: ' + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when headless web page throws an error.
|
|
||||||
* @param {string} message
|
|
||||||
* @param {!Array<{file: string,
|
|
||||||
* line: number,
|
|
||||||
* function: string}>} trace
|
|
||||||
*/
|
|
||||||
function onError(message, trace) {
|
|
||||||
system.stderr.writeLine(message);
|
|
||||||
trace.forEach(function(t) {
|
|
||||||
var msg = '> ';
|
|
||||||
if (t.function != '') {
|
|
||||||
msg += t.function + ' at ';
|
|
||||||
}
|
|
||||||
msg += t.file + ':' + t.line;
|
|
||||||
system.stderr.writeLine(msg);
|
|
||||||
});
|
|
||||||
page.close();
|
|
||||||
phantom.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when JavaScript inside page sends us a message.
|
|
||||||
* @param {boolean} succeeded
|
|
||||||
*/
|
|
||||||
function onCallback(succeeded) {
|
|
||||||
page.close();
|
|
||||||
if (succeeded) {
|
|
||||||
phantom.exit();
|
|
||||||
} else {
|
|
||||||
phantom.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a single pending test.
|
|
||||||
*/
|
|
||||||
function run() {
|
|
||||||
virtualPageHtml =
|
|
||||||
'<!doctype html>\n' +
|
|
||||||
'<meta charset="utf-8">' +
|
|
||||||
'<body>\n' +
|
|
||||||
'</body>\n' +
|
|
||||||
// These definitions are only necessary because we're compiling in
|
|
||||||
// WHITESPACE_ONLY mode.
|
|
||||||
'<script>\n' +
|
|
||||||
' var CLOSURE_NO_DEPS = true;\n' +
|
|
||||||
' var CLOSURE_UNCOMPILED_DEFINES = {\n' +
|
|
||||||
' "goog.ENABLE_DEBUG_LOADER": false\n' +
|
|
||||||
' };\n' +
|
|
||||||
'</script>\n' +
|
|
||||||
'<script src="' + RUNFILES_PREFIX + js + '"></script>\n';
|
|
||||||
page.onAlert = onAlert;
|
|
||||||
page.onCallback = onCallback;
|
|
||||||
page.onConsoleMessage = onConsoleMessage;
|
|
||||||
page.onError = onError;
|
|
||||||
page.onLoadFinished = onLoadFinished;
|
|
||||||
// XXX: If PhantomJS croaks, fail sooner rather than later.
|
|
||||||
// https://github.com/ariya/phantomjs/issues/10652
|
|
||||||
page.settings.resourceTimeout = 2000;
|
|
||||||
page.open(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
js = system.args[1];
|
|
||||||
var port = Math.floor(Math.random() * (60000 - 32768)) + 32768;
|
|
||||||
var server = webserver.create();
|
|
||||||
server.listen(port, onRequest);
|
|
||||||
url = 'http://localhost:' + port + VIRTUAL_PAGE;
|
|
||||||
system.stderr.writeLine('Listening ' + url);
|
|
||||||
run();
|
|
||||||
})();
|
|
32
third_party/java/soy/BUILD
vendored
32
third_party/java/soy/BUILD
vendored
|
@ -1,32 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
licenses(["notice"]) # Apache License 2.0
|
|
||||||
|
|
||||||
java_library(
|
|
||||||
name = "soy",
|
|
||||||
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",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
java_binary(
|
|
||||||
name = "SoyParseInfoGenerator",
|
|
||||||
jvm_flags = ["-client"],
|
|
||||||
main_class = "com.google.template.soy.SoyParseInfoGenerator",
|
|
||||||
runtime_deps = [
|
|
||||||
"@args4j//jar",
|
|
||||||
":soy",
|
|
||||||
],
|
|
||||||
)
|
|
19
third_party/phantomjs/BUILD
vendored
19
third_party/phantomjs/BUILD
vendored
|
@ -1,19 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
licenses(["notice"]) # BSD
|
|
||||||
|
|
||||||
genrule(
|
|
||||||
name = "phantomjs_bin",
|
|
||||||
srcs = ["@phantomjs//file"],
|
|
||||||
outs = ["phantomjs"],
|
|
||||||
cmd = " && ".join([
|
|
||||||
"IN=$$(pwd)/$(SRCS)",
|
|
||||||
"OUT=$$(pwd)/$@",
|
|
||||||
"TMP=$$(mktemp -d $${TMPDIR:-/tmp}/phantomjs.XXXXXXXX)",
|
|
||||||
"cd $$TMP",
|
|
||||||
"tar -xjf $$IN",
|
|
||||||
"cd phantomjs-*",
|
|
||||||
"mv bin/phantomjs $$OUT",
|
|
||||||
"rm -rf $$TMP",
|
|
||||||
]),
|
|
||||||
)
|
|
Loading…
Add table
Reference in a new issue