Skip to content

Commit

Permalink
chore: upgrade Bazel core packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eagle authored and alexeagle committed Jun 8, 2020
1 parent 3942fd9 commit 3824ccf
Show file tree
Hide file tree
Showing 25 changed files with 133 additions and 171 deletions.
2 changes: 1 addition & 1 deletion examples/parcel/parcel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _parcel_impl(ctx):
parcel = rule(
implementation = _parcel_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"entry_point": attr.label(
allow_single_file = True,
mandatory = True,
Expand All @@ -60,6 +59,7 @@ parcel = rule(
executable = True,
cfg = "host",
),
"srcs": attr.label_list(allow_files = True),
},
outputs = {
"bundle": "%{name}.js",
Expand Down
2 changes: 1 addition & 1 deletion internal/common/copy_to_bin.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def _copy_to_bin_impl(ctx):
_copy_to_bin = rule(
implementation = _copy_to_bin_impl,
attrs = {
"srcs": attr.label_list(mandatory = True, allow_files = True),
"is_windows": attr.bool(mandatory = True, doc = "Automatically set by macro"),
"srcs": attr.label_list(mandatory = True, allow_files = True),
},
)

Expand Down
2 changes: 1 addition & 1 deletion internal/common/params_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ _DOC = """Generates a params file from a list of arguments."""

# See params_file macro below for docstrings
_ATTRS = {
"out": attr.output(mandatory = True),
"args": attr.string_list(),
"data": attr.label_list(allow_files = True),
"is_windows": attr.bool(mandatory = True),
"newline": attr.string(
values = ["unix", "windows", "auto"],
default = "auto",
),
"out": attr.output(mandatory = True),
}

def _expand_location_into_runfiles(ctx, s):
Expand Down
8 changes: 4 additions & 4 deletions internal/coverage/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

exports_files([
"lcov_merger-js.js",
])

# BEGIN-INTERNAL
load("//packages/typescript:checked_in_ts_project.bzl", "checked_in_ts_project")

Expand All @@ -14,7 +10,11 @@ checked_in_ts_project(
visibility = ["//visibility:public"],
deps = ["@npm//@types/node"],
)

# END-INTERNAL
exports_files([
"lcov_merger-js.js",
])

nodejs_binary(
name = "lcov_merger_js",
Expand Down
10 changes: 5 additions & 5 deletions internal/js_library/js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ def _impl(ctx):
_js_library = rule(
implementation = _impl,
attrs = {
"package_name": attr.string(),
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
),
"amd_names": attr.string_dict(doc = _AMD_NAMES_DOC),
"is_windows": attr.bool(mandatory = True, doc = "Automatically set by macro"),
# module_name for legacy ts_library module_mapping support
# TODO: remove once legacy module_mapping is removed
"module_name": attr.string(),
"package_name": attr.string(),
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
),
},
)

Expand Down
4 changes: 2 additions & 2 deletions internal/linker/test/integration/rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def _linked(ctx):
)

