From a3feac4adab51304dd0d6d1d339ebbd91f485f48 Mon Sep 17 00:00:00 2001 From: Daniel Muller Date: Wed, 1 May 2024 13:57:18 -0600 Subject: [PATCH] fix: Remove select statements from generated repo Using a select statement breaks things when the execution platform and host platform are mismatched --- cypress/BUILD.darwin.cypress | 17 +++++++++++++++ .../{BUILD.cypress => BUILD.linux.cypress} | 21 ++++--------------- cypress/repositories.bzl | 5 ++++- 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 cypress/BUILD.darwin.cypress rename cypress/{BUILD.cypress => BUILD.linux.cypress} (51%) diff --git a/cypress/BUILD.darwin.cypress b/cypress/BUILD.darwin.cypress new file mode 100644 index 0000000..925fb9d --- /dev/null +++ b/cypress/BUILD.darwin.cypress @@ -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", +) \ No newline at end of file diff --git a/cypress/BUILD.cypress b/cypress/BUILD.linux.cypress similarity index 51% rename from cypress/BUILD.cypress rename to cypress/BUILD.linux.cypress index 8176126..11129ec 100644 --- a/cypress/BUILD.cypress +++ b/cypress/BUILD.linux.cypress @@ -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"] ) @@ -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", ) \ No newline at end of file diff --git a/cypress/repositories.bzl b/cypress/repositories.bzl index 43f633e..0024ebb 100644 --- a/cypress/repositories.bzl +++ b/cypress/repositories.bzl @@ -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,