From abb7be83eb1292b345b9436e39ab748fb39bbc2c Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Sat, 30 Nov 2024 21:56:14 -0800 Subject: [PATCH 1/3] Added `rust_wasm_bindgen_test` rule --- .bazelci/presubmit.yml | 20 +- extensions/wasm_bindgen/.gitignore | 3 + extensions/wasm_bindgen/3rdparty/BUILD.bazel | 16 + .../3rdparty/BUILD.wasm-bindgen-cli.bazel | 35 +- .../wasm_bindgen/3rdparty/Cargo.Bazel.lock | 78 ++++ .../wasm_bindgen/3rdparty/crates/BUILD.bazel | 24 + .../3rdparty/crates/BUILD.js-sys-0.3.77.bazel | 3 + .../3rdparty/crates/BUILD.minicov-0.3.7.bazel | 146 ++++++ .../crates/BUILD.same-file-1.0.6.bazel | 95 ++++ .../3rdparty/crates/BUILD.walkdir-2.5.0.bazel | 97 ++++ .../BUILD.wasm-bindgen-futures-0.4.50.bazel | 92 ++++ .../BUILD.wasm-bindgen-test-0.3.50.bazel | 95 ++++ ...BUILD.wasm-bindgen-test-macro-0.3.50.bazel | 88 ++++ .../crates/BUILD.web-sys-0.3.77.bazel | 87 ++++ .../wasm_bindgen/3rdparty/crates/defs.bzl | 76 ++++ .../wasm_bindgen/3rdparty/patches/BUILD.bazel | 0 .../wasm-bindgen-cli.webdriver_json.patch | 13 + extensions/wasm_bindgen/BUILD.bazel | 59 ++- extensions/wasm_bindgen/MODULE.bazel | 27 ++ extensions/wasm_bindgen/defs.bzl | 5 + extensions/wasm_bindgen/private/BUILD.bazel | 13 + .../wasm_bindgen/private/wasm_bindgen.bzl | 106 ++++- .../private/wasm_bindgen_test.bzl | 343 ++++++++++++++ .../private/wasm_bindgen_test_runner.rs | 187 ++++++++ .../private/webdrivers/BUILD.bazel | 12 + .../private/webdrivers/BUILD.chrome.bazel | 36 ++ .../BUILD.chrome_headless_shell.bazel | 36 ++ .../webdrivers/BUILD.chromedriver.bazel | 36 ++ .../webdrivers/BUILD.geckodriver.bazel | 27 ++ .../webdrivers/webdriver_repositories.bzl | 418 ++++++++++++++++++ extensions/wasm_bindgen/repositories.bzl | 6 + extensions/wasm_bindgen/rules_js/defs.bzl | 14 +- extensions/wasm_bindgen/test/BUILD.bazel | 27 +- extensions/wasm_bindgen/test/main.rs | 15 + extensions/wasm_bindgen/webdriver.json | 9 + 35 files changed, 2310 insertions(+), 34 deletions(-) create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.minicov-0.3.7.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.same-file-1.0.6.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.walkdir-2.5.0.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-futures-0.4.50.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-0.3.50.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-macro-0.3.50.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/crates/BUILD.web-sys-0.3.77.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/patches/BUILD.bazel create mode 100644 extensions/wasm_bindgen/3rdparty/patches/wasm-bindgen-cli.webdriver_json.patch create mode 100644 extensions/wasm_bindgen/private/wasm_bindgen_test.bzl create mode 100644 extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs create mode 100644 extensions/wasm_bindgen/private/webdrivers/BUILD.bazel create mode 100644 extensions/wasm_bindgen/private/webdrivers/BUILD.chrome.bazel create mode 100644 extensions/wasm_bindgen/private/webdrivers/BUILD.chrome_headless_shell.bazel create mode 100644 extensions/wasm_bindgen/private/webdrivers/BUILD.chromedriver.bazel create mode 100644 extensions/wasm_bindgen/private/webdrivers/BUILD.geckodriver.bazel create mode 100644 extensions/wasm_bindgen/private/webdrivers/webdriver_repositories.bzl create mode 100644 extensions/wasm_bindgen/webdriver.json diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 0003e2b36d..c487b16a16 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1073,12 +1073,15 @@ tasks: platform: ubuntu2004 name: Extensions wasm-bindgen working_directory: extensions/wasm_bindgen + shell_commands: + - "sudo apt -y update && sudo apt -y install libxcb1 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libxkbcommon-x11-0 libcairo2" build_flags: *aspects_flags test_flags: *aspects_flags build_targets: - "//..." - test_targets: - - "//..." + # TODO: Chromedriver cannot launch chrome on linux + # test_targets: + # - "//..." extensions_wasm_bindgen_linux_rbe: platform: rbe_ubuntu2004 name: Extensions wasm-bindgen @@ -1090,12 +1093,13 @@ tasks: test_flags: *aspects_flags build_targets: - "//..." - test_targets: - - "--" - - "//..." - # TODO: https://github.com/bazelbuild/rules_rust/issues/3039 - - "-//rules_js/test:hello_world_wasm_lib_test" - - "-//rules_js/test:hello_world_wasm_direct_test" + # TODO: Chromedriver cannot launch chrome on linux + # test_targets: + # - "--" + # - "//..." + # # TODO: https://github.com/bazelbuild/rules_rust/issues/3039 + # - "-//rules_js/test:hello_world_wasm_lib_test" + # - "-//rules_js/test:hello_world_wasm_direct_test" extensions_wasm_bindgen_macos: platform: macos_arm64 name: Extensions wasm-bindgen diff --git a/extensions/wasm_bindgen/.gitignore b/extensions/wasm_bindgen/.gitignore index 8bbbb50386..5d0ef67187 100644 --- a/extensions/wasm_bindgen/.gitignore +++ b/extensions/wasm_bindgen/.gitignore @@ -4,6 +4,9 @@ /bazel-* user.bazelrc +# Test Browsers +browsers/ + # rust-analyzer rust-project.json diff --git a/extensions/wasm_bindgen/3rdparty/BUILD.bazel b/extensions/wasm_bindgen/3rdparty/BUILD.bazel index 7981723da6..dd1868506c 100644 --- a/extensions/wasm_bindgen/3rdparty/BUILD.bazel +++ b/extensions/wasm_bindgen/3rdparty/BUILD.bazel @@ -33,6 +33,9 @@ crates_vendor( "wasm-bindgen": crate.spec( version = WASM_BINDGEN_VERSION, ), + "wasm-bindgen-test": crate.spec( + version = "0.3.37", + ), }, # Shorten the repository name to avoid MAX_PATH issues on Windows # `rules_rust_wasm_bindgen_deps` == `rrwbd` @@ -47,12 +50,25 @@ alias( visibility = ["//visibility:public"], ) +alias( + name = "wasm_bindgen_test_runner", + actual = "@rules_rust_wasm_bindgen_cli//:test_runner", + tags = ["manual"], + visibility = ["//visibility:public"], +) + alias( name = "wasm_bindgen", actual = "//3rdparty/crates:wasm-bindgen", visibility = ["//visibility:public"], ) +alias( + name = "wasm_bindgen_test", + actual = "//3rdparty/crates:wasm-bindgen-test", + visibility = ["//visibility:public"], +) + bzl_library( name = "bzl_lib", srcs = [ diff --git a/extensions/wasm_bindgen/3rdparty/BUILD.wasm-bindgen-cli.bazel b/extensions/wasm_bindgen/3rdparty/BUILD.wasm-bindgen-cli.bazel index 93617e4c4f..dff0d48ad5 100644 --- a/extensions/wasm_bindgen/3rdparty/BUILD.wasm-bindgen-cli.bazel +++ b/extensions/wasm_bindgen/3rdparty/BUILD.wasm-bindgen-cli.bazel @@ -12,7 +12,10 @@ exports_files([ # TODO: Comment on bootstrapping rust_binary( name = "wasm-bindgen-cli", - srcs = glob(["**/*.rs"]), + srcs = glob( + include = ["**/*.rs"], + exclude = ["src/bin/wasm-bindgen-test-runner/**"], + ), aliases = aliases(), crate_features = [ ], @@ -33,3 +36,33 @@ alias( actual = ":wasm-bindgen-cli", tags = ["manual"], ) + +rust_binary( + name = "wasm-bindgen-test-runner", + srcs = glob( + include = ["**/*.rs"], + exclude = ["src/bin/wasm-bindgen.rs"], + ), + aliases = aliases(), + compile_data = glob([ + "**/*.html", + ]), + crate_features = [ + ], + crate_root = "src/bin/wasm-bindgen-test-runner/main.rs", + data = [], + edition = "2018", + proc_macro_deps = all_crate_deps(proc_macro = True), + rustc_flags = [ + # Don't produce warnings for this crate + "--cap-lints=allow", + ], + version = WASM_BINDGEN_VERSION, + deps = all_crate_deps(), +) + +alias( + name = "test_runner", + actual = ":wasm-bindgen-test-runner", + tags = ["manual"], +) diff --git a/extensions/wasm_bindgen/3rdparty/Cargo.Bazel.lock b/extensions/wasm_bindgen/3rdparty/Cargo.Bazel.lock index 3b62821ea3..968a7f1e32 100644 --- a/extensions/wasm_bindgen/3rdparty/Cargo.Bazel.lock +++ b/extensions/wasm_bindgen/3rdparty/Cargo.Bazel.lock @@ -833,6 +833,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "miniz_oxide" version = "0.8.2" @@ -1252,6 +1262,15 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.27" @@ -1562,6 +1581,16 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "walrus" version = "0.23.3" @@ -1640,12 +1669,14 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shlex", "tempfile", "ureq", "walrus", "wasm-bindgen", "wasm-bindgen-cli-support", "wasm-bindgen-shared", + "wasm-bindgen-test", "wasmparser", "wasmprinter", ] @@ -1683,6 +1714,19 @@ dependencies = [ "wasm-bindgen-wasm-conventions", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.100" @@ -1726,6 +1770,30 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-bindgen-test" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" +dependencies = [ + "js-sys", + "minicov", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasm-bindgen-threads-xform" version = "0.2.100" @@ -1796,6 +1864,16 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.7" diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.bazel index ceb82812ec..53b6f0e987 100644 --- a/extensions/wasm_bindgen/3rdparty/crates/BUILD.bazel +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.bazel @@ -175,6 +175,18 @@ alias( tags = ["manual"], ) +alias( + name = "shlex-1.3.0", + actual = "@rrwbd__shlex-1.3.0//:shlex", + tags = ["manual"], +) + +alias( + name = "shlex", + actual = "@rrwbd__shlex-1.3.0//:shlex", + tags = ["manual"], +) + alias( name = "tempfile-3.15.0", actual = "@rrwbd__tempfile-3.15.0//:tempfile", @@ -247,6 +259,18 @@ alias( tags = ["manual"], ) +alias( + name = "wasm-bindgen-test-0.3.50", + actual = "@rrwbd__wasm-bindgen-test-0.3.50//:wasm_bindgen_test", + tags = ["manual"], +) + +alias( + name = "wasm-bindgen-test", + actual = "@rrwbd__wasm-bindgen-test-0.3.50//:wasm_bindgen_test", + tags = ["manual"], +) + alias( name = "wasmparser-0.214.0", actual = "@rrwbd__wasmparser-0.214.0//:wasmparser", diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.js-sys-0.3.77.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.js-sys-0.3.77.bazel index ea1940413b..eddd122915 100644 --- a/extensions/wasm_bindgen/3rdparty/crates/BUILD.js-sys-0.3.77.bazel +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.js-sys-0.3.77.bazel @@ -28,6 +28,9 @@ rust_library( "WORKSPACE.bazel", ], ), + crate_features = [ + "std", + ], crate_root = "src/lib.rs", edition = "2021", rustc_flags = [ diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.minicov-0.3.7.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.minicov-0.3.7.bazel new file mode 100644 index 0000000000..5567adf257 --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.minicov-0.3.7.bazel @@ -0,0 +1,146 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "minicov", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=minicov", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.3.7", + deps = [ + "@rrwbd__minicov-0.3.7//:build_script_build", + ], +) + +cargo_build_script( + name = "_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + "**/*.rs", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + pkg_name = "minicov", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=minicov", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.7", + visibility = ["//visibility:private"], + deps = [ + "@rrwbd__cc-1.2.7//:cc", + "@rrwbd__walkdir-2.5.0//:walkdir", + ], +) + +alias( + name = "build_script_build", + actual = ":_bs", + tags = ["manual"], +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.same-file-1.0.6.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.same-file-1.0.6.bazel new file mode 100644 index 0000000000..545317a13c --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.same-file-1.0.6.bazel @@ -0,0 +1,95 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "same_file", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=same-file", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "1.0.6", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.walkdir-2.5.0.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.walkdir-2.5.0.bazel new file mode 100644 index 0000000000..d8dd9e1152 --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.walkdir-2.5.0.bazel @@ -0,0 +1,97 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "walkdir", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=walkdir", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "2.5.0", + deps = [ + "@rrwbd__same-file-1.0.6//:same_file", + ] + select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@rrwbd__winapi-util-0.1.9//:winapi_util", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-futures-0.4.50.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-futures-0.4.50.bazel new file mode 100644 index 0000000000..41a9f1fcf5 --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-futures-0.4.50.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasm_bindgen_futures", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasm-bindgen-futures", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.4.50", + deps = [ + "@rrwbd__cfg-if-1.0.0//:cfg_if", + "@rrwbd__js-sys-0.3.77//:js_sys", + "@rrwbd__once_cell-1.20.2//:once_cell", + "@rrwbd__wasm-bindgen-0.2.100//:wasm_bindgen", + ], +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-0.3.50.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-0.3.50.bazel new file mode 100644 index 0000000000..c8a2af7f7a --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-0.3.50.bazel @@ -0,0 +1,95 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "wasm_bindgen_test", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + proc_macro_deps = [ + "@rrwbd__wasm-bindgen-test-macro-0.3.50//:wasm_bindgen_test_macro", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasm-bindgen-test", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.3.50", + deps = [ + "@rrwbd__js-sys-0.3.77//:js_sys", + "@rrwbd__wasm-bindgen-0.2.100//:wasm_bindgen", + "@rrwbd__wasm-bindgen-futures-0.4.50//:wasm_bindgen_futures", + ], +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-macro-0.3.50.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-macro-0.3.50.bazel new file mode 100644 index 0000000000..cec123b15e --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.wasm-bindgen-test-macro-0.3.50.bazel @@ -0,0 +1,88 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_proc_macro") + +package(default_visibility = ["//visibility:public"]) + +rust_proc_macro( + name = "wasm_bindgen_test_macro", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=wasm-bindgen-test-macro", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.3.50", + deps = [ + "@rrwbd__proc-macro2-1.0.92//:proc_macro2", + "@rrwbd__quote-1.0.38//:quote", + "@rrwbd__syn-2.0.95//:syn", + ], +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/BUILD.web-sys-0.3.77.bazel b/extensions/wasm_bindgen/3rdparty/crates/BUILD.web-sys-0.3.77.bazel new file mode 100644 index 0000000000..ce51a4b06a --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/crates/BUILD.web-sys-0.3.77.bazel @@ -0,0 +1,87 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//3rdparty:crates_vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "web_sys", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=web-sys", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.3.77", + deps = [ + "@rrwbd__js-sys-0.3.77//:js_sys", + "@rrwbd__wasm-bindgen-0.2.100//:wasm_bindgen", + ], +) diff --git a/extensions/wasm_bindgen/3rdparty/crates/defs.bzl b/extensions/wasm_bindgen/3rdparty/crates/defs.bzl index ffbdafa964..7cf35c927a 100644 --- a/extensions/wasm_bindgen/3rdparty/crates/defs.bzl +++ b/extensions/wasm_bindgen/3rdparty/crates/defs.bzl @@ -302,12 +302,14 @@ _NORMAL_DEPENDENCIES = { "rouille": Label("@rrwbd//:rouille-3.6.2"), "serde": Label("@rrwbd//:serde-1.0.217"), "serde_json": Label("@rrwbd//:serde_json-1.0.135"), + "shlex": Label("@rrwbd//:shlex-1.3.0"), "tempfile": Label("@rrwbd//:tempfile-3.15.0"), "ureq": Label("@rrwbd//:ureq-2.12.1"), "walrus": Label("@rrwbd//:walrus-0.23.3"), "wasm-bindgen": Label("@rrwbd//:wasm-bindgen-0.2.100"), "wasm-bindgen-cli-support": Label("@rrwbd//:wasm-bindgen-cli-support-0.2.100"), "wasm-bindgen-shared": Label("@rrwbd//:wasm-bindgen-shared-0.2.100"), + "wasm-bindgen-test": Label("@rrwbd//:wasm-bindgen-test-0.3.50"), }, }, } @@ -407,6 +409,7 @@ _CONDITIONS = { "cfg(all(target_arch = \"aarch64\", target_env = \"msvc\", not(windows_raw_dylib)))": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], "cfg(all(target_arch = \"aarch64\", target_os = \"windows\"))": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], "cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))": ["@rules_rust//rust/platform:wasm32-unknown-unknown"], + "cfg(all(target_arch = \"wasm32\", wasm_bindgen_unstable_test_coverage))": [], "cfg(all(target_arch = \"x86\", target_env = \"gnu\", not(target_abi = \"llvm\"), not(windows_raw_dylib)))": ["@rules_rust//rust/platform:i686-unknown-linux-gnu"], "cfg(all(target_arch = \"x86\", target_env = \"msvc\", not(windows_raw_dylib)))": ["@rules_rust//rust/platform:i686-pc-windows-msvc"], "cfg(all(target_arch = \"x86_64\", target_env = \"gnu\", not(target_abi = \"llvm\"), not(windows_raw_dylib)))": ["@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], @@ -417,6 +420,7 @@ _CONDITIONS = { "cfg(any(unix, target_os = \"wasi\"))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-fuchsia", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:wasm32-wasip1", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-fuchsia", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], "cfg(not(all(target_arch = \"arm\", target_os = \"none\")))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-pc-windows-msvc", "@rules_rust//rust/platform:aarch64-unknown-fuchsia", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:aarch64-unknown-uefi", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-pc-windows-msvc", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:riscv32imc-unknown-none-elf", "@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:wasm32-unknown-unknown", "@rules_rust//rust/platform:wasm32-wasip1", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-pc-windows-msvc", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-fuchsia", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu", "@rules_rust//rust/platform:x86_64-unknown-none", "@rules_rust//rust/platform:x86_64-unknown-uefi"], "cfg(not(windows))": ["@rules_rust//rust/platform:aarch64-apple-darwin", "@rules_rust//rust/platform:aarch64-apple-ios", "@rules_rust//rust/platform:aarch64-apple-ios-sim", "@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:aarch64-unknown-fuchsia", "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu", "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710", "@rules_rust//rust/platform:aarch64-unknown-uefi", "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi", "@rules_rust//rust/platform:i686-apple-darwin", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:i686-unknown-freebsd", "@rules_rust//rust/platform:i686-unknown-linux-gnu", "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", "@rules_rust//rust/platform:riscv32imc-unknown-none-elf", "@rules_rust//rust/platform:riscv64gc-unknown-none-elf", "@rules_rust//rust/platform:s390x-unknown-linux-gnu", "@rules_rust//rust/platform:thumbv7em-none-eabi", "@rules_rust//rust/platform:thumbv8m.main-none-eabi", "@rules_rust//rust/platform:wasm32-unknown-unknown", "@rules_rust//rust/platform:wasm32-wasip1", "@rules_rust//rust/platform:x86_64-apple-darwin", "@rules_rust//rust/platform:x86_64-apple-ios", "@rules_rust//rust/platform:x86_64-linux-android", "@rules_rust//rust/platform:x86_64-unknown-freebsd", "@rules_rust//rust/platform:x86_64-unknown-fuchsia", "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu", "@rules_rust//rust/platform:x86_64-unknown-none", "@rules_rust//rust/platform:x86_64-unknown-uefi"], + "cfg(target_feature = \"atomics\")": [], "cfg(target_os = \"android\")": ["@rules_rust//rust/platform:aarch64-linux-android", "@rules_rust//rust/platform:armv7-linux-androideabi", "@rules_rust//rust/platform:i686-linux-android", "@rules_rust//rust/platform:x86_64-linux-android"], "cfg(target_os = \"haiku\")": [], "cfg(target_os = \"hermit\")": [], @@ -1390,6 +1394,16 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.mime_guess-2.0.5.bazel"), ) + maybe( + http_archive, + name = "rrwbd__minicov-0.3.7", + sha256 = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/minicov/0.3.7/download"], + strip_prefix = "minicov-0.3.7", + build_file = Label("//3rdparty/crates:BUILD.minicov-0.3.7.bazel"), + ) + maybe( http_archive, name = "rrwbd__miniz_oxide-0.8.2", @@ -1750,6 +1764,16 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.safemem-0.3.3.bazel"), ) + maybe( + http_archive, + name = "rrwbd__same-file-1.0.6", + sha256 = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502", + type = "tar.gz", + urls = ["https://static.crates.io/crates/same-file/1.0.6/download"], + strip_prefix = "same-file-1.0.6", + build_file = Label("//3rdparty/crates:BUILD.same-file-1.0.6.bazel"), + ) + maybe( http_archive, name = "rrwbd__semver-1.0.24", @@ -2070,6 +2094,16 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.wait-timeout-0.2.0.bazel"), ) + maybe( + http_archive, + name = "rrwbd__walkdir-2.5.0", + sha256 = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/walkdir/2.5.0/download"], + strip_prefix = "walkdir-2.5.0", + build_file = Label("//3rdparty/crates:BUILD.walkdir-2.5.0.bazel"), + ) + maybe( http_archive, name = "rrwbd__walrus-0.23.3", @@ -2140,6 +2174,16 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.wasm-bindgen-externref-xform-0.2.100.bazel"), ) + maybe( + http_archive, + name = "rrwbd__wasm-bindgen-futures-0.4.50", + sha256 = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasm-bindgen-futures/0.4.50/download"], + strip_prefix = "wasm-bindgen-futures-0.4.50", + build_file = Label("//3rdparty/crates:BUILD.wasm-bindgen-futures-0.4.50.bazel"), + ) + maybe( http_archive, name = "rrwbd__wasm-bindgen-macro-0.2.100", @@ -2180,6 +2224,26 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.wasm-bindgen-shared-0.2.100.bazel"), ) + maybe( + http_archive, + name = "rrwbd__wasm-bindgen-test-0.3.50", + sha256 = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasm-bindgen-test/0.3.50/download"], + strip_prefix = "wasm-bindgen-test-0.3.50", + build_file = Label("//3rdparty/crates:BUILD.wasm-bindgen-test-0.3.50.bazel"), + ) + + maybe( + http_archive, + name = "rrwbd__wasm-bindgen-test-macro-0.3.50", + sha256 = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b", + type = "tar.gz", + urls = ["https://static.crates.io/crates/wasm-bindgen-test-macro/0.3.50/download"], + strip_prefix = "wasm-bindgen-test-macro-0.3.50", + build_file = Label("//3rdparty/crates:BUILD.wasm-bindgen-test-macro-0.3.50.bazel"), + ) + maybe( http_archive, name = "rrwbd__wasm-bindgen-threads-xform-0.2.100", @@ -2240,6 +2304,16 @@ def crate_repositories(): build_file = Label("//3rdparty/crates:BUILD.wasmprinter-0.214.0.bazel"), ) + maybe( + http_archive, + name = "rrwbd__web-sys-0.3.77", + sha256 = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2", + type = "tar.gz", + urls = ["https://static.crates.io/crates/web-sys/0.3.77/download"], + strip_prefix = "web-sys-0.3.77", + build_file = Label("//3rdparty/crates:BUILD.web-sys-0.3.77.bazel"), + ) + maybe( http_archive, name = "rrwbd__webpki-roots-0.26.7", @@ -2499,12 +2573,14 @@ def crate_repositories(): struct(repo = "rrwbd__serde-1.0.217", is_dev_dep = False), struct(repo = "rrwbd__serde_derive-1.0.217", is_dev_dep = False), struct(repo = "rrwbd__serde_json-1.0.135", is_dev_dep = False), + struct(repo = "rrwbd__shlex-1.3.0", is_dev_dep = False), struct(repo = "rrwbd__tempfile-3.15.0", is_dev_dep = False), struct(repo = "rrwbd__ureq-2.12.1", is_dev_dep = False), struct(repo = "rrwbd__walrus-0.23.3", is_dev_dep = False), struct(repo = "rrwbd__wasm-bindgen-0.2.100", is_dev_dep = False), struct(repo = "rrwbd__wasm-bindgen-cli-support-0.2.100", is_dev_dep = False), struct(repo = "rrwbd__wasm-bindgen-shared-0.2.100", is_dev_dep = False), + struct(repo = "rrwbd__wasm-bindgen-test-0.3.50", is_dev_dep = False), struct(repo = "rrwbd__assert_cmd-2.0.16", is_dev_dep = True), struct(repo = "rrwbd__diff-0.1.13", is_dev_dep = True), struct(repo = "rrwbd__predicates-3.1.3", is_dev_dep = True), diff --git a/extensions/wasm_bindgen/3rdparty/patches/BUILD.bazel b/extensions/wasm_bindgen/3rdparty/patches/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/extensions/wasm_bindgen/3rdparty/patches/wasm-bindgen-cli.webdriver_json.patch b/extensions/wasm_bindgen/3rdparty/patches/wasm-bindgen-cli.webdriver_json.patch new file mode 100644 index 0000000000..73cdeecea8 --- /dev/null +++ b/extensions/wasm_bindgen/3rdparty/patches/wasm-bindgen-cli.webdriver_json.patch @@ -0,0 +1,13 @@ +diff --git a/src/bin/wasm-bindgen-test-runner/headless.rs b/src/bin/wasm-bindgen-test-runner/headless.rs +index d392293..7e5a77d 100644 +--- a/src/bin/wasm-bindgen-test-runner/headless.rs ++++ b/src/bin/wasm-bindgen-test-runner/headless.rs +@@ -126,7 +126,7 @@ pub fn run( + session: None, + }; + println!("Try find `webdriver.json` for configure browser's capabilities:"); +- let capabilities: Capabilities = match File::open("webdriver.json") { ++ let capabilities: Capabilities = match File::open(std::env::var("WASM_BINDGEN_WEBDRIVER_JSON").unwrap_or("webdriver.json".to_string())) { + Ok(file) => { + println!("Ok"); + serde_json::from_reader(file) diff --git a/extensions/wasm_bindgen/BUILD.bazel b/extensions/wasm_bindgen/BUILD.bazel index f1831da3b0..b2296528ee 100644 --- a/extensions/wasm_bindgen/BUILD.bazel +++ b/extensions/wasm_bindgen/BUILD.bazel @@ -1,20 +1,48 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("//:defs.bzl", "rust_wasm_bindgen_toolchain") - -package(default_visibility = ["//visibility:public"]) +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load(":defs.bzl", "rust_wasm_bindgen_toolchain") exports_files([ "defs.bzl", "MODULE.bazel", + "webdriver.json", ]) toolchain_type( name = "toolchain_type", + visibility = ["//visibility:public"], +) + +string_flag( + name = "test_browser", + build_setting_default = "chrome", + values = [ + "chrome", + "firefox", + ], + visibility = ["//visibility:public"], +) + +config_setting( + name = "test_browser_chrome", + flag_values = { + ":test_browser": "chrome", + }, + visibility = ["//visibility:public"], +) + +config_setting( + name = "test_browser_firefox", + flag_values = { + ":test_browser": "firefox", + }, + visibility = ["//visibility:public"], ) bzl_library( name = "bzl_lib", srcs = glob(["**/*.bzl"]), + visibility = ["//visibility:public"], deps = [ "//3rdparty:bzl_lib", "//private:bzl_lib", @@ -23,11 +51,32 @@ bzl_library( rust_wasm_bindgen_toolchain( name = "default_wasm_bindgen_toolchain_impl", - bindgen = "@rules_rust_wasm_bindgen//3rdparty:wasm_bindgen_cli", + browser = select({ + ":test_browser_chrome": "@chrome", + ":test_browser_firefox": "@firefox", + }), + browser_type = select({ + ":test_browser_chrome": "chrome", + ":test_browser_firefox": "firefox", + }), + visibility = ["//visibility:public"], + wasm_bindgen_cli = "//3rdparty:wasm_bindgen_cli", + wasm_bindgen_test = "//3rdparty:wasm_bindgen_test", + wasm_bindgen_test_runner = "//3rdparty:wasm_bindgen_test_runner", + webdriver = select({ + ":test_browser_chrome": "@chromedriver", + ":test_browser_firefox": "@geckodriver", + }), + webdriver_args = select({ + ":test_browser_chrome": ["--verbose"], + ":test_browser_firefox": [], + }), + webdriver_json = "webdriver.json", ) toolchain( name = "default_wasm_bindgen_toolchain", toolchain = "default_wasm_bindgen_toolchain_impl", - toolchain_type = "//:toolchain_type", + toolchain_type = ":toolchain_type", + visibility = ["//visibility:public"], ) diff --git a/extensions/wasm_bindgen/MODULE.bazel b/extensions/wasm_bindgen/MODULE.bazel index 5ef51eccd7..ed5592a842 100644 --- a/extensions/wasm_bindgen/MODULE.bazel +++ b/extensions/wasm_bindgen/MODULE.bazel @@ -15,6 +15,31 @@ bazel_dep(name = "aspect_rules_js", version = "2.1.2") rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( rust_ext, + "chrome", + "chrome_headless_shell", + "chrome_headless_shell_linux64", + "chrome_headless_shell_mac_arm64", + "chrome_headless_shell_mac_x64", + "chrome_headless_shell_win32", + "chrome_headless_shell_win64", + "chrome_linux64", + "chrome_mac_arm64", + "chrome_mac_x64", + "chrome_win32", + "chrome_win64", + "chromedriver", + "chromedriver_linux64", + "chromedriver_mac_arm64", + "chromedriver_mac_x64", + "chromedriver_win32", + "chromedriver_win64", + "firefox", + "geckodriver", + "geckodriver_linux64", + "geckodriver_linux_aarch64", + "geckodriver_macos", + "geckodriver_macos_aarch64", + "geckodriver_win64", "rrwbd", "rrwbd__anyhow-1.0.95", "rrwbd__assert_cmd-2.0.16", @@ -28,12 +53,14 @@ use_repo( "rrwbd__serde-1.0.217", "rrwbd__serde_derive-1.0.217", "rrwbd__serde_json-1.0.135", + "rrwbd__shlex-1.3.0", "rrwbd__tempfile-3.15.0", "rrwbd__ureq-2.12.1", "rrwbd__walrus-0.23.3", "rrwbd__wasm-bindgen-0.2.100", "rrwbd__wasm-bindgen-cli-support-0.2.100", "rrwbd__wasm-bindgen-shared-0.2.100", + "rrwbd__wasm-bindgen-test-0.3.50", "rrwbd__wasmparser-0.214.0", "rrwbd__wasmprinter-0.214.0", "rules_rust_wasm_bindgen_cli", diff --git a/extensions/wasm_bindgen/defs.bzl b/extensions/wasm_bindgen/defs.bzl index c838f80071..eeebf4c241 100644 --- a/extensions/wasm_bindgen/defs.bzl +++ b/extensions/wasm_bindgen/defs.bzl @@ -50,7 +50,12 @@ load( _rust_wasm_bindgen = "rust_wasm_bindgen", _rust_wasm_bindgen_toolchain = "rust_wasm_bindgen_toolchain", ) +load( + "//private:wasm_bindgen_test.bzl", + _rust_wasm_bindgen_test = "rust_wasm_bindgen_test", +) rust_wasm_bindgen = _rust_wasm_bindgen rust_wasm_bindgen_toolchain = _rust_wasm_bindgen_toolchain +rust_wasm_bindgen_test = _rust_wasm_bindgen_test RustWasmBindgenInfo = _RustWasmBindgenInfo diff --git a/extensions/wasm_bindgen/private/BUILD.bazel b/extensions/wasm_bindgen/private/BUILD.bazel index dae3c33e94..df2c6be51b 100644 --- a/extensions/wasm_bindgen/private/BUILD.bazel +++ b/extensions/wasm_bindgen/private/BUILD.bazel @@ -1,13 +1,26 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load("@rules_rust//rust:defs.bzl", "rust_binary") bzl_library( name = "bzl_lib", srcs = [ "transitions.bzl", "wasm_bindgen.bzl", + "wasm_bindgen_test.bzl", ], visibility = ["//:__pkg__"], deps = [ "@rules_rust//rust:bzl_lib", ], ) + +rust_binary( + name = "wasm_bindgen_test_runner", + srcs = ["wasm_bindgen_test_runner.rs"], + edition = "2021", + visibility = ["//visibility:public"], + deps = [ + "@rrwbd//:serde_json", + "@rules_rust//tools/runfiles", + ], +) diff --git a/extensions/wasm_bindgen/private/wasm_bindgen.bzl b/extensions/wasm_bindgen/private/wasm_bindgen.bzl index 9d421e536f..1c2355278a 100644 --- a/extensions/wasm_bindgen/private/wasm_bindgen.bzl +++ b/extensions/wasm_bindgen/private/wasm_bindgen.bzl @@ -122,17 +122,18 @@ def _rust_wasm_bindgen_impl(ctx): info, ] - if RustAnalyzerGroupInfo in ctx.attr.wasm_file: - providers.append(ctx.attr.wasm_file[RustAnalyzerGroupInfo]) + crate = ctx.attr.wasm_file[0] + if RustAnalyzerGroupInfo in crate: + providers.append(crate[RustAnalyzerGroupInfo]) - if RustAnalyzerInfo in ctx.attr.wasm_file: - providers.append(ctx.attr.wasm_file[RustAnalyzerInfo]) + if RustAnalyzerInfo in crate: + providers.append(crate[RustAnalyzerInfo]) - if ClippyInfo in ctx.attr.wasm_file: - providers.append(ctx.attr.wasm_file[ClippyInfo]) + if ClippyInfo in crate: + providers.append(crate[ClippyInfo]) - if OutputGroupInfo in ctx.attr.wasm_file: - output_info = ctx.attr.wasm_file[OutputGroupInfo] + if OutputGroupInfo in crate: + output_info = crate[OutputGroupInfo] output_groups = {} for group in ["rusfmt_checks", "clippy_checks", "rust_analyzer_crate_spec"]: if hasattr(output_info, group): @@ -160,8 +161,12 @@ WASM_BINDGEN_ATTR = { values = ["wasm32", "wasm64"], ), "wasm_file": attr.label( - doc = "The `.wasm` file or crate to generate bindings for.", + doc = "The `.wasm` crate to generate bindings for.", allow_single_file = True, + providers = [ + [rust_common.test_crate_info], + [rust_common.crate_info], + ], aspects = [ rust_analyzer_aspect, rustfmt_aspect, @@ -191,8 +196,45 @@ An example of this rule in use can be seen at [@rules_rust//examples/wasm](../ex ) def _rust_wasm_bindgen_toolchain_impl(ctx): + all_test_files = depset() + if ctx.attr.wasm_bindgen_test or ctx.attr.webdriver or ctx.attr.browser_type: + if not ctx.attr.wasm_bindgen_test: + fail("Not all webdriver attributes provided. Missing `wasm_bindgen_test` on `{}`".format(ctx.label)) + if not ctx.attr.webdriver: + fail("Not all webdriver attributes provided. Missing `webdriver` on `{}`".format(ctx.label)) + if not ctx.attr.browser_type: + fail("Not all webdriver attributes provided. Missing `browser_type` on `{}`".format(ctx.label)) + + all_depsets = [ + ctx.attr.webdriver[DefaultInfo].files, + ctx.attr.webdriver[DefaultInfo].default_runfiles.files, + ctx.attr.wasm_bindgen_test_runner[DefaultInfo].files, + ctx.attr.wasm_bindgen_test_runner[DefaultInfo].default_runfiles.files, + ctx.attr.webdriver_json[DefaultInfo].files, + ctx.attr.webdriver_json[DefaultInfo].default_runfiles.files, + ] + + if ctx.attr.browser: + all_depsets.extend([ + ctx.attr.browser[DefaultInfo].files, + ctx.attr.browser[DefaultInfo].default_runfiles.files, + ]) + + all_test_files = depset(transitive = all_depsets) + return platform_common.ToolchainInfo( - bindgen = ctx.executable.bindgen, + wasm_bindgen_cli = ctx.executable.wasm_bindgen_cli, + wasm_bindgen_test = ctx.attr.wasm_bindgen_test, + wasm_bindgen_test_runner = ctx.executable.wasm_bindgen_test_runner, + webdriver = ctx.executable.webdriver, + webdriver_args = ctx.attr.webdriver_args, + webdriver_json = ctx.file.webdriver_json, + browser_type = ctx.attr.browser_type, + browser = ctx.executable.browser, + all_test_files = all_test_files, + + # Deprecated + bindgen = ctx.executable.wasm_bindgen_cli, ) rust_wasm_bindgen_toolchain = rule( @@ -204,10 +246,10 @@ In cases where users want to control or change the version of `wasm-bindgen` use a unique toolchain can be created as in the example below: ```python -load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_toolchain") +load("@rules_rust_wasm_bindgen//:defs.bzl", "rust_wasm_bindgen_toolchain") -rust_bindgen_toolchain( - bindgen = "//3rdparty/crates:wasm_bindgen_cli__bin", +rust_wasm_bindgen_toolchain( + wasm_bindgen_cli = "//3rdparty/crates:wasm_bindgen_cli__bin", ) toolchain( @@ -229,10 +271,46 @@ For additional information, see the [Bazel toolchains documentation][toolchains] [toolchains]: https://docs.bazel.build/versions/master/toolchains.html """, attrs = { - "bindgen": attr.label( + "browser": attr.label( + doc = "The browser entrypoint.", + cfg = "exec", + executable = True, + allow_files = True, + ), + "browser_type": attr.string( + doc = "The type of browser provided.", + values = [ + "firefox", + "chrome", + ], + ), + "wasm_bindgen_cli": attr.label( doc = "The label of a `wasm-bindgen-cli` executable.", executable = True, cfg = "exec", ), + "wasm_bindgen_test": attr.label( + doc = "The label of a `wasm-bindgen-test` crate.", + cfg = "target", + ), + "wasm_bindgen_test_runner": attr.label( + doc = "The label of a `wasm-bindgen-test-runner` binary.", + executable = True, + cfg = "exec", + ), + "webdriver": attr.label( + doc = "The webdriver to use.", + executable = True, + allow_files = True, + cfg = "exec", + ), + "webdriver_args": attr.string_list( + doc = "Arguments to pass to the `webdriver` binary.", + ), + "webdriver_json": attr.label( + doc = "The [`webdriver.json` config file](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/browsers.html#configuring-headless-browser-capabilities) for wasm-bindgen-test.", + allow_single_file = [".json"], + cfg = "exec", + ), }, ) diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl new file mode 100644 index 0000000000..1ed803017d --- /dev/null +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl @@ -0,0 +1,343 @@ +"""Bazel test rules for [wasm-bindgen](https://crates.io/crates/wasm-bindgen)""" + +load("@rules_rust//rust:defs.bzl", "rust_common") + +# buildifier: disable=bzl-visibility +load("@rules_rust//rust/private:rust.bzl", "RUSTC_ATTRS", "get_rust_test_flags") + +# buildifier: disable=bzl-visibility +load("@rules_rust//rust/private:rustc.bzl", "rustc_compile_action") + +# buildifier: disable=bzl-visibility +# load("@rules_rust//rust/private:toolchain_utils.bzl", "get_coverage_env") + +# buildifier: disable=bzl-visibility +load( + "@rules_rust//rust/private:utils.bzl", + "determine_output_hash", + "expand_dict_value_locations", + "find_toolchain", + "generate_output_diagnostics", + "get_import_macro_deps", + "transform_deps", + "transform_sources", +) +load("//:providers.bzl", "RustWasmBindgenInfo") +load("//private:transitions.bzl", "wasm_bindgen_transition") + +WasmBindgenTestCrateInfo = provider( + doc = "A provider encompasing the crate from a `rust_wasm_bindgen` target.", + fields = { + "crate": "The underlying `rust_wasm_bindgen.crate`.", + }, +) + +def _wasm_bindgen_test_crate_aspect(target, ctx): + if WasmBindgenTestCrateInfo in target: + return [] + + crate = ctx.rule.attr.wasm_file[0] + if rust_common.test_crate_info in crate: + crate_info = crate[rust_common.test_crate_info].crate + elif rust_common.crate_info in crate: + crate_info = crate[rust_common.crate_info] + else: + fail("Unable to determine crate info from {}".format(crate)) + + return [WasmBindgenTestCrateInfo( + crate = crate_info, + )] + +wasm_bindgen_test_crate_aspect = aspect( + doc = "An aspect for accessing the underlying crate from a `rust_wasm_bindgen` target.", + implementation = _wasm_bindgen_test_crate_aspect, +) + +def _rlocationpath(file, workspace_name): + if file.short_path.startswith("../"): + return file.short_path[len("../"):] + + return "{}/{}".format(workspace_name, file.short_path) + +def _rust_wasm_bindgen_test_impl(ctx): + wb_toolchain = ctx.toolchains[Label("//:toolchain_type")] + if not wb_toolchain.webdriver: + fail("The currently registered wasm_bindgen_toolchain does not have a webdriver assigned. Tests are unavailable without one.") + + toolchain = find_toolchain(ctx) + + crate_type = "bin" + deps = transform_deps(ctx.attr.deps + [wb_toolchain.wasm_bindgen_test]) + proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps + get_import_macro_deps(ctx)) + + # Target is building the crate in `test` config + if WasmBindgenTestCrateInfo in ctx.attr.wasm: + crate = ctx.attr.wasm[WasmBindgenTestCrateInfo].crate + elif rust_common.test_crate_info in ctx.attr.wasm: + crate = ctx.attr.wasm[rust_common.test_crate_info].crate + elif rust_common.crate_info in ctx.attr.wasm: + crate = ctx.attr.wasm[rust_common.test_crate_info].crate + else: + fail("Unable to locate CrateInfo for target: {}".format(ctx.attr.wasm)) + + output_hash = determine_output_hash(crate.root, ctx.label) + output = ctx.actions.declare_file( + "test-%s/%s%s" % ( + output_hash, + ctx.label.name, + toolchain.binary_ext, + ), + ) + + srcs = crate.srcs.to_list() + compile_data = depset(ctx.files.compile_data, transitive = [crate.compile_data]).to_list() + srcs, compile_data, _crate_root = transform_sources(ctx, srcs, compile_data, None) + + # Optionally join compile data + if crate.compile_data: + compile_data = depset(ctx.files.compile_data, transitive = [crate.compile_data]) + else: + compile_data = depset(ctx.files.compile_data) + if crate.compile_data_targets: + compile_data_targets = depset(ctx.attr.compile_data, transitive = [crate.compile_data_targets]) + else: + compile_data_targets = depset(ctx.attr.compile_data) + rustc_env_files = ctx.files.rustc_env_files + crate.rustc_env_files + + # crate.rustc_env is already expanded upstream in rust_library rule implementation + rustc_env = dict(crate.rustc_env) + data_paths = depset(direct = getattr(ctx.attr, "data", [])).to_list() + rustc_env.update(expand_dict_value_locations( + ctx, + ctx.attr.rustc_env, + data_paths, + {}, + )) + aliases = dict(crate.aliases) + aliases.update(ctx.attr.aliases) + + # Build the test binary using the dependency's srcs. + crate_info_dict = dict( + name = crate.name, + type = crate_type, + root = crate.root, + srcs = depset(srcs, transitive = [crate.srcs]), + deps = depset(deps, transitive = [crate.deps]), + proc_macro_deps = depset(proc_macro_deps, transitive = [crate.proc_macro_deps]), + aliases = {}, + output = output, + rustc_output = generate_output_diagnostics(ctx, output), + edition = crate.edition, + rustc_env = rustc_env, + rustc_env_files = rustc_env_files, + is_test = True, + compile_data = compile_data, + compile_data_targets = compile_data_targets, + wrapped_crate_type = crate.type, + owner = ctx.label, + ) + + crate_providers = rustc_compile_action( + ctx = ctx, + attr = ctx.attr, + toolchain = toolchain, + crate_info_dict = crate_info_dict, + rust_flags = get_rust_test_flags(ctx.attr), + skip_expanding_rustc_env = True, + ) + data = getattr(ctx.attr, "data", []) + + env = expand_dict_value_locations( + ctx, + getattr(ctx.attr, "env", {}), + data, + {}, + ) + + # if ctx.configuration.coverage_enabled: + # env.update(get_coverage_env(toolchain)) + + components = "{}/{}".format(ctx.label.workspace_root, ctx.label.package).split("/") + env["CARGO_MANIFEST_DIR"] = "/".join([c for c in components if c]) + + runner = ctx.actions.declare_file(ctx.label.name) + ctx.actions.symlink( + output = runner, + target_file = ctx.executable._runner, + is_executable = True, + ) + + if wb_toolchain.browser: + env["BROWSER"] = _rlocationpath(wb_toolchain.browser, ctx.workspace_name) + + env["BROWSER_TYPE"] = wb_toolchain.browser_type + env["WEBDRIVER"] = _rlocationpath(wb_toolchain.webdriver, ctx.workspace_name) + env["WEBDRIVER_ARGS"] = json.encode(wb_toolchain.webdriver_args) + env["WEBDRIVER_JSON"] = _rlocationpath(wb_toolchain.webdriver_json, ctx.workspace_name) + env["WASM_BINDGEN_TEST_RUNNER"] = _rlocationpath(wb_toolchain.wasm_bindgen_test_runner, ctx.workspace_name) + + # Force the use of a browser for now as there is no node integration. + env["WASM_BINDGEN_USE_BROWSER"] = "1" + + providers = [] + + for prov in crate_providers: + if type(prov) == "DefaultInfo": + files = prov.files.to_list() + if len(files) != 1: + fail("Unexpected number of output files for `{}`: {}".format(ctx.label, files)) + wasm_file = files[0] + env["TEST_WASM_BINARY"] = _rlocationpath(files[0], ctx.workspace_name) + providers.append(DefaultInfo( + files = prov.files, + runfiles = prov.default_runfiles.merge(ctx.runfiles(files = [wasm_file], transitive_files = wb_toolchain.all_test_files)), + executable = runner, + )) + else: + providers.append(prov) + + providers.append(testing.TestEnvironment(env)) + + return providers + +rust_wasm_bindgen_test = rule( + doc = "Rules for running [wasm-bindgen tests](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/index.html).", + implementation = _rust_wasm_bindgen_test_impl, + cfg = wasm_bindgen_transition, + attrs = { + "aliases": attr.label_keyed_string_dict( + doc = """\ + Remap crates to a new name or moniker for linkage to this target + + These are other `rust_library` targets and will be presented as the new name given. + """, + ), + "compile_data": attr.label_list( + doc = """\ + List of files used by this rule at compile time. + + This attribute can be used to specify any data files that are embedded into + the library, such as via the + [`include_str!`](https://doc.rust-lang.org/std/macro.include_str!.html) + macro. + """, + allow_files = True, + ), + "crate_features": attr.string_list( + doc = """\ + List of features to enable for this crate. + + Features are defined in the code using the `#[cfg(feature = "foo")]` + configuration option. The features listed here will be passed to `rustc` + with `--cfg feature="${feature_name}"` flags. + """, + ), + "data": attr.label_list( + doc = """\ + List of files used by this rule at compile time and runtime. + + If including data at compile time with include_str!() and similar, + prefer `compile_data` over `data`, to prevent the data also being included + in the runfiles. + """, + allow_files = True, + ), + "deps": attr.label_list( + doc = """\ + List of other libraries to be linked to this library target. + + These can be either other `rust_library` targets or `cc_library` targets if + linking a native library. + """, + ), + "edition": attr.string( + doc = "The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.", + ), + "env": attr.string_dict( + mandatory = False, + doc = """\ + Specifies additional environment variables to set when the test is executed by bazel test. + Values are subject to `$(rootpath)`, `$(execpath)`, location, and + ["Make variable"](https://docs.bazel.build/versions/master/be/make-variables.html) substitution. + """, + ), + "env_inherit": attr.string_list( + doc = "Specifies additional environment variables to inherit from the external environment when the test is executed by bazel test.", + ), + "proc_macro_deps": attr.label_list( + doc = """\ + List of `rust_proc_macro` targets used to help build this library target. + """, + cfg = "exec", + providers = [rust_common.crate_info], + ), + "rustc_env": attr.string_dict( + doc = """\ + Dictionary of additional `"key": "value"` environment variables to set for rustc. + + rust_test()/rust_binary() rules can use $(rootpath //package:target) to pass in the + location of a generated file or external tool. Cargo build scripts that wish to + expand locations should use cargo_build_script()'s build_script_env argument instead, + as build scripts are run in a different environment - see cargo_build_script()'s + documentation for more. + """, + ), + "rustc_env_files": attr.label_list( + doc = """\ + Files containing additional environment variables to set for rustc. + + These files should contain a single variable per line, of format + `NAME=value`, and newlines may be included in a value by ending a + line with a trailing back-slash (`\\\\`). + + The order that these files will be processed is unspecified, so + multiple definitions of a particular variable are discouraged. + + Note that the variables here are subject to + [workspace status](https://docs.bazel.build/versions/main/user-manual.html#workspace_status) + stamping should the `stamp` attribute be enabled. Stamp variables + should be wrapped in brackets in order to be resolved. E.g. + `NAME={WORKSPACE_STATUS_VARIABLE}`. + """, + allow_files = True, + ), + "rustc_flags": attr.string_list( + doc = """\ + List of compiler flags passed to `rustc`. + + These strings are subject to Make variable expansion for predefined + source/output path variables like `$location`, `$execpath`, and + `$rootpath`. This expansion is useful if you wish to pass a generated + file of arguments to rustc: `@$(location //package:target)`. + """, + ), + "target_arch": attr.string( + doc = "The target architecture to use for the wasm-bindgen command line option.", + default = "wasm32", + values = ["wasm32", "wasm64"], + ), + "version": attr.string( + doc = "A version to inject in the cargo environment variable.", + default = "0.0.0", + ), + "wasm": attr.label( + doc = "The wasm target to test.", + aspects = [wasm_bindgen_test_crate_aspect], + providers = [RustWasmBindgenInfo], + mandatory = True, + ), + "_runner": attr.label( + doc = "TODO", + cfg = "exec", + executable = True, + default = Label("//private:wasm_bindgen_test_runner"), + ), + } | RUSTC_ATTRS, + fragments = ["cpp"], + toolchains = [ + str(Label("//:toolchain_type")), + "@rules_rust//rust:toolchain_type", + "@bazel_tools//tools/cpp:toolchain_type", + ], + test = True, +) diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs b/extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs new file mode 100644 index 0000000000..c1d81f4f32 --- /dev/null +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs @@ -0,0 +1,187 @@ +//! wasm-bindgen test runner + +use std::collections::BTreeMap; +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::{exit, Command}; + +use runfiles::{rlocation, Runfiles}; + +fn write_webdriver_for_browser( + original: &Path, + section: &str, + args: &Vec, + browser: &Option, + output: &Path, +) { + let content = fs::read_to_string(original).unwrap_or_else(|e| { + panic!( + "Failed to read webdriver.json at: {}\n{:?}", + original.display(), + e + ) + }); + + let mut json_data: serde_json::Value = serde_json::from_str(&content).unwrap_or_else(|e| { + panic!( + "Failed to deserialize json at: {}\n{:?}", + original.display(), + e + ) + }); + + let options = json_data + .as_object_mut() + .unwrap() + .entry(section) + .or_insert_with(|| serde_json::json!({})); + + if let Some(binary) = browser { + options.as_object_mut().unwrap().insert( + "binary".to_string(), + serde_json::Value::String(binary.to_string_lossy().to_string()), + ); + } + + let current_args = options + .as_object_mut() + .unwrap() + .entry("args") + .or_insert_with(|| serde_json::json!([])); + + for arg in args { + current_args + .as_array_mut() + .unwrap_or_else(|| panic!("Unable to access args array for section `{}`", section)) + .push(serde_json::json!(arg)); + } + + fs::write( + output, + serde_json::to_string_pretty(&json_data).expect("Failed to serialize json data"), + ) + .unwrap_or_else(|e| { + panic!( + "Failed to write webdriver config: {}\n{:?}", + output.display(), + e + ) + }); +} + +fn main() { + let runfiles = Runfiles::create().expect("Failed to locate runfiles"); + + let test_runner = rlocation!( + runfiles, + env::var("WASM_BINDGEN_TEST_RUNNER").expect("Failed to find TEST_WASM_BINARY env var") + ) + .expect("Failed to locate test binary"); + let test_bin = rlocation!( + runfiles, + env::var("TEST_WASM_BINARY").expect("Failed to find TEST_WASM_BINARY env var") + ) + .expect("Failed to locate test binary"); + + let browser_type = env::var("BROWSER_TYPE").expect("Failed to find `BROWSER_TYPE` env var"); + let browser = env::var_os("BROWSER").map(|_| { + rlocation!(runfiles, env::var("BROWSER").unwrap()).expect("Failed to locate browser") + }); + + let webdriver = rlocation!( + runfiles, + env::var("WEBDRIVER").expect("Failed to find WEBDRIVER env var.") + ) + .expect("Failed to locate webdriver"); + + let webdriver_json = rlocation!( + runfiles, + env::var("WEBDRIVER_JSON").expect("Failed to find WEBDRIVER_JSON env var.") + ) + .expect("Failed to locate webdriver"); + + // Update any existing environment variables. + let mut env = env::vars().collect::>(); + env.insert("TMP".to_string(), env["TEST_TMPDIR"].clone()); + env.insert("TEMP".to_string(), env["TEST_TMPDIR"].clone()); + env.insert("TMPDIR".to_string(), env["TEST_TMPDIR"].clone()); + env.insert("HOME".to_string(), env["TEST_TMPDIR"].clone()); + env.insert("USERPROFILE".to_string(), env["TEST_TMPDIR"].clone()); + + let webdriver_args: Vec = serde_json::from_str( + &env::var("WEBDRIVER_ARGS").expect("Failed to find WEBDRIVER_ARGS env var."), + ) + .expect("Failed to parse json encoded webdriver args."); + + let undeclared_test_outputs = PathBuf::from( + env::var("TEST_UNDECLARED_OUTPUTS_DIR") + .expect("TEST_UNDECLARED_OUTPUTS_DIR should always be defined for tests."), + ); + + let updated_webdriver_json = undeclared_test_outputs.join("webdriver.json"); + env.insert( + "WASM_BINDGEN_WEBDRIVER_JSON".to_string(), + updated_webdriver_json.to_string_lossy().to_string(), + ); + + // Configure the appropriate environment and config values for the browser. + match browser_type.as_str() { + "chrome" => { + env.insert( + "CHROMEDRIVER".to_string(), + webdriver.to_string_lossy().to_string(), + ); + + let user_data_dir = undeclared_test_outputs.join("user_data_dir"); + + write_webdriver_for_browser( + &webdriver_json, + "goog:chromeOptions", + &vec![format!("user-data-dir={}", user_data_dir.display())], + &browser, + &updated_webdriver_json, + ); + + env.insert("CHROMEDRIVER_ARGS".to_string(), webdriver_args.join(" ")); + } + "firefox" => { + env.insert( + "GECKODRIVER".to_string(), + webdriver.to_string_lossy().to_string(), + ); + + write_webdriver_for_browser( + &webdriver_json, + "moz:firefoxOptions", + &Vec::new(), + &browser, + &updated_webdriver_json, + ); + + // Sandboxing is always disabled as by default tests run in sandboxes anyway + // and creating an additional one would result in errors. + env.insert("MOZ_DISABLE_CONTENT_SANDBOX".to_string(), "1".to_string()); + + env.insert("GECKODRIVER_ARGS".to_string(), webdriver_args.join(" ")); + } + _ => { + panic!("Unexpected browser type: {}", browser_type) + } + } + + // Run the test + let mut command = Command::new(test_runner); + command.envs(env).arg(test_bin).args(env::args().skip(1)); + let result = command + .status() + .unwrap_or_else(|_| panic!("Failed to spawn command: {:#?}", command)); + + if !result.success() { + exit( + result + .code() + .expect("Completed processes will always have exit codes."), + ) + } +} diff --git a/extensions/wasm_bindgen/private/webdrivers/BUILD.bazel b/extensions/wasm_bindgen/private/webdrivers/BUILD.bazel new file mode 100644 index 0000000000..7e1a4b295b --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/BUILD.bazel @@ -0,0 +1,12 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +exports_files([ + "firefox", + "chrome", +]) + +bzl_library( + name = "bzl_lib", + srcs = glob(["*.bzl"]), + visibility = ["//private:__pkg__"], +) diff --git a/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome.bazel b/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome.bazel new file mode 100644 index 0000000000..eb1c4f0531 --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome.bazel @@ -0,0 +1,36 @@ +alias( + name = "chrome_macos", + actual = select({ + "@platforms//cpu:x86_64": "@chrome_mac_x64", + "//conditions:default": "@chrome_mac_arm64", + }), + target_compatible_with = ["@platforms//os:macos"], +) + +alias( + name = "chrome_linux", + actual = select({ + "@platforms//cpu:aarch64": "@chrome_linux_aarch64", + "//conditions:default": "@chrome_linux64", + }), + target_compatible_with = ["@platforms//os:linux"], +) + +alias( + name = "chrome_windows", + actual = select({ + "@platforms//cpu:i386": "@chrome_win32", + "//conditions:default": "@chrome_win64", + }), + target_compatible_with = ["@platforms//os:windows"], +) + +alias( + name = "chrome", + actual = select({ + "@platforms//os:linux": "@chrome_linux64", + "@platforms//os:macos": ":chrome_macos", + "@platforms//os:windows": ":chrome_windows", + }), + visibility = ["//visibility:public"], +) diff --git a/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome_headless_shell.bazel b/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome_headless_shell.bazel new file mode 100644 index 0000000000..0fedc6afae --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/BUILD.chrome_headless_shell.bazel @@ -0,0 +1,36 @@ +alias( + name = "chrome_headless_shell_macos", + actual = select({ + "@platforms//cpu:x86_64": "@chrome_headless_shell_mac_x64", + "//conditions:default": "@chrome_headless_shell_mac_arm64", + }), + target_compatible_with = ["@platforms//os:macos"], +) + +alias( + name = "chrome_headless_shell_linux", + actual = select({ + "@platforms//cpu:aarch64": "@chrome_headless_shell_linux_aarch64", + "//conditions:default": "@chrome_headless_shell_linux64", + }), + target_compatible_with = ["@platforms//os:linux"], +) + +alias( + name = "chrome_headless_shell_windows", + actual = select({ + "@platforms//cpu:i386": "@chrome_headless_shell_win32", + "//conditions:default": "@chrome_headless_shell_win64", + }), + target_compatible_with = ["@platforms//os:windows"], +) + +alias( + name = "chrome_headless_shell", + actual = select({ + "@platforms//os:linux": "@chrome_headless_shell_linux64", + "@platforms//os:macos": ":chrome_headless_shell_macos", + "@platforms//os:windows": ":chrome_headless_shell_windows", + }), + visibility = ["//visibility:public"], +) diff --git a/extensions/wasm_bindgen/private/webdrivers/BUILD.chromedriver.bazel b/extensions/wasm_bindgen/private/webdrivers/BUILD.chromedriver.bazel new file mode 100644 index 0000000000..9da63a1cdd --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/BUILD.chromedriver.bazel @@ -0,0 +1,36 @@ +alias( + name = "chromedriver_macos", + actual = select({ + "@platforms//cpu:x86_64": "@chromedriver_mac_x64", + "//conditions:default": "@chromedriver_mac_arm64", + }), + target_compatible_with = ["@platforms//os:macos"], +) + +alias( + name = "chromedriver_linux", + actual = select({ + "@platforms//cpu:aarch64": "@chromedriver_linux_aarch64", + "//conditions:default": "@chromedriver_linux64", + }), + target_compatible_with = ["@platforms//os:linux"], +) + +alias( + name = "chromedriver_windows", + actual = select({ + "@platforms//cpu:i386": "@chromedriver_win32", + "//conditions:default": "@chromedriver_win64", + }), + target_compatible_with = ["@platforms//os:windows"], +) + +alias( + name = "chromedriver", + actual = select({ + "@platforms//os:linux": "@chromedriver_linux64", + "@platforms//os:macos": ":chromedriver_macos", + "@platforms//os:windows": ":chromedriver_windows", + }), + visibility = ["//visibility:public"], +) diff --git a/extensions/wasm_bindgen/private/webdrivers/BUILD.geckodriver.bazel b/extensions/wasm_bindgen/private/webdrivers/BUILD.geckodriver.bazel new file mode 100644 index 0000000000..cd55db537a --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/BUILD.geckodriver.bazel @@ -0,0 +1,27 @@ +alias( + name = "geckodriver_macos", + actual = select({ + "@platforms//cpu:x86_64": "@geckodriver_macos", + "//conditions:default": "@geckodriver_macos_aarch64", + }), + target_compatible_with = ["@platforms//os:macos"], +) + +alias( + name = "geckodriver_linux", + actual = select({ + "@platforms//cpu:aarch64": "@geckodriver_linux_aarch64", + "//conditions:default": "@geckodriver_linux64", + }), + target_compatible_with = ["@platforms//os:linux"], +) + +alias( + name = "geckodriver", + actual = select({ + "@platforms//os:linux": ":geckodriver_linux", + "@platforms//os:macos": ":geckodriver_macos", + "@platforms//os:windows": "@geckodriver_win64", + }), + visibility = ["//visibility:public"], +) diff --git a/extensions/wasm_bindgen/private/webdrivers/webdriver_repositories.bzl b/extensions/wasm_bindgen/private/webdrivers/webdriver_repositories.bzl new file mode 100644 index 0000000000..bc4eef4908 --- /dev/null +++ b/extensions/wasm_bindgen/private/webdrivers/webdriver_repositories.bzl @@ -0,0 +1,418 @@ +"""Depednencies for `wasm_bindgen_test` rules""" + +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def _build_file_repository_impl(repository_ctx): + repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format( + repository_ctx.name, + )) + + repository_ctx.file("BUILD.bazel", repository_ctx.read(repository_ctx.path(repository_ctx.attr.build_file))) + +build_file_repository = repository_rule( + doc = "A repository rule for generating external repositories with a specific build file.", + implementation = _build_file_repository_impl, + attrs = { + "build_file": attr.label( + doc = "The file to use as the BUILD file for this repository.", + mandatory = True, + allow_files = True, + ), + }, +) + +_WEBDRIVER_BUILD_CONTENT = """\ +filegroup( + name = "{name}", + srcs = ["{tool}"], + data = glob( + include = [ + "**", + ], + exclude = [ + "*.bazel", + "BUILD", + "WORKSPACE", + ], + ), + visibility = ["//visibility:public"], +) +""" + +def _webdriver_repository_impl(repository_ctx): + result = repository_ctx.download_and_extract( + repository_ctx.attr.urls, + stripPrefix = repository_ctx.attr.strip_prefix, + integrity = repository_ctx.attr.integrity, + ) + + repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format( + repository_ctx.attr.original_name, + )) + + repository_ctx.file("BUILD.bazel", _WEBDRIVER_BUILD_CONTENT.format( + name = repository_ctx.attr.original_name, + tool = repository_ctx.attr.tool, + )) + + return { + "integrity": result.integrity, + "name": repository_ctx.name, + "original_name": repository_ctx.attr.original_name, + "strip_prefix": repository_ctx.attr.strip_prefix, + "tool": repository_ctx.attr.tool, + "urls": repository_ctx.attr.urls, + } + +webdriver_repository = repository_rule( + doc = "A repository rule for downloading webdriver tools.", + implementation = _webdriver_repository_impl, + attrs = { + "integrity": attr.string( + doc = """Expected checksum in Subresource Integrity format of the file downloaded.""", + ), + # TODO: This can be removed in Bazel 8 and it's use moved to `repository_ctx.original_name`. + "original_name": attr.string( + doc = "The original name of the repository.", + ), + "strip_prefix": attr.string( + doc = """A directory prefix to strip from the extracted files.""", + ), + "tool": attr.string( + doc = "The name of the webdriver tool being downloaded.", + mandatory = True, + ), + "urls": attr.string_list( + doc = "A list of URLs to a file that will be made available to Bazel.", + mandatory = True, + ), + }, +) + +_FIREFOX_WRAPPER_TEMPLATE_UNIX = """\ +#!/usr/bin/env bash + +set -euo pipefail + +exec {firefox} $@ +""" + +_FIREFOX_WRAPPER_TEMPLATE_WINDOWS = """\ +@ECHO OFF + +{firefox} %* + +:: Capture the exit code of firefox.exe +SET exit_code=!errorlevel! + +:: Exit with the same exit code +EXIT /b %exit_code% +""" + +_FIREFOX_NOT_FOUND_TEMPLATE_UNIX = """\ +#!/usr/bin/env bash + +set -euo pipefail + +>&2 echo "No firefox binary provided. Please export 'FIREFOX_BINARY' and try building again" +exit 1 +""" + +_FIREFOX_NOT_FOUND_TEMPLATE_WINDOWS = """\ +@ECHO OFF + +echo No firefox binary provided. Please export 'FIREFOX_BINARY' and try building again. +exit 1 +""" + +_FIREFOX_BUILD_CONTENT_UNIX = """\ +exports_files(["firefox"]) +""" + +_FIREFOX_BUILD_CONTENT_WINDOWS = """\ +exports_files(["firefox.bat"]) + +alias( + name = "firefox", + actual = "firefox.bat", + visibility = ["//visibility:public"], +) +""" + +def _local_firefox_repository_impl(repository_ctx): + repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format( + repository_ctx.name, + )) + + is_windows = False + if "FIREFOX_BINARY" not in repository_ctx.os.environ: + script_contents = _FIREFOX_NOT_FOUND_TEMPLATE_UNIX + if "win" in repository_ctx.os.name: + is_windows = True + script_contents = _FIREFOX_NOT_FOUND_TEMPLATE_WINDOWS + else: + firefox_bin = repository_ctx.os.environ["FIREFOX_BINARY"] + template = _FIREFOX_WRAPPER_TEMPLATE_UNIX + if firefox_bin.endswith((".exe", ".bat")): + is_windows = True + template = _FIREFOX_WRAPPER_TEMPLATE_WINDOWS + script_contents = template.format( + firefox = firefox_bin, + ) + + repository_ctx.file( + "firefox{}".format(".bat" if is_windows else ""), + script_contents, + executable = True, + ) + + repository_ctx.file("BUILD.bazel", _FIREFOX_BUILD_CONTENT_WINDOWS if is_windows else _FIREFOX_BUILD_CONTENT_UNIX) + +local_firefox_repository = repository_rule( + doc = """\ +A repository rule for wrapping the path to a host installed firefox binary + +Note that firefox binaries can be found here: https://ftp.mozilla.org/pub/firefox/releases/ + +However, for platforms like MacOS and Windows, the storage formats are not something that can be extracted +in a repository rule. +""", + implementation = _local_firefox_repository_impl, + environ = ["FIREFOX_BINARY"], +) + +def firefox_deps(): + """Download firefix/geckodriver dependencies + + Returns: + A list of repositories crated + """ + + geckodriver_version = "0.35.0" + + direct_deps = [] + for platform, integrity in { + "linux-aarch64": "sha256-kdHkRmRtjuhYMJcORIBlK3JfGefsvvo//TlHvHviOkc=", + "linux64": "sha256-rCbpuo87jOD79zObnJAgGS9tz8vwSivNKvgN/muyQmA=", + "macos": "sha256-zP9gaFH9hNMKhk5LvANTVSOkA4v5qeeHowgXqHdvraE=", + "macos-aarch64": "sha256-K4XNwwaSsz0nP18Zmj3Q9kc9JXeNlmncVwQmCzm99Xg=", + "win64": "sha256-5t4e5JqtKUMfe4/zZvEEhtAI3VzY3elMsB1+nj0z2Yg=", + }.items(): + archive = "tar.gz" + tool = "geckodriver" + if "win" in platform: + archive = "zip" + tool = "geckodriver.exe" + + name = "geckodriver_{}".format(platform.replace("-", "_")) + direct_deps.append(struct(repo = name)) + maybe( + webdriver_repository, + name = name, + original_name = name, + urls = ["https://github.com/mozilla/geckodriver/releases/download/v{version}/geckodriver-v{version}-{platform}.{archive}".format( + version = geckodriver_version, + platform = platform, + archive = archive, + )], + integrity = integrity, + tool = tool, + ) + + direct_deps.append(struct(repo = "geckodriver")) + maybe( + build_file_repository, + name = "geckodriver", + build_file = Label("//private/webdrivers:BUILD.geckodriver.bazel"), + ) + + direct_deps.append(struct(repo = "firefox")) + maybe( + local_firefox_repository, + name = "firefox", + ) + + return direct_deps + +# A snippet from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json +# but modified to included `integrity` +CHROME_DATA = { + "downloads": { + "chrome": [ + { + "integrity": "sha256-fm2efJlMZRGqLP7dgfMqhz6CKY/qVJrO6lfDZLLhA/k=", + "platform": "linux64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chrome-linux64.zip", + }, + { + "integrity": "sha256-uROIJ56CjR6ZyjiwPCAB7n21aSoA3Wi6TluPnAch8YM=", + "platform": "mac-arm64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chrome-mac-arm64.zip", + }, + { + "integrity": "sha256-e9rzOOF8n43J5IpwvBQjnKyGc26QnBcTygpALtGDCK0=", + "platform": "mac-x64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chrome-mac-x64.zip", + }, + { + "integrity": "sha256-tp67N9Iy0WPqRBqCPG66ow/TTEcBuSuS/XsJwms253Q=", + "platform": "win32", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chrome-win32.zip", + }, + { + "integrity": "sha256-GhiJkB9FcXIxdIqWf2gsJh0jYLWzx2V2r3wWLRcwSSk=", + "platform": "win64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chrome-win64.zip", + }, + ], + "chrome-headless-shell": [ + { + "integrity": "sha256-ZfahmT+jnxYV7e6e62Fj5W32FPJryOgAmhVDjNDp0Hk=", + "platform": "linux64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chrome-headless-shell-linux64.zip", + }, + { + "integrity": "sha256-Rfdu/e4raKeTCvh5FgK4H6rrAG14KRWK4fAzoOrqUBQ=", + "platform": "mac-arm64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chrome-headless-shell-mac-arm64.zip", + }, + { + "integrity": "sha256-TWHvAfeYDKifKQD95rSantkCtpR3vLKraP41VnlGFmA=", + "platform": "mac-x64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chrome-headless-shell-mac-x64.zip", + }, + { + "integrity": "sha256-KuWJUK12L+K4sQwRRecq0qrqz4CLDqPkN3c31vpMLXI=", + "platform": "win32", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chrome-headless-shell-win32.zip", + }, + { + "integrity": "sha256-9ZoAYNyG2yu/QQLNqVjbBMjrj5WtaSm62Ydp8u4BXqk=", + "platform": "win64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chrome-headless-shell-win64.zip", + }, + ], + "chromedriver": [ + { + "integrity": "sha256-FB1JYbgukDV7/PngapsD7b09XcqO5h01VFtTGPq6has=", + "platform": "linux64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chromedriver-linux64.zip", + }, + { + "integrity": "sha256-ZATjVJV7PsswgvgdT7zQeeC6pgflX6qcrQmHxwY+/xE=", + "platform": "mac-arm64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chromedriver-mac-arm64.zip", + }, + { + "integrity": "sha256-8IsY85x99wA1VtRY5K1vB9hB0tJtzPgfNJaLYEUk7mw=", + "platform": "mac-x64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chromedriver-mac-x64.zip", + }, + { + "integrity": "sha256-HYamG2SqvfrCLbxaQIc8CI5x1KnZ/XkJ0Y3RKwmFaDo=", + "platform": "win32", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chromedriver-win32.zip", + }, + { + "integrity": "sha256-IxvDZCKGBTZkYDT/M7XQOfI/DaQxA9yYPJ0PB5XniVQ=", + "platform": "win64", + "url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chromedriver-win64.zip", + }, + ], + }, + "revision": "1429446", + "version": "136.0.7055.0", +} + +def chrome_deps(): + """Download chromedriver dependencies + + Returns: + A list of repositories crated + """ + + direct_deps = [] + for data in CHROME_DATA["downloads"]["chromedriver"]: + platform = data["platform"] + name = "chromedriver_{}".format(platform.replace("-", "_")) + direct_deps.append(struct(repo = name)) + tool = "chromedriver" + if platform.startswith("win"): + tool = "chromedriver.exe" + maybe( + webdriver_repository, + name = name, + original_name = name, + urls = [data["url"]], + strip_prefix = "chromedriver-{}".format(platform), + integrity = data.get("integrity", ""), + tool = tool, + ) + + for data in CHROME_DATA["downloads"]["chrome-headless-shell"]: + platform = data["platform"] + name = "chrome_headless_shell_{}".format(platform.replace("-", "_")) + direct_deps.append(struct(repo = name)) + tool = "chrome-headless-shell" + if platform.startswith("win"): + tool = "chrome-headless-shell.exe" + maybe( + webdriver_repository, + name = name, + original_name = name, + urls = [data["url"]], + strip_prefix = "chrome-headless-shell-{}".format(platform), + integrity = data.get("integrity", ""), + tool = tool, + ) + + for data in CHROME_DATA["downloads"]["chrome"]: + platform = data["platform"] + name = "chrome_{}".format(platform.replace("-", "_")) + direct_deps.append(struct(repo = name)) + + if platform.startswith("win"): + tool = "chrome.exe" + elif platform.startswith("mac"): + tool = "Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing" + else: + tool = "chrome" + maybe( + webdriver_repository, + name = name, + original_name = name, + urls = [data["url"]], + strip_prefix = "chrome-{}".format(platform), + integrity = data.get("integrity", ""), + tool = tool, + ) + + direct_deps.append(struct(repo = "chromedriver")) + maybe( + build_file_repository, + name = "chromedriver", + build_file = Label("//private/webdrivers:BUILD.chromedriver.bazel"), + ) + + direct_deps.append(struct(repo = "chrome_headless_shell")) + maybe( + build_file_repository, + name = "chrome_headless_shell", + build_file = Label("//private/webdrivers:BUILD.chrome_headless_shell.bazel"), + ) + + direct_deps.append(struct(repo = "chrome")) + maybe( + build_file_repository, + name = "chrome", + build_file = Label("//private/webdrivers:BUILD.chrome.bazel"), + ) + + return direct_deps + +def webdriver_repositories(): + direct_deps = [] + direct_deps.extend(chrome_deps()) + direct_deps.extend(firefox_deps()) + + return direct_deps diff --git a/extensions/wasm_bindgen/repositories.bzl b/extensions/wasm_bindgen/repositories.bzl index 44743f7920..56aed16be0 100644 --- a/extensions/wasm_bindgen/repositories.bzl +++ b/extensions/wasm_bindgen/repositories.bzl @@ -17,6 +17,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//3rdparty/crates:crates.bzl", "crate_repositories") +load("//private/webdrivers:webdriver_repositories.bzl", "webdriver_repositories") WASM_BINDGEN_VERSION = "0.2.100" @@ -42,9 +43,14 @@ def rust_wasm_bindgen_dependencies(): type = "tar.gz", strip_prefix = "wasm-bindgen-cli-{}".format(WASM_BINDGEN_VERSION), build_file = Label("//3rdparty:BUILD.wasm-bindgen-cli.bazel"), + patch_args = ["-p1"], + patches = [ + Label("//3rdparty/patches:wasm-bindgen-cli.webdriver_json.patch"), + ], ) direct_deps.extend(crate_repositories()) + direct_deps.extend(webdriver_repositories()) return direct_deps # buildifier: disable=unnamed-macro diff --git a/extensions/wasm_bindgen/rules_js/defs.bzl b/extensions/wasm_bindgen/rules_js/defs.bzl index 70dc0a9813..1da939c52f 100644 --- a/extensions/wasm_bindgen/rules_js/defs.bzl +++ b/extensions/wasm_bindgen/rules_js/defs.bzl @@ -3,7 +3,7 @@ load("@aspect_rules_js//js:providers.bzl", "js_info") # buildifier: disable=bzl-visibility -load("@rules_rust//rust/private:providers.bzl", "RustAnalyzerGroupInfo", "RustAnalyzerInfo") +load("@rules_rust//rust/private:providers.bzl", "ClippyInfo", "RustAnalyzerGroupInfo", "RustAnalyzerInfo") load("//private:wasm_bindgen.bzl", "WASM_BINDGEN_ATTR", "rust_wasm_bindgen_action") def _js_rust_wasm_bindgen_impl(ctx): @@ -32,11 +32,15 @@ def _js_rust_wasm_bindgen_impl(ctx): ), ] - if RustAnalyzerGroupInfo in ctx.attr.wasm_file: - providers.append(ctx.attr.wasm_file[RustAnalyzerGroupInfo]) + crate = ctx.attr.wasm_file[0] + if RustAnalyzerGroupInfo in crate: + providers.append(crate[RustAnalyzerGroupInfo]) - if RustAnalyzerInfo in ctx.attr.wasm_file: - providers.append(ctx.attr.wasm_file[RustAnalyzerInfo]) + if RustAnalyzerInfo in crate: + providers.append(crate[RustAnalyzerInfo]) + + if ClippyInfo in crate: + providers.append(crate[ClippyInfo]) return providers diff --git a/extensions/wasm_bindgen/test/BUILD.bazel b/extensions/wasm_bindgen/test/BUILD.bazel index 26addefcd8..37237f8fdc 100644 --- a/extensions/wasm_bindgen/test/BUILD.bazel +++ b/extensions/wasm_bindgen/test/BUILD.bazel @@ -13,7 +13,7 @@ # limitations under the License. load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library") -load("@rules_rust_wasm_bindgen//:defs.bzl", "rust_wasm_bindgen") +load("@rules_rust_wasm_bindgen//:defs.bzl", "rust_wasm_bindgen", "rust_wasm_bindgen_test") package(default_visibility = ["//:__subpackages__"]) @@ -47,26 +47,51 @@ rust_wasm_bindgen( wasm_file = ":hello_world_bin_wasm", ) +rust_wasm_bindgen_test( + name = "hello_world_bundler_wasm_bindgen_test", + wasm = ":hello_world_bundler_wasm_bindgen", +) + rust_wasm_bindgen( name = "hello_world_web_wasm_bindgen", target = "web", wasm_file = ":hello_world_lib_wasm", ) +rust_wasm_bindgen_test( + name = "hello_world_web_wasm_bindgen_test", + wasm = "hello_world_web_wasm_bindgen", +) + rust_wasm_bindgen( name = "hello_world_deno_wasm_bindgen", target = "deno", wasm_file = ":hello_world_lib_wasm", ) +rust_wasm_bindgen_test( + name = "hello_world_deno_wasm_bindgen_test", + wasm = "hello_world_deno_wasm_bindgen", +) + rust_wasm_bindgen( name = "hello_world_nomodules_wasm_bindgen", target = "no-modules", wasm_file = ":hello_world_lib_wasm", ) +rust_wasm_bindgen_test( + name = "hello_world_nomodules_wasm_bindgen_test", + wasm = "hello_world_nomodules_wasm_bindgen", +) + rust_wasm_bindgen( name = "hello_world_nodejs_wasm_bindgen", target = "nodejs", wasm_file = ":hello_world_lib_wasm", ) + +rust_wasm_bindgen_test( + name = "hello_world_nodejs_wasm_bindgen_test", + wasm = "hello_world_nodejs_wasm_bindgen", +) diff --git a/extensions/wasm_bindgen/test/main.rs b/extensions/wasm_bindgen/test/main.rs index 8703ad3000..b87890c6cf 100644 --- a/extensions/wasm_bindgen/test/main.rs +++ b/extensions/wasm_bindgen/test/main.rs @@ -9,3 +9,18 @@ pub fn double(i: i32) -> i32 { fn main() { println!("Hello {}", double(2)); } + +#[cfg(test)] +mod tests { + use wasm_bindgen_test::*; + + #[wasm_bindgen_test] + fn test_double_four() { + assert_eq!(super::double(4), 8); + } + + #[wasm_bindgen_test(unsupported = test)] + fn test_double_two() { + assert_eq!(super::double(2), 4); + } +} diff --git a/extensions/wasm_bindgen/webdriver.json b/extensions/wasm_bindgen/webdriver.json new file mode 100644 index 0000000000..5121d40609 --- /dev/null +++ b/extensions/wasm_bindgen/webdriver.json @@ -0,0 +1,9 @@ +{ + "moz:firefoxOptions": { + "prefs": {}, + "args": [] + }, + "goog:chromeOptions": { + "args": [] + } +} From 0fae67a2b4aadcd1189bf029b6b99073be3737c8 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Sat, 8 Mar 2025 13:46:16 -0800 Subject: [PATCH 2/3] renamed runner to wrapper --- extensions/wasm_bindgen/private/BUILD.bazel | 4 ++-- .../wasm_bindgen/private/wasm_bindgen_test.bzl | 17 +++++++---------- ...t_runner.rs => wasm_bindgen_test_wrapper.rs} | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) rename extensions/wasm_bindgen/private/{wasm_bindgen_test_runner.rs => wasm_bindgen_test_wrapper.rs} (98%) diff --git a/extensions/wasm_bindgen/private/BUILD.bazel b/extensions/wasm_bindgen/private/BUILD.bazel index df2c6be51b..684011ea6b 100644 --- a/extensions/wasm_bindgen/private/BUILD.bazel +++ b/extensions/wasm_bindgen/private/BUILD.bazel @@ -15,8 +15,8 @@ bzl_library( ) rust_binary( - name = "wasm_bindgen_test_runner", - srcs = ["wasm_bindgen_test_runner.rs"], + name = "wasm_bindgen_test_wrapper", + srcs = ["wasm_bindgen_test_wrapper.rs"], edition = "2021", visibility = ["//visibility:public"], deps = [ diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl index 1ed803017d..273b9fd2a3 100644 --- a/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl @@ -154,16 +154,13 @@ def _rust_wasm_bindgen_test_impl(ctx): {}, ) - # if ctx.configuration.coverage_enabled: - # env.update(get_coverage_env(toolchain)) - components = "{}/{}".format(ctx.label.workspace_root, ctx.label.package).split("/") env["CARGO_MANIFEST_DIR"] = "/".join([c for c in components if c]) - runner = ctx.actions.declare_file(ctx.label.name) + wrapper = ctx.actions.declare_file(ctx.label.name) ctx.actions.symlink( - output = runner, - target_file = ctx.executable._runner, + output = wrapper, + target_file = ctx.executable._wrapper, is_executable = True, ) @@ -191,7 +188,7 @@ def _rust_wasm_bindgen_test_impl(ctx): providers.append(DefaultInfo( files = prov.files, runfiles = prov.default_runfiles.merge(ctx.runfiles(files = [wasm_file], transitive_files = wb_toolchain.all_test_files)), - executable = runner, + executable = wrapper, )) else: providers.append(prov) @@ -326,11 +323,11 @@ rust_wasm_bindgen_test = rule( providers = [RustWasmBindgenInfo], mandatory = True, ), - "_runner": attr.label( - doc = "TODO", + "_wrapper": attr.label( + doc = "The process wrapper for wasm-bindgen-test-runner.", cfg = "exec", executable = True, - default = Label("//private:wasm_bindgen_test_runner"), + default = Label("//private:wasm_bindgen_test_wrapper"), ), } | RUSTC_ATTRS, fragments = ["cpp"], diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs b/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs similarity index 98% rename from extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs rename to extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs index c1d81f4f32..3ab9fe9fbc 100644 --- a/extensions/wasm_bindgen/private/wasm_bindgen_test_runner.rs +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs @@ -1,4 +1,4 @@ -//! wasm-bindgen test runner +//! A Bazel wrapper for the wasm-bindgen-test-runner binary. use std::collections::BTreeMap; use std::env; From 4048dbd56bb0de0ff3f416a7bf22170f90edf96f Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Sat, 8 Mar 2025 15:22:50 -0800 Subject: [PATCH 3/3] Remove unnecessary json encoding --- extensions/wasm_bindgen/private/BUILD.bazel | 2 +- extensions/wasm_bindgen/private/wasm_bindgen_test.bzl | 2 +- .../wasm_bindgen/private/wasm_bindgen_test_wrapper.rs | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/wasm_bindgen/private/BUILD.bazel b/extensions/wasm_bindgen/private/BUILD.bazel index 684011ea6b..45660286f3 100644 --- a/extensions/wasm_bindgen/private/BUILD.bazel +++ b/extensions/wasm_bindgen/private/BUILD.bazel @@ -21,6 +21,6 @@ rust_binary( visibility = ["//visibility:public"], deps = [ "@rrwbd//:serde_json", - "@rules_rust//tools/runfiles", + "@rules_rust//rust/runfiles", ], ) diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl index 273b9fd2a3..6617c64451 100644 --- a/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test.bzl @@ -169,7 +169,7 @@ def _rust_wasm_bindgen_test_impl(ctx): env["BROWSER_TYPE"] = wb_toolchain.browser_type env["WEBDRIVER"] = _rlocationpath(wb_toolchain.webdriver, ctx.workspace_name) - env["WEBDRIVER_ARGS"] = json.encode(wb_toolchain.webdriver_args) + env["WEBDRIVER_ARGS"] = " ".join(wb_toolchain.webdriver_args) env["WEBDRIVER_JSON"] = _rlocationpath(wb_toolchain.webdriver_json, ctx.workspace_name) env["WASM_BINDGEN_TEST_RUNNER"] = _rlocationpath(wb_toolchain.wasm_bindgen_test_runner, ctx.workspace_name) diff --git a/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs b/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs index 3ab9fe9fbc..ae9c098e7b 100644 --- a/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs +++ b/extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs @@ -109,10 +109,8 @@ fn main() { env.insert("HOME".to_string(), env["TEST_TMPDIR"].clone()); env.insert("USERPROFILE".to_string(), env["TEST_TMPDIR"].clone()); - let webdriver_args: Vec = serde_json::from_str( - &env::var("WEBDRIVER_ARGS").expect("Failed to find WEBDRIVER_ARGS env var."), - ) - .expect("Failed to parse json encoded webdriver args."); + let webdriver_args = + env::var("WEBDRIVER_ARGS").expect("Failed to find WEBDRIVER_ARGS env var."); let undeclared_test_outputs = PathBuf::from( env::var("TEST_UNDECLARED_OUTPUTS_DIR") @@ -143,7 +141,7 @@ fn main() { &updated_webdriver_json, ); - env.insert("CHROMEDRIVER_ARGS".to_string(), webdriver_args.join(" ")); + env.insert("CHROMEDRIVER_ARGS".to_string(), webdriver_args); } "firefox" => { env.insert( @@ -163,7 +161,7 @@ fn main() { // and creating an additional one would result in errors. env.insert("MOZ_DISABLE_CONTENT_SANDBOX".to_string(), "1".to_string()); - env.insert("GECKODRIVER_ARGS".to_string(), webdriver_args.join(" ")); + env.insert("GECKODRIVER_ARGS".to_string(), webdriver_args); } _ => { panic!("Unexpected browser type: {}", browser_type)