Skip to content

Commit

Permalink
refactor(builtin): vendor in runfiles.bash helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Mar 28, 2020
1 parent 2e049fc commit 8fd0bc2
Show file tree
Hide file tree
Showing 26 changed files with 425 additions and 22 deletions.
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ pkg_npm(
"//internal/pkg_npm:package_contents",
"//internal/pkg_web:package_contents",
"//internal/providers:package_contents",
"//third_party/github.com/bazelbuild/bazel:package_contents",
"//third_party/github.com/bazelbuild/bazel-skylib:package_contents",
"//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles:package_contents",
"//third_party/github.com/buffer-from:package_contents",
"//third_party/github.com/gjtorikian/isBinaryFile:package_contents",
"//third_party/github.com/juanjoDiaz/removeNPMAbsolutePaths:package_contents",
Expand Down
2 changes: 1 addition & 1 deletion internal/bazel_integration_test/bazel_integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ call :rlocation {TMPL_args} ARGS
launcher_content = """#!/usr/bin/env bash
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${{RUNFILES_DIR:-/dev/null}}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion internal/common/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sh_test(
":a",
"//third_party/github.com/bazelbuild/bazel-skylib:tests/unittest.bash",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
deps = ["@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles"],
)

copy_to_bin(
Expand Down
2 changes: 1 addition & 1 deletion internal/common/test/copy_to_bin_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion internal/linker/test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sh_binary(
"//internal/linker:index.js",
"//internal/linker/test/integration/static_linked_pkg",
"//internal/linker/test/integration/static_linked_scoped_pkg",
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
"@build_bazel_rules_nodejs//toolchains/node:node_bin",
],
)
Expand Down
2 changes: 1 addition & 1 deletion internal/linker/test/integration/run_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion internal/node/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
4 changes: 2 additions & 2 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _nodejs_binary_impl(ctx):

runfiles = []
runfiles.extend(node_tool_files)
runfiles.extend(ctx.files._bash_runfile_helpers)
runfiles.extend(ctx.files._bash_runfile_helper)
runfiles.append(ctx.outputs.loader_script)
runfiles.append(ctx.outputs.require_patch_script)
runfiles.append(ctx.file._repository_args)
Expand Down Expand Up @@ -444,7 +444,7 @@ jasmine_node_test(
`--node_options=--preserve-symlinks`
""",
),
"_bash_runfile_helpers": attr.label(default = Label("@bazel_tools//tools/bash/runfiles")),
"_bash_runfile_helper": attr.label(default = Label("@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles")),
"_launcher_template": attr.label(
default = Label("//internal/node:launcher.sh"),
allow_single_file = True,
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sh_test(
name = "bazel_bin_test",
srcs = ["bazel_bin_test.sh"],
data = [
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
"@npm//testy/bin:testy",
],
)
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/test/bazel_bin_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion packages/jasmine/src/jasmine_node_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def jasmine_node_test(
all_data = data + srcs + deps + [Label(jasmine)]

all_data += [":%s_devmode_srcs.MF" % name]
all_data += [Label("@bazel_tools//tools/bash/runfiles")]
all_data += [Label("@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles")]

# jasmine_runner.js consumes the first 3 args.
# The remaining target templated_args will be passed through to jasmine or
Expand Down
2 changes: 1 addition & 1 deletion packages/karma/src/karma_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _karma_web_test_impl(ctx):
content = """#!/usr/bin/env bash
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${{RUNFILES_DIR:-/dev/null}}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion packages/karma/test/stack_trace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sh_test(
srcs = ["test_sourcemap.sh"],
data = [
":karma_test_chromium-local",
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
],
tags = [
"browser:chromium-local",
Expand Down
2 changes: 1 addition & 1 deletion packages/protractor/src/protractor_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _protractor_web_test_impl(ctx):
content = """#!/usr/bin/env bash
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${{RUNFILES_DIR:-/dev/null}}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ ts_devserver = rule(
allow_files = True,
aspects = [node_modules_aspect],
),
"_bash_runfile_helpers": attr.label(default = Label("@bazel_tools//tools/bash/runfiles")),
"_bash_runfile_helpers": attr.label(default = Label("@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles")),
"_launcher_template": attr.label(allow_single_file = True, default = Label("//internal/devserver:launcher_template.sh")),
"_requirejs_script": attr.label(allow_single_file = True, default = Label("//third_party/npm/requirejs:require.js")),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/test/devmode_consumer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ sh_test(
srcs = ["devmode_consumer_test.sh"],
data = [
":devmode_consumer",
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/test/es6_consumer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ sh_test(
srcs = ["es6_output_test.sh"],
data = [
":es6_output",
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
],
)
2 changes: 1 addition & 1 deletion packages/typescript/test/es6_consumer/es6_output_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/test/some_module/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ sh_test(
srcs = ["module_load_test.sh"],
data = [
":bin",
"@bazel_tools//tools/bash/runfiles",
"@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
],
)
2 changes: 1 addition & 1 deletion packages/typescript/test/some_module/module_load_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
set -uo pipefail; f=build_bazel_rules_nodejs/third_party/github.com/bazelbuild/bazel/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
Expand Down
7 changes: 7 additions & 0 deletions third_party/github.com/bazelbuild/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
licenses(["notice"])

filegroup(
name = "package_contents",
srcs = glob(["**"]),
visibility = ["//:__pkg__"],
)
Loading

0 comments on commit 8fd0bc2

Please sign in to comment.