linked = rule(_linked, attrs = {
"out": attr.output(),
"program": attr.label(executable = True, cfg = "host", mandatory = True),
"deps": attr.label_list(
allow_files = True,
aspects = [module_mappings_aspect],
),
"out": attr.output(),
"program": attr.label(executable = True, cfg = "host", mandatory = True),
})
2 changes: 1 addition & 1 deletion internal/node/npm_package_bin.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load("//internal/linker:link_node_modules.bzl", "module_mappings_aspect")
# Note: this API is chosen to match nodejs_binary
# so that we can generate macros that act as either an output-producing tool or an executable
_ATTRS = {
"outs": attr.output_list(),
"args": attr.string_list(mandatory = True),
"configuration_env_vars": attr.string_list(default = []),
"data": attr.label_list(allow_files = True, aspects = [module_mappings_aspect, node_modules_aspect]),
"output_dir": attr.bool(),
"outs": attr.output_list(),
"tool": attr.label(
executable = True,
cfg = "host",
Expand Down
10 changes: 5 additions & 5 deletions internal/npm_install/node_module_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ def _node_module_library_impl(ctx):
node_module_library = rule(
implementation = _node_module_library_impl,
attrs = {
"srcs": attr.label_list(
doc = "The list of files that comprise the package",
allow_files = True,
"deps": attr.label_list(
doc = "Transitive dependencies of the package",
),
"named_module_srcs": attr.label_list(
doc = "A subset of srcs that are javascript named-UMD or named-AMD for use in rules such as ts_devserver",
allow_files = True,
),
"deps": attr.label_list(
doc = "Transitive dependencies of the package",
"srcs": attr.label_list(
doc = "The list of files that comprise the package",
allow_files = True,
),
},
doc = "Defines an npm package under node_modules",
Expand Down
8 changes: 4 additions & 4 deletions internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ load("//internal/common:os_name.bzl", "is_windows_os", "os_name")
load("//internal/node:node_labels.bzl", "get_node_label", "get_npm_label", "get_yarn_label")

COMMON_ATTRIBUTES = dict(dict(), **{
"timeout": attr.int(
default = 3600,
doc = """Maximum duration of the package manager execution in seconds.""",
),
"data": attr.label_list(
doc = """Data files required by this rule.
Expand Down Expand Up @@ -104,6 +100,10 @@ data attribute.
""",
default = True,
),
"timeout": attr.int(
default = 3600,
doc = """Maximum duration of the package manager execution in seconds.""",
),
})

def _create_build_files(repository_ctx, rule_type, node, lock_file):
Expand Down
8 changes: 4 additions & 4 deletions internal/npm_install/npm_umd_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def _npm_umd_bundle(ctx):
]

NPM_UMD_ATTRS = {
"package_name": attr.string(
doc = """The name of the npm package""",
mandatory = True,
),
"entry_point": attr.label(
doc = """Entry point for the npm package""",
mandatory = True,
Expand Down Expand Up @@ -93,6 +89,10 @@ This target would be then be used instead of the generated `@npm//typeorm:typeor
mandatory = True,
aspects = [node_modules_aspect],
),
"package_name": attr.string(
doc = """The name of the npm package""",
mandatory = True,
),
"_browserify_wrapped": attr.label(
executable = True,
cfg = "host",
Expand Down
18 changes: 9 additions & 9 deletions internal/pkg_npm/pkg_npm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ You can pass arguments to npm by escaping them from Bazel using a double-hyphen,

# Used in angular/angular /packages/bazel/src/ng_package/ng_package.bzl
PKG_NPM_ATTRS = {
"package_name": attr.string(
doc = """Optional package_name that this npm package may be imported as.""",
),
"srcs": attr.label_list(
doc = """Files inside this directory which are simply copied into the package.""",
"deps": attr.label_list(
doc = """Other targets which produce files that should be included in the package, such as `rollup_bundle`""",
allow_files = True,
),
"nested_packages": attr.label_list(
Expand All @@ -90,22 +87,25 @@ PKG_NPM_ATTRS = {
providers = [NodeContextInfo],
doc = "Internal use only",
),
"package_name": attr.string(
doc = """Optional package_name that this npm package may be imported as.""",
),
"replace_with_version": attr.string(
doc = """If set this value is replaced with the version stamp data.
See the section on stamping in the README.""",
default = "0.0.0-PLACEHOLDER",
),
"srcs": attr.label_list(
doc = """Files inside this directory which are simply copied into the package.""",
allow_files = True,
),
"substitutions": attr.string_dict(
doc = """Key-value pairs which are replaced in all the files while building the package.""",
),
"vendor_external": attr.string_list(
doc = """External workspaces whose contents should be vendored into this workspace.
Avoids 'external/foo' path segments in the resulting package.""",
),
"deps": attr.label_list(
doc = """Other targets which produce files that should be included in the package, such as `rollup_bundle`""",
allow_files = True,
),
"_npm_script_generator": attr.label(
default = Label("//internal/pkg_npm:npm_script_generator"),
cfg = "host",
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg_web/pkg_web.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
_DOC = """Assembles a web application from source files."""

_ATTRS = {
"additional_root_paths": attr.string_list(
doc = """Path prefixes to strip off all srcs, in addition to the current package. Longest wins.""",
),
"srcs": attr.label_list(
allow_files = True,
doc = """Files which should be copied into the package""",
),
"additional_root_paths": attr.string_list(
doc = """Path prefixes to strip off all srcs, in addition to the current package. Longest wins.""",
),
"_assembler": attr.label(
default = "@build_bazel_rules_nodejs//internal/pkg_web:assembler",
executable = True,
Expand Down
2 changes: 1 addition & 1 deletion internal/providers/linkable_package_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
LinkablePackageInfo = provider(
doc = "A doc string",
fields = {
"files": "Depset of files in this package (must all be contained within path)",
"package_name": """The package name.
Should be the same as name field in the package's package.json.
In the future, the linker may validate that the names match the name in a package.json file.
""",
"files": "Depset of files in this package (must all be contained within path)",
"path": """The path to link to.
Path must be relative to execroot/wksp. It can either an output dir path such as,
Expand Down
2 changes: 1 addition & 1 deletion internal/providers/node_runtime_deps_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ tree will exist on disk, so we assume node actions/binary/test executions will
do the same.
""",
fields = {
"pkgs": "list of labels of packages that provide NpmPackageInfo",
"deps": "depset of runtime dependency labels",
"pkgs": "list of labels of packages that provide NpmPackageInfo",
},
)

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@bazel/bazelisk": "^1.4.0",
"@bazel/buildifier": "^0.26.0",
"@bazel/buildozer": "^0.29.0",
"@bazel/ibazel": "^0.10.3",
"@bazel/bazelisk": "^1.5.0",
"@bazel/buildifier": "^3.2.0",
"@bazel/buildozer": "^3.2.0",
"@bazel/ibazel": "^0.13.1",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@gregmagolan/test-a": "0.0.5",
Expand Down
28 changes: 14 additions & 14 deletions packages/karma/karma_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ KARMA_PEER_DEPS = [
]

KARMA_WEB_TEST_ATTRS = {
"srcs": attr.label_list(
doc = "A list of JavaScript test files",
allow_files = [".js"],
),
"bootstrap": attr.label_list(
doc = """JavaScript files to include *before* the module loader (require.js).
For example, you can include Reflect,js for TypeScript decorator metadata reflection,
Expand All @@ -60,6 +56,11 @@ KARMA_WEB_TEST_ATTRS = {
doc = "Runtime dependencies",
allow_files = True,
),
"deps": attr.label_list(
doc = "Other targets which produce JavaScript such as `ts_library`",
allow_files = True,
aspects = [node_modules_aspect],
),
"karma": attr.label(
doc = "karma binary label",
# NB: replaced during pkg_npm with "@npm//karma/bin:karma"
Expand All @@ -68,24 +69,23 @@ KARMA_WEB_TEST_ATTRS = {
cfg = "target",
allow_files = True,
),
"static_files": attr.label_list(
doc = """Arbitrary files which are available to be served on request.
Files are served at:
`/base/<WORKSPACE_NAME>/<path-to-file>`, e.g.
`/base/npm_bazel_typescript/examples/testing/static_script.js`""",
allow_files = True,
),
"runtime_deps": attr.label_list(
doc = """Dependencies which should be loaded after the module loader but before the srcs and deps.
These should be a list of targets which produce JavaScript such as `ts_library`.
The files will be loaded in the same order they are declared by that rule.""",
allow_files = True,
aspects = [node_modules_aspect],
),
"deps": attr.label_list(
doc = "Other targets which produce JavaScript such as `ts_library`",
"srcs": attr.label_list(
doc = "A list of JavaScript test files",
allow_files = [".js"],
),
"static_files": attr.label_list(
doc = """Arbitrary files which are available to be served on request.
Files are served at:
`/base/<WORKSPACE_NAME>/<path-to-file>`, e.g.
`/base/npm_bazel_typescript/examples/testing/static_script.js`""",
allow_files = True,
aspects = [node_modules_aspect],
),
"_conf_tmpl": attr.label(
default = "//packages/karma:karma.conf.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/labs/protobufjs/ts_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def _ts_proto_library(ctx):
ts_proto_library = rule(
implementation = _ts_proto_library,
attrs = {
"deps": attr.label_list(doc = "proto_library targets"),
"output_name": attr.string(
doc = """Name of the resulting module, which you will import from.
If not specified, the name will match the target's name.""",
),
"deps": attr.label_list(doc = "proto_library targets"),
"_pbjs": attr.label(
default = Label("//packages/labs/protobufjs:pbjs"),
executable = True,
Expand Down
16 changes: 8 additions & 8 deletions packages/protractor/protractor_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ _protractor_web_test = rule(
outputs = {"script": "%{name}.sh"},
toolchains = ["@bazel_tools//tools/sh:toolchain_type"],
attrs = {
"srcs": attr.label_list(
doc = "A list of JavaScript test files",
allow_files = [".js"],
),
"configuration": attr.label(
doc = "Protractor configuration file",
allow_single_file = True,
Expand All @@ -195,6 +191,11 @@ _protractor_web_test = rule(
doc = "Runtime dependencies",
allow_files = True,
),
"deps": attr.label_list(
doc = "Other targets which produce JavaScript such as `ts_library`",
allow_files = True,
aspects = [node_modules_aspect],
),
"on_prepare": attr.label(
doc = """A file with a node.js script to run once before all tests run.
If the script exports a function which returns a promise, protractor
Expand All @@ -213,10 +214,9 @@ _protractor_web_test = rule(
cfg = "target",
allow_files = True,
),
"deps": attr.label_list(
doc = "Other targets which produce JavaScript such as `ts_library`",
allow_files = True,
aspects = [node_modules_aspect],
"srcs": attr.label_list(
doc = "A list of JavaScript test files",
allow_files = [".js"],
),
"_conf_tmpl": attr.label(
default = Label("//packages/protractor:protractor.conf.js"),
Expand Down
Loading

0 comments on commit 3824ccf

Please sign in to comment.