build: don't use deprecated $(location) pre-declared variable (#36308)
$(location) is not recommended in the bazel docs as depending on context it will either return the value of $(execpath) or $(rootpath). rules_nodejs now supports $(rootpath) and $(execpath) in templated_args of nodejs_binary. PR Close #36308
This commit is contained in:
parent
61e5ab4703
commit
c58e6ba13a
@ -23,8 +23,8 @@ genrule(
|
|||||||
],
|
],
|
||||||
outs = ["package.json"],
|
outs = ["package.json"],
|
||||||
cmd = """
|
cmd = """
|
||||||
$(location //tools:inline-package-json-deps) $(location tmpl-package.json) \
|
$(execpath //tools:inline-package-json-deps) $(execpath tmpl-package.json) \
|
||||||
$(location //:package.json) $@
|
$(execpath //:package.json) $@
|
||||||
""",
|
""",
|
||||||
tools = ["//tools:inline-package-json-deps"],
|
tools = ["//tools:inline-package-json-deps"],
|
||||||
)
|
)
|
||||||
|
@ -20,16 +20,16 @@ def circular_dependency_test(name, deps, entry_point, **kwargs):
|
|||||||
templated_args = [
|
templated_args = [
|
||||||
"--circular",
|
"--circular",
|
||||||
"--no-spinner",
|
"--no-spinner",
|
||||||
# NOTE: We cannot use `$(location)` to resolve labels. This is because `ts_library`
|
# NOTE: We cannot use `$(rootpath)` to resolve labels. This is because `ts_library`
|
||||||
# does not pre-declare outputs in the rule. Hence, the outputs cannot be referenced
|
# does not pre-declare outputs in the rule. Hence, the outputs cannot be referenced
|
||||||
# through labels (i.e. `//packages/core:index.js`). Read more here:
|
# through labels (i.e. `//packages/core:index.js`). Read more here:
|
||||||
# https://docs.bazel.build/versions/2.0.0/skylark/rules.html#outputs
|
# https://docs.bazel.build/versions/2.0.0/skylark/rules.html#outputs
|
||||||
# TODO: revisit once https://github.com/bazelbuild/rules_nodejs/issues/1563 is solved.
|
# TODO: revisit once https://github.com/bazelbuild/rules_nodejs/issues/1563 is solved.
|
||||||
"$(rlocation %s)" % entry_point,
|
"$$(rlocation %s)" % entry_point,
|
||||||
# Madge supports custom module resolution, but expects a configuration file
|
# Madge supports custom module resolution, but expects a configuration file
|
||||||
# similar to a Webpack configuration file setting the `resolve` option.
|
# similar to a Webpack configuration file setting the `resolve` option.
|
||||||
"--webpack-config",
|
"--webpack-config",
|
||||||
"$(rlocation $(location %s))" % MADGE_CONFIG_LABEL,
|
"$$(rlocation $(rootpath %s))" % MADGE_CONFIG_LABEL,
|
||||||
],
|
],
|
||||||
testonly = 1,
|
testonly = 1,
|
||||||
expected_exit_code = 0,
|
expected_exit_code = 0,
|
||||||
|
@ -340,7 +340,7 @@ def jasmine_node_test(bootstrap = [], **kwargs):
|
|||||||
templated_args = kwargs.pop("templated_args", [])
|
templated_args = kwargs.pop("templated_args", [])
|
||||||
for label in bootstrap:
|
for label in bootstrap:
|
||||||
deps += [label]
|
deps += [label]
|
||||||
templated_args += ["--node_options=--require=$(rlocation $(location %s))" % label]
|
templated_args += ["--node_options=--require=$$(rlocation $(rootpath %s))" % label]
|
||||||
if label.endswith("_es5"):
|
if label.endswith("_es5"):
|
||||||
# If this label is a filegroup derived from a ts_library then automatically
|
# If this label is a filegroup derived from a ts_library then automatically
|
||||||
# add the ts_library target (which is the label sans `_es5`) to deps so we pull
|
# add the ts_library target (which is the label sans `_es5`) to deps so we pull
|
||||||
|
@ -181,7 +181,7 @@ def npm_integration_test(name, **kwargs):
|
|||||||
name = name,
|
name = name,
|
||||||
data = data + npm_deps + [":%s.config" % name, ":%s.config.js" % name],
|
data = data + npm_deps + [":%s.config" % name, ":%s.config.js" % name],
|
||||||
tags = tags,
|
tags = tags,
|
||||||
templated_args = ["$(location :%s.config.js)" % name],
|
templated_args = ["$(rootpath :%s.config.js)" % name],
|
||||||
entry_point = "//tools/npm_integration_test:test_runner.js",
|
entry_point = "//tools/npm_integration_test:test_runner.js",
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
@ -192,7 +192,7 @@ def npm_integration_test(name, **kwargs):
|
|||||||
name = name + ".debug",
|
name = name + ".debug",
|
||||||
data = data + npm_deps + [":%s.debug.config" % name, ":%s.debug.config.js" % name],
|
data = data + npm_deps + [":%s.debug.config" % name, ":%s.debug.config.js" % name],
|
||||||
tags = tags + ["manual", "local"],
|
tags = tags + ["manual", "local"],
|
||||||
templated_args = ["$(location :%s.debug.config.js)" % name],
|
templated_args = ["$(rootpath :%s.debug.config.js)" % name],
|
||||||
entry_point = "//tools/npm_integration_test:test_runner.js",
|
entry_point = "//tools/npm_integration_test:test_runner.js",
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
@ -340,7 +340,7 @@ class TestRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = require(process.argv[2]);
|
const config = require(runfiles.resolveWorkspaceRelative(process.argv[2]));
|
||||||
|
|
||||||
// set env vars passed from --define
|
// set env vars passed from --define
|
||||||
for (const k of Object.keys(config.envVars)) {
|
for (const k of Object.keys(config.envVars)) {
|
||||||
|
@ -60,5 +60,5 @@ nodejs_binary(
|
|||||||
"@npm//shelljs",
|
"@npm//shelljs",
|
||||||
],
|
],
|
||||||
entry_point = "karma-saucelabs.js",
|
entry_point = "karma-saucelabs.js",
|
||||||
templated_args = ["$(location sauce-service.sh)"],
|
templated_args = ["$(rootpath sauce-service.sh)"],
|
||||||
)
|
)
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import {SymbolExtractor} from './symbol_extractor';
|
import {SymbolExtractor} from './symbol_extractor';
|
||||||
|
|
||||||
|
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER'] as string);
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
const args = process.argv.slice(2) as[string, string];
|
const args = process.argv.slice(2) as[string, string];
|
||||||
process.exitCode = main(args) ? 0 : 1;
|
process.exitCode = main(args) ? 0 : 1;
|
||||||
@ -22,8 +24,8 @@ if (require.main === module) {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
function main(argv: [string, string, string] | [string, string]): boolean {
|
function main(argv: [string, string, string] | [string, string]): boolean {
|
||||||
const javascriptFilePath = require.resolve(argv[0]);
|
const javascriptFilePath = runfiles.resolveWorkspaceRelative(argv[0]);
|
||||||
const goldenFilePath = require.resolve(argv[1]);
|
const goldenFilePath = runfiles.resolveWorkspaceRelative(argv[1]);
|
||||||
const doUpdate = argv[2] == '--accept';
|
const doUpdate = argv[2] == '--accept';
|
||||||
|
|
||||||
const javascriptContent = fs.readFileSync(javascriptFilePath).toString();
|
const javascriptContent = fs.readFileSync(javascriptFilePath).toString();
|
||||||
|
@ -24,7 +24,7 @@ def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
|
|||||||
name = name,
|
name = name,
|
||||||
data = all_data,
|
data = all_data,
|
||||||
entry_point = entry_point,
|
entry_point = entry_point,
|
||||||
templated_args = ["$(location %s)" % src, "$(location %s)" % golden],
|
templated_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden],
|
||||||
configuration_env_vars = ["angular_ivy_enabled"],
|
configuration_env_vars = ["angular_ivy_enabled"],
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
@ -35,6 +35,6 @@ def js_expected_symbol_test(name, src, golden, data = [], **kwargs):
|
|||||||
data = all_data,
|
data = all_data,
|
||||||
entry_point = entry_point,
|
entry_point = entry_point,
|
||||||
configuration_env_vars = ["angular_ivy_enabled"],
|
configuration_env_vars = ["angular_ivy_enabled"],
|
||||||
templated_args = ["$(location %s)" % src, "$(location %s)" % golden, "--accept"],
|
templated_args = ["$(rootpath %s)" % src, "$(rootpath %s)" % golden, "--accept"],
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user