Skip to content

Commit

Permalink
fix: Remove select statements from generated repo
Browse files Browse the repository at this point in the history
Using a select statement breaks things when the
execution platform and host platform are
mismatched
  • Loading branch information
mrmeku committed May 1, 2024
1 parent 5ccc974 commit a3feac4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
17 changes: 17 additions & 0 deletions cypress/BUILD.darwin.cypress
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# BUILD file inserted into the cypress toolchain repository

load("@aspect_rules_cypress//cypress:toolchain.bzl", "cypress_toolchain")
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")

filegroup(
name = "files",
srcs = ["Cypress.app", "binary_state.json"],
visibility = ["//visibility:public"],
)

cypress_toolchain(
name = "cypress_toolchain",
target_tool = "Cypress.app/Contents/MacOS/Cypress",
target_tool_files = ":files",
)
21 changes: 4 additions & 17 deletions cypress/BUILD.cypress → cypress/BUILD.linux.cypress
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ load("@aspect_rules_cypress//cypress:toolchain.bzl", "cypress_toolchain")
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")


# Copy the cypress binary directory to make it RBE compatible.
copy_directory(
name = "cypress_binary",
src = select({
"@bazel_tools//src/conditions:darwin": "Cypress.app",
"//conditions:default": "Cypress",
}),
out = select({
"@bazel_tools//src/conditions:darwin": "Cypress.app",
"//conditions:default": "Cypress",
}),
src = "Cypress",
out = "Cypress",
tags = ["manual"]
)

Expand All @@ -27,18 +20,12 @@ copy_to_bin(

filegroup(
name = "files",
srcs = select({
"@bazel_tools//src/conditions:darwin": ["Cypress.app", "binary_state.json"],
"//conditions:default": [":cypress_binary", ":binary_state_file"]
}),
srcs = [":cypress_binary", ":binary_state_file"],
visibility = ["//visibility:public"],
)

cypress_toolchain(
name = "cypress_toolchain",
target_tool = select({
"@bazel_tools//src/conditions:darwin": "Cypress.app/Contents/MacOS/Cypress",
"//conditions:default": "Cypress/Cypress",
}),
target_tool = "Cypress/Cypress",
target_tool_files = ":files",
)
5 changes: 4 additions & 1 deletion cypress/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def _cypress_repo_impl(repository_ctx):
repository_ctx.file("binary_state.json", binary_state_json_contents)

# Base BUILD file for this repository
repository_ctx.template("BUILD.bazel", Label("//cypress:BUILD.cypress"))
if repository_ctx.attr.platform.startswith("darwin-"):
repository_ctx.template("BUILD.bazel", Label("//cypress:BUILD.darwin.cypress"))
else:
repository_ctx.template("BUILD.bazel", Label("//cypress:BUILD.linux.cypress"))

cypress_repositories = repository_rule(
_cypress_repo_impl,
Expand Down

0 comments on commit a3feac4

Please sign in to comment.