diff --git a/.bazelrc b/.bazelrc index d0ae7bf8..a0490fc5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,12 +45,3 @@ build:tsan --linkopt=-fsanitize=thread build:tsan --strip=never build:tsan --features=dbg build:tsan --compilation_mode=dbg - -# WebAssembly (WASM) configuration -# Usage: bazel build --config=wasm //... -# Compiles using the hermetic emsdk toolchain downloaded automatically by Bazel. -build:wasm --platforms=@emsdk//:platform_wasm -build:wasm --cpu=wasm -build:wasm --cxxopt=-std=c++20 -build:wasm --host_cxxopt=-std=c++20 -build:wasm --compilation_mode=opt diff --git a/.github/workflows/ci_wasm.yml b/.github/workflows/ci_wasm.yml index 7b0d9fcb..9e0e4616 100644 --- a/.github/workflows/ci_wasm.yml +++ b/.github/workflows/ci_wasm.yml @@ -22,8 +22,9 @@ jobs: # 3️⃣ Build WASM targets (hermetic emsdk toolchain downloaded by Bazel) - name: Build WASM targets - run: bazel build --config=wasm --verbose_failures //examples:all_examples_wasm + run: bazel build --verbose_failures //examples/wasm:all_examples_wasm # 4️⃣ Smoke test: run solve_board under Node.js — pass if it does not crash - name: Smoke test solve_board_wasm - run: node bazel-bin/examples/solve_board.js + run: node bazel-bin/examples/wasm/solve_board.js +git push -u origin wasm-refactor \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel index 02ea9a23..8a672088 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -72,8 +72,7 @@ config_setting( define_values = {"asan": "true"}, ) -# WebAssembly (WASM) build configuration -# Usage: bazel build --config=wasm //... +# Matches cc_* targets built under the wasm_cc_binary platform transition (cpu=wasm). config_setting( name = "build_wasm", values = {"cpu": "wasm"}, diff --git a/docs/wasm_build.md b/docs/wasm_build.md index 9cfca6db..411785ec 100644 --- a/docs/wasm_build.md +++ b/docs/wasm_build.md @@ -1,6 +1,6 @@ # WebAssembly (WASM) Build Guide -This document explains how to build the DDS library and examples for WebAssembly using Bazel. +This document explains how to build DDS examples for WebAssembly using Bazel. ## Prerequisites @@ -9,128 +9,102 @@ This document explains how to build the DDS library and examples for WebAssembly Bazel 7.x or later is required. Install using your package manager or download from: https://bazel.build/install -The Emscripten SDK (emsdk) does NOT need to be manually installed. Bazel will automatically download, configure, and cache the appropriate hermetic Emscripten toolchain for your host platform as part of the build process. +The Emscripten SDK (emsdk) does NOT need to be manually installed. Bazel downloads and caches a hermetic Emscripten toolchain when you build a `wasm_cc_binary` target. ## Building WASM Examples -### Build All Examples +WASM targets use `wasm_cc_binary`, which applies an Emscripten **platform transition** to the underlying `cc_binary`. You do **not** need `--config=wasm` or any other `.bazelrc` profile. -```bash -cd /workspaces/dds -bazel build //examples:all_examples_wasm -``` - -### Build Specific Example +### Build all WASM examples ```bash -bazel build //examples:solve_board_wasm -``` - -### Output Files - -the output files will be located in: -``` -bazel-bin/examples/ +bazel build //examples/wasm:all_examples_wasm ``` -Depending on the target, you'll get: -- `target.js` - JavaScript bindings -- `target.wasm` - WebAssembly binary +The alias `//examples:all_examples_wasm` points at the same filegroup. +### Build a specific example -## Available WASM Targets - -The following example targets are available for WASM builds: +```bash +bazel build //examples/wasm:solve_board_wasm +``` -### Implemented Examples -- `solve_board` - Solves a single board (produces .js and .wasm) +### Output files -- `analyse_play_bin` - Analyze play from binary format +Outputs are under `bazel-bin/examples/wasm/`: +- `solve_board.js` / `solve_board.wasm` +- `AnalysePlayBin.js` / `AnalysePlayBin.wasm` -## WASM Build Configuration +## Available WASM targets -The WASM build is configured through: +Rules in `examples/wasm/BUILD.bazel` wrap native examples in `examples/`: -1. **BUILD.bazel** - Defines the WASM config_setting: - ```python - config_setting( - name = "build_wasm", - values = {"cpu": "wasm"}, - ) - ``` +- `solve_board_wasm` — solves a single board +- `analyse_play_bin_wasm` — analyze play from binary format -2. **CPPVARIABLES.bzl** - Specifies WASM-specific compiler flags: - - Optimization: `-O3 -flto` - - Exceptions: `-fexceptions` - - Define: `-D__WASM__` +## How it works -3. **.bazelrc** - Contains the `wasm` profile: - ``` - build:wasm --platforms=@emsdk//:platform_wasm - build:wasm --cpu=wasm - build:wasm --cxxopt=-std=c++20 - build:wasm --host_cxxopt=-std=c++20 - build:wasm --compilation_mode=opt - ``` +1. **`wasm_cc_binary`** (from `@emsdk`) transitions its `cc_target` to `@emsdk//:platform_wasm` and sets `--cpu=wasm`. +2. **`//:build_wasm`** in the root `BUILD.bazel` matches that CPU for `select()` in `CPPVARIABLES.bzl` and example link flags. +3. **`wasm_compat.bzl`** — shared Emscripten link flags (`WASM_LINKOPTS`) on the WASM-capable `cc_binary` targets. -## Running WASM Examples +Native builds (`bazel build //...`, `bazel test //library/tests/...`, Python bindings) are unchanged and use the host LLVM toolchain. -After building, you can run the examples: +## Running WASM examples -### Node.js (requires Node.js installed) +### Node.js ```bash -node bazel-bin/examples/solve_board.js +node bazel-bin/examples/wasm/solve_board.js ``` -### Web Browser (TODO) - -For HTML targets, open the generated HTML file in a web browser: -```bash -# Copy the output files to a web-accessible location -cp bazel-bin/examples/solve_board.* /path/to/webserver/ - -# Then open in browser at http://localhost:8000/solve_board.html -``` +### Web browser (not yet supported) -## Compilation Flags +There is no checked-in HTML runner yet. To experiment manually, copy the built `.js` and `.wasm` files from `bazel-bin/examples/wasm/` to a static file server and load the `.js` from a page that provides the Emscripten `Module` hooks. -The WASM build uses the following key flags: +## Compilation flags | Flag | Purpose | |------|---------| | `-O3` | Aggressive optimization | | `-flto` | Link-time optimization | | `-fexceptions` | Enable C++ exceptions | -| `-D__WASM__` | Defines `__WASM__` preprocessor constant | +| `-D__WASM__` | Preprocessor constant for WASM builds | | `-sWASM=1` | Emscripten WASM output (link flag) | | `-sALLOW_MEMORY_GROWTH=1` | Allow heap growth at runtime | -| `-sINITIAL_MEMORY=268435456` | Configure 256MB initial memory | +| `-sINITIAL_MEMORY=268435456` | 256MB initial memory | + +## C++ standard -## C++ Standard +WASM example binaries are built as C++20. The Emscripten toolchain (via `wasm_cc_binary`) compiles the transitioned `cc_target`; project flags for that configuration come from `CPPVARIABLES.bzl` when `//:build_wasm` matches (`--cpu=wasm` set by the transition). + +Host-side Bazel actions still use the normal platform flags in `.bazelrc`: -The WASM build uses C++20 as specified in `.bazelrc`: ``` -build:wasm --cxxopt=-std=c++20 +build:macos --cxxopt=-std=c++20 +build:linux --cxxopt=-std=c++20 ``` -## Related Documentation +There is no separate `build:wasm` profile in `.bazelrc`; WASM builds are selected by targeting `//examples/wasm:*`. -- [Emscripten Documentation](https://emscripten.org/docs/) -- [Bazel Build System](https://bazel.build/docs) -- [DDS C++ API](c++_interface.md) -- [Build System Overview](BUILD_SYSTEM.md) +## Development notes -## Next Steps +- The `__WASM__` preprocessor constant is defined for WASM builds (`CPPVARIABLES.bzl`). It was added to work around platform-specific code paths; revisit whether it can be narrowed or removed as WASM support matures. +- Some threading and platform-specific features are disabled or stubbed when `__WASM__` is set. +- A reusable `cc_library` WASM artifact (not only example binaries) is not yet provided; today only `wasm_cc_binary` example targets are wired up. +- Browser/HTML packaging (`.html` shell, assets) is not yet documented or automated; Node.js is the supported smoke-test runner for now. + +## Next steps To integrate WASM builds into CI/CD: -1. See `.github/workflows/ci_linux.yml` and `.github/workflows/ci_macos.yml` -2. Store WASM artifacts for download/release -## Development Notes +1. See `.github/workflows/ci_wasm.yml` +2. Store WASM artifacts (`*.js`, `*.wasm`) for download or release as needed + +## Related documentation -- The `__WASM__` preprocessor constant is added initially to bypass error, need to check again whether we can remove -- Some threading and platform-specific features are disabled for WASM -- The build flow for a reusable library wasm -- A good HTML example +- [Emscripten Documentation](https://emscripten.org/docs/) +- [Bazel Build System](https://bazel.build/docs) +- [DDS C++ API](c++_interface.md) +- [Build System Overview](BUILD_SYSTEM.md) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index e577e567..1ae72944 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -1,60 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("//:CPPVARIABLES.bzl", "DDS_CPPOPTS", "DDS_LINKOPTS", "DDS_LOCAL_DEFINES") -load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") - -filegroup( - name = "solve_board_wasm_inputs", - srcs = [ - "hands.cpp", - "solve_board.cpp", - "//library/src:dds_wasm_sources", - "//library/src:testable_dds_headers", - "//library/src/heuristic_sorting:wasm_sources", - "//library/src/lookup_tables:wasm_sources", - "//library/src/moves:wasm_sources", - "//library/src/solver_context:wasm_sources", - "//library/src/system:wasm_sources", - "//library/src/trans_table:wasm_sources", - "//library/src/utility:wasm_sources", - ], -) - -filegroup( - name = "analyse_play_bin_wasm_inputs", - srcs = [ - "hands.cpp", - "analyse_play_bin.cpp", - "//library/src:dds_wasm_sources", - "//library/src:testable_dds_headers", - "//library/src/heuristic_sorting:wasm_sources", - "//library/src/lookup_tables:wasm_sources", - "//library/src/moves:wasm_sources", - "//library/src/solver_context:wasm_sources", - "//library/src/system:wasm_sources", - "//library/src/trans_table:wasm_sources", - "//library/src/utility:wasm_sources", - ], -) - -wasm_cc_binary( - name = "solve_board_wasm", - cc_target = ":solve_board", - outputs = [ - "solve_board.js", - "solve_board.wasm", - ], - tags = ["manual"], -) - -wasm_cc_binary( - name = "analyse_play_bin_wasm", - cc_target = ":AnalysePlayBin", - outputs = [ - "AnalysePlayBin.js", - "AnalysePlayBin.wasm", - ], - tags = ["manual"], -) +load("//:wasm_compat.bzl", "WASM_LINKOPTS") # Examples use legacy C-style code, so we need to suppress certain warnings EXAMPLES_CPPOPTS = DDS_CPPOPTS + select({ @@ -73,14 +19,9 @@ EXAMPLES_LOCAL_DEFINES = DDS_LOCAL_DEFINES + select({ "//conditions:default": [], }) -# WASM-specific link flags for em++ output (produces .html, .js, .wasm) +# Emscripten link flags for examples built as WASM (see //examples/wasm). EXAMPLES_LINKOPTS_WASM = select({ - "//:build_wasm": [ - "-sWASM=1", - "-fexceptions", - "-sALLOW_MEMORY_GROWTH=1", - "-sINITIAL_MEMORY=268435456", - ], + "//:build_wasm": WASM_LINKOPTS, "//conditions:default": [], }) @@ -102,7 +43,7 @@ cc_binary( name = "analyse_all_plays_bin", srcs = ["analyse_all_plays_bin.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -115,7 +56,7 @@ cc_binary( name = "analyse_all_plays_pbn", srcs = ["analyse_all_plays_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -130,6 +71,7 @@ cc_binary( copts = EXAMPLES_CPPOPTS, linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, + visibility = ["//examples/wasm:__pkg__"], deps = [ ":hands", "//library/src:dds", @@ -141,7 +83,7 @@ cc_binary( name = "analyse_play_pbn", srcs = ["analyse_play_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -154,7 +96,7 @@ cc_binary( name = "calc_all_tables", srcs = ["calc_all_tables.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -167,7 +109,7 @@ cc_binary( name = "calc_all_tables_pbn", srcs = ["calc_all_tables_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -180,7 +122,7 @@ cc_binary( name = "calc_dd_table", srcs = ["calc_dd_table.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -193,7 +135,7 @@ cc_binary( name = "calc_dd_table_pbn", srcs = ["calc_dd_table_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -206,7 +148,7 @@ cc_binary( name = "dealer_par", srcs = ["dealer_par.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -219,7 +161,7 @@ cc_binary( name = "par", srcs = ["par.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -232,7 +174,7 @@ cc_binary( name = "solve_all_boards", srcs = ["solve_all_boards.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -247,6 +189,7 @@ cc_binary( copts = EXAMPLES_CPPOPTS, linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, + visibility = ["//examples/wasm:__pkg__"], deps = [ ":hands", "//library/src:dds", @@ -258,7 +201,7 @@ cc_binary( name = "solve_board_pbn", srcs = ["solve_board_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -271,7 +214,7 @@ cc_binary( name = "migration_example", srcs = ["migration_example.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ "//library/src:dds", @@ -283,7 +226,7 @@ cc_binary( name = "calc_par_context_example", srcs = ["calc_par_context_example.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, + linkopts = DDS_LINKOPTS, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -293,7 +236,7 @@ cc_binary( ], ) -# Convenience target to build all examples +# Convenience target to build all native examples filegroup( name = "all_examples", srcs = [ @@ -315,11 +258,8 @@ filegroup( ], ) -filegroup( +# Backward-compatible alias; prefer //examples/wasm:all_examples_wasm. +alias( name = "all_examples_wasm", - srcs = [ - ":analyse_play_bin_wasm", - ":solve_board_wasm", - ], - tags = ["manual"], + actual = "//examples/wasm:all_examples_wasm", ) diff --git a/examples/wasm/BUILD.bazel b/examples/wasm/BUILD.bazel new file mode 100644 index 00000000..58ac4d7a --- /dev/null +++ b/examples/wasm/BUILD.bazel @@ -0,0 +1,28 @@ +load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") + +wasm_cc_binary( + name = "solve_board_wasm", + cc_target = "//examples:solve_board", + outputs = [ + "solve_board.js", + "solve_board.wasm", + ], +) + +wasm_cc_binary( + name = "analyse_play_bin_wasm", + cc_target = "//examples:AnalysePlayBin", + outputs = [ + "AnalysePlayBin.js", + "AnalysePlayBin.wasm", + ], +) + +filegroup( + name = "all_examples_wasm", + srcs = [ + ":analyse_play_bin_wasm", + ":solve_board_wasm", + ], + visibility = ["//visibility:public"], +) diff --git a/library/src/BUILD.bazel b/library/src/BUILD.bazel index ca141ddd..730bc3b7 100644 --- a/library/src/BUILD.bazel +++ b/library/src/BUILD.bazel @@ -64,16 +64,6 @@ filegroup( ], ) -filegroup( - name = "dds_wasm_sources", - srcs = glob([ - "**/*.cpp", - ]), - visibility = [ - "//examples:__pkg__", - ], -) - cc_library( name = "testable_dds", srcs = ["//library/src:testable_dds_sources"], diff --git a/library/src/heuristic_sorting/BUILD.bazel b/library/src/heuristic_sorting/BUILD.bazel index e6e7ffb1..6ce9cdcd 100644 --- a/library/src/heuristic_sorting/BUILD.bazel +++ b/library/src/heuristic_sorting/BUILD.bazel @@ -44,12 +44,4 @@ cc_library( "//library/tests/heuristic_sorting:__pkg__", "//library/tests/regression/heuristic_sorting:__pkg__", ], -) - -filegroup( - name = "wasm_sources", - srcs = ["heuristic_sorting.cpp"], - visibility = [ - "//examples:__pkg__", - ], ) \ No newline at end of file diff --git a/library/src/lookup_tables/BUILD.bazel b/library/src/lookup_tables/BUILD.bazel index 2e35514c..76f9c93f 100644 --- a/library/src/lookup_tables/BUILD.bazel +++ b/library/src/lookup_tables/BUILD.bazel @@ -14,11 +14,3 @@ cc_library( linkopts = DDS_LINKOPTS, local_defines = DDS_LOCAL_DEFINES, ) - -filegroup( - name = "wasm_sources", - srcs = ["lookup_tables.cpp"], - visibility = [ - "//examples:__pkg__", - ], -) diff --git a/library/src/moves/BUILD.bazel b/library/src/moves/BUILD.bazel index 75d13fff..317f5645 100644 --- a/library/src/moves/BUILD.bazel +++ b/library/src/moves/BUILD.bazel @@ -35,12 +35,4 @@ cc_library( visibility = [ "//library/tests/moves:__pkg__", ], -) - -filegroup( - name = "wasm_sources", - srcs = glob(["*.cpp"]), - visibility = [ - "//examples:__pkg__", - ], ) \ No newline at end of file diff --git a/library/src/solver_context/BUILD.bazel b/library/src/solver_context/BUILD.bazel index d25dea9e..a566211b 100644 --- a/library/src/solver_context/BUILD.bazel +++ b/library/src/solver_context/BUILD.bazel @@ -51,11 +51,3 @@ cc_library( linkopts = DDS_LINKOPTS, local_defines = DDS_LOCAL_DEFINES + DDS_SCHEDULER_DEFINE + ["DDS_UTILITIES_STATS"], ) - -filegroup( - name = "wasm_sources", - srcs = ["solver_context.cpp"], - visibility = [ - "//examples:__pkg__", - ], -) diff --git a/library/src/system/BUILD.bazel b/library/src/system/BUILD.bazel index 8ef12ac3..fb05075a 100644 --- a/library/src/system/BUILD.bazel +++ b/library/src/system/BUILD.bazel @@ -59,11 +59,3 @@ cc_library( linkopts = DDS_LINKOPTS, local_defines = DDS_LOCAL_DEFINES + DDS_SCHEDULER_DEFINE + ["DDS_UTILITIES_STATS"], ) - -filegroup( - name = "wasm_sources", - srcs = glob(["*.cpp"]), - visibility = [ - "//examples:__pkg__", - ], -) diff --git a/library/src/trans_table/BUILD.bazel b/library/src/trans_table/BUILD.bazel index b3cf2f13..d9caef65 100644 --- a/library/src/trans_table/BUILD.bazel +++ b/library/src/trans_table/BUILD.bazel @@ -47,15 +47,4 @@ cc_library( visibility = [ "//library/tests/trans_table:__pkg__", ], -) - -filegroup( - name = "wasm_sources", - srcs = [ - "trans_table_l.cpp", - "trans_table_s.cpp", - ], - visibility = [ - "//examples:__pkg__", - ], ) \ No newline at end of file diff --git a/library/src/utility/BUILD.bazel b/library/src/utility/BUILD.bazel index 874ade9b..214f0e9f 100644 --- a/library/src/utility/BUILD.bazel +++ b/library/src/utility/BUILD.bazel @@ -19,12 +19,3 @@ cc_library( deps = [], ) -filegroup( - name = "wasm_sources", - srcs = ["constants.cpp"], - visibility = [ - "//examples:__pkg__", - ], -) - - diff --git a/library/tests/heuristic_sorting/BUILD.bazel b/library/tests/heuristic_sorting/BUILD.bazel index 80e0db94..3f564dd7 100644 --- a/library/tests/heuristic_sorting/BUILD.bazel +++ b/library/tests/heuristic_sorting/BUILD.bazel @@ -2,6 +2,7 @@ load("//:CPPVARIABLES.bzl", "DDS_CPPOPTS", "DDS_LINKOPTS", "DDS_LOCAL_DEFINES") load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_test", "cc_binary") + cc_test( name = "heuristic_sorting_test", size = "small", @@ -63,4 +64,4 @@ cc_test( "//library/src/moves:moves", "@googletest//:gtest_main", ], -) +) \ No newline at end of file diff --git a/library/tests/moves/BUILD.bazel b/library/tests/moves/BUILD.bazel index 47939520..5eb94e20 100644 --- a/library/tests/moves/BUILD.bazel +++ b/library/tests/moves/BUILD.bazel @@ -1,6 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_test") -package(default_visibility = ["//visibility:public"]) cc_test( name = "moves_test", diff --git a/library/tests/regression/heuristic_sorting/BUILD.bazel b/library/tests/regression/heuristic_sorting/BUILD.bazel index 2c7ef1c9..0671095c 100644 --- a/library/tests/regression/heuristic_sorting/BUILD.bazel +++ b/library/tests/regression/heuristic_sorting/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_test") + # Regression tests for heuristic sorting behavior cc_test( diff --git a/library/tests/solve_board/BUILD.bazel b/library/tests/solve_board/BUILD.bazel index 222909fd..e1d11fe1 100644 --- a/library/tests/solve_board/BUILD.bazel +++ b/library/tests/solve_board/BUILD.bazel @@ -2,6 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_test") + cc_test( name = "solve_board_test", size = "small", diff --git a/library/tests/trans_table/BUILD.bazel b/library/tests/trans_table/BUILD.bazel index 56a4e0cb..b7374c98 100644 --- a/library/tests/trans_table/BUILD.bazel +++ b/library/tests/trans_table/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + cc_library( name = "test_utilities", srcs = [ @@ -31,4 +32,4 @@ cc_test( ":test_utilities", "@googletest//:gtest_main", ], -) +) \ No newline at end of file diff --git a/library/tests/utility/BUILD.bazel b/library/tests/utility/BUILD.bazel index 5504c7c4..16101a17 100644 --- a/library/tests/utility/BUILD.bazel +++ b/library/tests/utility/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_test") + # Utility tests: constants, lookup tables, and RNG determinism validation cc_test( diff --git a/wasm/BUILD.bazel b/wasm/BUILD.bazel new file mode 100644 index 00000000..9bb72912 --- /dev/null +++ b/wasm/BUILD.bazel @@ -0,0 +1 @@ +# WASM helpers live in //:wasm_compat.bzl (no build targets in this package). diff --git a/wasm_compat.bzl b/wasm_compat.bzl new file mode 100644 index 00000000..dcec1543 --- /dev/null +++ b/wasm_compat.bzl @@ -0,0 +1,9 @@ +"""Shared attributes for WebAssembly (Emscripten) builds.""" + +# Emscripten link flags for cc_binary targets wrapped by wasm_cc_binary. +WASM_LINKOPTS = [ + "-sWASM=1", + "-fexceptions", + "-sALLOW_MEMORY_GROWTH=1", + "-sINITIAL_MEMORY=268435456", +]