-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper to create closure_js_library metadata (#298)
The helper will make it is easier for other rules to act like a closure_js_library. Note that the returned struct from helper is not a proper provider since existing contract of closure_js_library is not compatible with it and requires a large incompatible refactoring. This patch also fixes handling of zip files and adds corresponding tests.
- Loading branch information
Showing
8 changed files
with
124 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2018 The Closure Rules 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. | ||
|
||
package(default_testonly = True) | ||
|
||
licenses(["notice"]) # Apache 2.0 | ||
|
||
load("//closure/private:file_test.bzl", "file_test") | ||
load("//closure:defs.bzl", "closure_js_binary") | ||
load(":zip_file_test_library.bzl", "zip_file_test_library") | ||
|
||
zip_file_test_library( | ||
name = "main_lib", | ||
srcs = ["main.js.zip"], | ||
) | ||
|
||
closure_js_binary( | ||
name = "main_bin", | ||
deps = [":main_lib"], | ||
) | ||
|
||
file_test( | ||
name = "zip_files_worksCorrectly", | ||
content = "console.log(\"hi from zip\");\n", | ||
file = "main_bin.js", | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
load("//closure:defs.bzl", "CLOSURE_JS_TOOLCHAIN_ATTRS", "create_closure_js_library") | ||
|
||
def _impl_zip_file_test_library(ctx): | ||
return create_closure_js_library(ctx, ctx.files.srcs) | ||
|
||
zip_file_test_library = rule( | ||
implementation = _impl_zip_file_test_library, | ||
attrs = dict(CLOSURE_JS_TOOLCHAIN_ATTRS, **{ | ||
"srcs": attr.label_list(allow_files = [".js.zip"]), | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters