Skip to content

Commit

Permalink
Add missing rules_shell declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrindel committed Dec 25, 2024
1 parent e90e9a3 commit 34114d4
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 139 deletions.
37 changes: 22 additions & 15 deletions bazel_integration_test/private/bazel_binaries_script.template
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#!/bin/bash
# vi: ft=sh

# --- 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
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 || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: ${BASH_SOURCE[0]} cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

export USE_BAZEL_VERSION="{version}"

# Need to write data here, the default is read-only inside tests.
Expand All @@ -20,10 +9,28 @@ if [[ -z "${BAZELISK_HOME:-}" ]]; then
fi

# Find the bazelisk binary, if it has not already been found.
if [[ -z "${BAZELISK_BINARY:-}" ]]; then
BAZELISK_BINARY="$(rlocation {bazelisk})" || \
#
# Code that uses cgrindel/bazel-starlib's updatesrc utilities can execute Bazel
# invocations from directories that cannot find the runfiles. The first
# invocation will find the BIT_BAZELISK_BINARY. So, we export the value so that
# subsequent invocations can find it. This allows us to forgo the runfiles
# evaluation for this script in those cases.
if [[ -z "${BIT_BAZELISK_BINARY:-}" ]]; then
# --- 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
# shellcheck disable=SC1090
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 || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: ${BASH_SOURCE[0]} cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

BIT_BAZELISK_BINARY="$(rlocation {bazelisk})" || \
(echo >&2 "Failed to locate bazelisk at {bazelisk}" && exit 1)
export BAZELISK_BINARY
export BIT_BAZELISK_BINARY
fi

exec "${BAZELISK_BINARY}" ${BIT_STARTUP_OPTIONS:-} "$@"
exec "${BIT_BAZELISK_BINARY}" ${BIT_STARTUP_OPTIONS:-} "$@"
83 changes: 1 addition & 82 deletions examples/custom_test_runner/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,82 +1 @@
workspace(name = "custom_test_runner_example")

# MARK: - rules_bazel_integration_test

local_repository(
name = "rules_bazel_integration_test",
path = "../..",
)

load("@rules_bazel_integration_test//bazel_integration_test:deps.bzl", "bazel_integration_test_rules_dependencies")

bazel_integration_test_rules_dependencies()

load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")

bazel_starlib_dependencies()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@rules_bazel_integration_test//bazel_integration_test:defs.bzl", "bazel_binaries")

bazel_binaries(versions = ["//:.bazelversion"])

# MARK: - rules_swift and swift_bazel

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_swift_package_manager",
sha256 = "17319e76637ecfd0f8f8081fa9d08feec225f883170b6bd55ad1a4182dfb5466",
urls = [
"https://github.com/cgrindel/rules_swift_package_manager/releases/download/v0.43.0/rules_swift_package_manager.v0.43.0.tar.gz",
],
)

load("@rules_swift_package_manager//:deps.bzl", "swift_bazel_dependencies")

swift_bazel_dependencies()

http_archive(
name = "build_bazel_rules_swift",
sha256 = "5bb49e7a1764f3f227677c572d6487b5bfeb2613eaaae2a82b240d9b836a0b4e",
url = "https://github.com/bazelbuild/rules_swift/releases/download/2.3.1/rules_swift.2.3.1.tar.gz",
)

load("//:swift_deps.bzl", "swift_dependencies")

# gazelle:repository_macro swift_deps.bzl%swift_dependencies
swift_dependencies()

load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)

swift_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

# MARK: - Gazelle

# gazelle:repo bazel_gazelle

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@rules_swift_package_manager//:go_deps.bzl", "swift_bazel_go_dependencies")

# Declare Go dependencies before calling go_rules_dependencies.
swift_bazel_go_dependencies()

go_rules_dependencies()

go_register_toolchains(version = "1.19.1")

gazelle_dependencies()
# Intentionally blank.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
module(
name = "test_workspace",
version = "0.0.0",
)

bazel_dep(name = "rules_shell", version = "0.3.0")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
workspace(name = "test_workspace")
# Intentionally blank.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel_dep(name = "rules_shell", version = "0.3.0")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally blank.
30 changes: 1 addition & 29 deletions examples/simple/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
workspace(name = "simple_example")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "cgrindel_bazel_starlib",
sha256 = "43e375213dabe0c3928e65412ea7ec16850db93285c8c6f8b0eaa41cacd0f882",
urls = [
"https://github.com/cgrindel/bazel-starlib/releases/download/v0.21.0/bazel-starlib.v0.21.0.tar.gz",
],
)

load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")

bazel_starlib_dependencies()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

# Buildifier Dependencies

load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()
# Intentionally blank.
2 changes: 2 additions & 0 deletions tests/e2e_tests/workspace/child_workspace/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ module(
name = "e2e_child",
version = "0.0.0",
)

bazel_dep(name = "rules_shell", version = "0.3.0")
7 changes: 1 addition & 6 deletions tests/params_tests/workspace/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
bazel_dep(name = "rules_shell", version = "0.3.0")

0 comments on commit 34114d4

Please sign in to comment.