diff --git a/.bazelrc b/.bazelrc index a0490fc5..d0ae7bf8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,3 +45,12 @@ 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/BUILD.bazel b/BUILD.bazel index 42078aa5..02ea9a23 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -72,6 +72,13 @@ config_setting( define_values = {"asan": "true"}, ) +# WebAssembly (WASM) build configuration +# Usage: bazel build --config=wasm //... +config_setting( + name = "build_wasm", + values = {"cpu": "wasm"}, +) + load("@rules_cc//cc:defs.bzl", "cc_library") diff --git a/CPPVARIABLES.bzl b/CPPVARIABLES.bzl index eee3f146..880c67d3 100644 --- a/CPPVARIABLES.bzl +++ b/CPPVARIABLES.bzl @@ -7,7 +7,6 @@ DDS_CPPOPTS = select({ "-fPIC", "-Wpedantic", "-Wall", - "-Wno-character-conversion", "-Werror", ], "//:debug_build_macos": [ @@ -16,7 +15,6 @@ DDS_CPPOPTS = select({ "-fPIC", "-Wpedantic", "-Wall", - "-Wno-character-conversion", "-Werror", ], "//:build_linux": [ @@ -51,6 +49,14 @@ DDS_CPPOPTS = select({ "/WX", "/permissive-", ], + "//:build_wasm": [ + "-O3", + "-flto", + "-Wpedantic", + "-Wall", + "-Werror", + "-fexceptions", + ], "//conditions:default": [ "-std=c++20" ], @@ -64,6 +70,7 @@ DDS_LOCAL_DEFINES = select({ "//:debug_build_macos": [], "//:build_linux": [], "//:debug_build_linux": [], + "//:build_wasm": ["__WASM__"], "//conditions:default": [], }) + select({ "//:debug_all": ["DDS_DEBUG_ALL"], diff --git a/MODULE.bazel b/MODULE.bazel index ddf9ca9d..cf4cdcb9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -9,6 +9,7 @@ bazel_dep(name = "googletest", version = "1.17.0.bcr.2") bazel_dep(name = "pybind11_bazel", version = "3.0.1") bazel_dep(name = "rules_python", version = "2.0.1") bazel_dep(name = "toolchains_llvm", version = "1.7.0") +bazel_dep(name = "emsdk", version = "5.0.7") llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") llvm.toolchain( @@ -29,4 +30,5 @@ python.toolchain( ) use_repo(python, "python_3_14") -register_toolchains("@llvm_toolchain//:all") \ No newline at end of file +register_toolchains("@llvm_toolchain//:all") +register_toolchains("@emsdk//:all") \ No newline at end of file diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 0d0059a5..54b461c3 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -41,12 +41,15 @@ "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", "https://bcr.bazel.build/modules/bazel_features/1.34.0/MODULE.bazel": "e8475ad7c8965542e0c7aac8af68eb48c4af904be3d614b6aa6274c092c2ea1e", "https://bcr.bazel.build/modules/bazel_features/1.38.0/MODULE.bazel": "f9b8a9c890ebd216b4049fd12a31d3c2602e3403c7af636b04fbbd7453edc9c9", + "https://bcr.bazel.build/modules/bazel_features/1.39.0/MODULE.bazel": "28739425c1fc283c91931619749c832b555e60bcd1010b40d8441ce0a5cf726d", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080", "https://bcr.bazel.build/modules/bazel_features/1.43.0/MODULE.bazel": "defa2226f06ba20550d6548c3a2ea2a7929634437a52973869c20c225450eb91", "https://bcr.bazel.build/modules/bazel_features/1.43.0/source.json": "1c4207dc858d6de0eecef30026793616bbf420c74aac27b6bad212534a730437", "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", + "https://bcr.bazel.build/modules/bazel_lib/3.0.0/MODULE.bazel": "22b70b80ac89ad3f3772526cd9feee2fa412c2b01933fea7ed13238a448d370d", + "https://bcr.bazel.build/modules/bazel_lib/3.0.0/source.json": "895f21909c6fba01d7c17914bb6c8e135982275a1b18cdaa4e62272217ef1751", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", @@ -65,6 +68,8 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.9.0/source.json": "7ad77c1e8c1b84222d9b3f3cae016a76639435744c19330b0b37c0a3c9da7dc0", "https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f", "https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd", + "https://bcr.bazel.build/modules/emsdk/5.0.7/MODULE.bazel": "c9464a9a8c07bdef4bf2ddcd67c20bcb3c71915da818679756b1e85a04a0b9c0", + "https://bcr.bazel.build/modules/emsdk/5.0.7/source.json": "0c4e55e4b706d842045b1b8583efc060945432722c81a8f9a7f0855c986d6321", "https://bcr.bazel.build/modules/gawk/5.3.2.bcr.1/MODULE.bazel": "cdf8cbe5ee750db04b78878c9633cc76e80dcf4416cbe982ac3a9222f80713c8", "https://bcr.bazel.build/modules/gawk/5.3.2.bcr.1/source.json": "fa7b512dfcb5eafd90ce3959cf42a2a6fe96144ebbb4b3b3928054895f2afac2", "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", @@ -141,6 +146,7 @@ "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", + "https://bcr.bazel.build/modules/rules_cc/0.2.16/MODULE.bazel": "9242fa89f950c6ef7702801ab53922e99c69b02310c39fb6e62b2bd30df2a1d4", "https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84", "https://bcr.bazel.build/modules/rules_cc/0.2.18/MODULE.bazel": "4460ec36adc8f722a6a2a4ac9374cb91f2acebadaa93fc37966129afb3dece87", "https://bcr.bazel.build/modules/rules_cc/0.2.18/source.json": "abad668ff2fd63ada1ac49bf386d37e27048b89a3465a6fd968bb832b00a09d3", @@ -173,6 +179,8 @@ "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", "https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb", + "https://bcr.bazel.build/modules/rules_nodejs/6.7.3/MODULE.bazel": "c22a48b2a0dbf05a9dc5f83837bbc24c226c1f6e618de3c3a610044c9f336056", + "https://bcr.bazel.build/modules/rules_nodejs/6.7.3/source.json": "a3f966f4415a8a6545e560ee5449eac95cc633f96429d08e87c87775c72f5e09", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", "https://bcr.bazel.build/modules/rules_pkg/1.0.1/MODULE.bazel": "5b1df97dbc29623bccdf2b0dcd0f5cb08e2f2c9050aab1092fd39a41e82686ff", "https://bcr.bazel.build/modules/rules_pkg/1.0.1/source.json": "bd82e5d7b9ce2d31e380dd9f50c111d678c3bdaca190cb76b0e1c71b05e1ba8a", @@ -195,6 +203,7 @@ "https://bcr.bazel.build/modules/rules_python/1.5.1/MODULE.bazel": "acfe65880942d44a69129d4c5c3122d57baaf3edf58ae5a6bd4edea114906bf5", "https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8", "https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8", + "https://bcr.bazel.build/modules/rules_python/1.8.4/MODULE.bazel": "33e3971e66161a3e955f7a0d411a8d1f291c4ce4c561851512466f3c77ff8ece", "https://bcr.bazel.build/modules/rules_python/1.9.0/MODULE.bazel": "afc3a05f29f09f2d3ee95ad99a145250dab41a2b2d8d6f82cc91936b3213282c", "https://bcr.bazel.build/modules/rules_python/2.0.1/MODULE.bazel": "294fbfe4dc3b24a925172e5487e1e8d3c2927cf4fba1eaddd7bad0ce50701da1", "https://bcr.bazel.build/modules/rules_python/2.0.1/source.json": "f2bacc75d3fc496dfd3e6a5986200b10e70169aaaf4ee5f1cea573c8d347e7c4", @@ -233,6 +242,94 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { + "@@emsdk+//:emscripten_cache.bzl%emscripten_cache": { + "general": { + "bzlTransitiveDigest": "uqDvXmpTNqW4+ie/Fk+xC3TrFrKvL+9hNtoP51Kt2oo=", + "usagesDigest": "VPgNmvM2UoqCG4eFVWZb0w4XPfP0v8NIzb+KfzDwqVE=", + "recordedInputs": [], + "generatedRepoSpecs": { + "emscripten_cache": { + "repoRuleId": "@@emsdk+//:emscripten_cache.bzl%_emscripten_cache_repository", + "attributes": { + "configuration": [], + "targets": [] + } + } + } + } + }, + "@@emsdk+//:emscripten_deps.bzl%emscripten_deps": { + "general": { + "bzlTransitiveDigest": "Dt5IF0PG0xjU5iMLeU6FQ1/xWvBqUgUognNk3r5pJXY=", + "usagesDigest": "lqS0hMGr6MqmX63BGZOskMFcqzqO53K0UlYFxuE3QSU=", + "recordedInputs": [ + "REPO_MAPPING:bazel_features+,bazel_features_globals bazel_features++version_extension+bazel_features_globals", + "REPO_MAPPING:bazel_features+,bazel_features_version bazel_features++version_extension+bazel_features_version", + "REPO_MAPPING:emsdk+,bazel_tools bazel_tools", + "REPO_MAPPING:emsdk+,rules_cc rules_cc+", + "REPO_MAPPING:protobuf+,proto_bazel_features bazel_features+", + "REPO_MAPPING:rules_cc+,bazel_skylib bazel_skylib+", + "REPO_MAPPING:rules_cc+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_cc+,cc_compatibility_proxy rules_cc++compatibility_proxy+cc_compatibility_proxy", + "REPO_MAPPING:rules_cc+,com_google_protobuf protobuf+", + "REPO_MAPPING:rules_cc+,platforms platforms", + "REPO_MAPPING:rules_cc+,rules_cc rules_cc+", + "REPO_MAPPING:rules_cc++compatibility_proxy+cc_compatibility_proxy,rules_cc rules_cc+" + ], + "generatedRepoSpecs": { + "emscripten_bin_linux": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "\npackage(default_visibility = ['//visibility:public'])\n\nfilegroup(\n name = \"all\",\n srcs = glob([\"**\"]),\n)\n\nfilegroup(\n name = \"includes\",\n srcs = glob([\n \"emscripten/cache/sysroot/include/c++/v1/**\",\n \"emscripten/cache/sysroot/include/compat/**\",\n \"emscripten/cache/sysroot/include/**\",\n \"lib/clang/**/include/**\",\n ]),\n)\n\nfilegroup(\n name = \"emcc_common\",\n srcs = [\n \"emscripten/emcc.py\",\n \"emscripten/embuilder.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/cache/sysroot_install.stamp\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/third_party/**\",\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"compiler_files\",\n srcs = [\n \"bin/clang\",\n \"bin/clang++\",\n \":emcc_common\",\n \":includes\",\n ],\n)\n\nfilegroup(\n name = \"linker_files\",\n srcs = [\n \"bin/clang\",\n \"bin/llvm-ar\",\n \"bin/llvm-dwarfdump\",\n \"bin/llvm-nm\",\n \"bin/llvm-objcopy\",\n \"bin/wasm-ctor-eval\",\n \"bin/wasm-emscripten-finalize\",\n \"bin/wasm-ld\",\n \"bin/wasm-metadce\",\n \"bin/wasm-opt\",\n \"bin/wasm-split\",\n \"bin/wasm2js\",\n \":emcc_common\",\n ] + glob(\n include = [\n \"emscripten/cache/sysroot/lib/**\",\n \"emscripten/node_modules/**\",\n \"emscripten/src/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"ar_files\",\n srcs = [\n \"bin/llvm-ar\",\n \"emscripten/emar.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n", + "sha256": "f96cc4df9263e386d70ad37c731959886cb2a7e983b7a68bdc9ccf32402be1bd", + "strip_prefix": "install", + "type": "tar.xz", + "url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/6cd98e86d7749ff98b82b7f2ae78eb4f01942788/wasm-binaries.tar.xz" + } + }, + "emscripten_bin_linux_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "\npackage(default_visibility = ['//visibility:public'])\n\nfilegroup(\n name = \"all\",\n srcs = glob([\"**\"]),\n)\n\nfilegroup(\n name = \"includes\",\n srcs = glob([\n \"emscripten/cache/sysroot/include/c++/v1/**\",\n \"emscripten/cache/sysroot/include/compat/**\",\n \"emscripten/cache/sysroot/include/**\",\n \"lib/clang/**/include/**\",\n ]),\n)\n\nfilegroup(\n name = \"emcc_common\",\n srcs = [\n \"emscripten/emcc.py\",\n \"emscripten/embuilder.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/cache/sysroot_install.stamp\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/third_party/**\",\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"compiler_files\",\n srcs = [\n \"bin/clang\",\n \"bin/clang++\",\n \":emcc_common\",\n \":includes\",\n ],\n)\n\nfilegroup(\n name = \"linker_files\",\n srcs = [\n \"bin/clang\",\n \"bin/llvm-ar\",\n \"bin/llvm-dwarfdump\",\n \"bin/llvm-nm\",\n \"bin/llvm-objcopy\",\n \"bin/wasm-ctor-eval\",\n \"bin/wasm-emscripten-finalize\",\n \"bin/wasm-ld\",\n \"bin/wasm-metadce\",\n \"bin/wasm-opt\",\n \"bin/wasm-split\",\n \"bin/wasm2js\",\n \":emcc_common\",\n ] + glob(\n include = [\n \"emscripten/cache/sysroot/lib/**\",\n \"emscripten/node_modules/**\",\n \"emscripten/src/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"ar_files\",\n srcs = [\n \"bin/llvm-ar\",\n \"emscripten/emar.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n", + "sha256": "3cd706f3c97bc9e2abc9898c66ed15988243d189194623a4fb02ec207dc48693", + "strip_prefix": "install", + "type": "tar.xz", + "url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/6cd98e86d7749ff98b82b7f2ae78eb4f01942788/wasm-binaries-arm64.tar.xz" + } + }, + "emscripten_bin_mac": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "\npackage(default_visibility = ['//visibility:public'])\n\nfilegroup(\n name = \"all\",\n srcs = glob([\"**\"]),\n)\n\nfilegroup(\n name = \"includes\",\n srcs = glob([\n \"emscripten/cache/sysroot/include/c++/v1/**\",\n \"emscripten/cache/sysroot/include/compat/**\",\n \"emscripten/cache/sysroot/include/**\",\n \"lib/clang/**/include/**\",\n ]),\n)\n\nfilegroup(\n name = \"emcc_common\",\n srcs = [\n \"emscripten/emcc.py\",\n \"emscripten/embuilder.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/cache/sysroot_install.stamp\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/third_party/**\",\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"compiler_files\",\n srcs = [\n \"bin/clang\",\n \"bin/clang++\",\n \":emcc_common\",\n \":includes\",\n ],\n)\n\nfilegroup(\n name = \"linker_files\",\n srcs = [\n \"bin/clang\",\n \"bin/llvm-ar\",\n \"bin/llvm-dwarfdump\",\n \"bin/llvm-nm\",\n \"bin/llvm-objcopy\",\n \"bin/wasm-ctor-eval\",\n \"bin/wasm-emscripten-finalize\",\n \"bin/wasm-ld\",\n \"bin/wasm-metadce\",\n \"bin/wasm-opt\",\n \"bin/wasm-split\",\n \"bin/wasm2js\",\n \":emcc_common\",\n ] + glob(\n include = [\n \"emscripten/cache/sysroot/lib/**\",\n \"emscripten/node_modules/**\",\n \"emscripten/src/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"ar_files\",\n srcs = [\n \"bin/llvm-ar\",\n \"emscripten/emar.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n", + "sha256": "0ccd510ae3e1014ffc565de482982507d1c2d3d6dc6f5bf243e857c73bd5d352", + "strip_prefix": "install", + "type": "tar.xz", + "url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/6cd98e86d7749ff98b82b7f2ae78eb4f01942788/wasm-binaries.tar.xz" + } + }, + "emscripten_bin_mac_arm64": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "\npackage(default_visibility = ['//visibility:public'])\n\nfilegroup(\n name = \"all\",\n srcs = glob([\"**\"]),\n)\n\nfilegroup(\n name = \"includes\",\n srcs = glob([\n \"emscripten/cache/sysroot/include/c++/v1/**\",\n \"emscripten/cache/sysroot/include/compat/**\",\n \"emscripten/cache/sysroot/include/**\",\n \"lib/clang/**/include/**\",\n ]),\n)\n\nfilegroup(\n name = \"emcc_common\",\n srcs = [\n \"emscripten/emcc.py\",\n \"emscripten/embuilder.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/cache/sysroot_install.stamp\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/third_party/**\",\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"compiler_files\",\n srcs = [\n \"bin/clang\",\n \"bin/clang++\",\n \":emcc_common\",\n \":includes\",\n ],\n)\n\nfilegroup(\n name = \"linker_files\",\n srcs = [\n \"bin/clang\",\n \"bin/llvm-ar\",\n \"bin/llvm-dwarfdump\",\n \"bin/llvm-nm\",\n \"bin/llvm-objcopy\",\n \"bin/wasm-ctor-eval\",\n \"bin/wasm-emscripten-finalize\",\n \"bin/wasm-ld\",\n \"bin/wasm-metadce\",\n \"bin/wasm-opt\",\n \"bin/wasm-split\",\n \"bin/wasm2js\",\n \":emcc_common\",\n ] + glob(\n include = [\n \"emscripten/cache/sysroot/lib/**\",\n \"emscripten/node_modules/**\",\n \"emscripten/src/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"ar_files\",\n srcs = [\n \"bin/llvm-ar\",\n \"emscripten/emar.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n", + "sha256": "37554ed4c36abb1c802aa280f2c1ef9702e19e832a66c2fe6d940b65a2049b2c", + "strip_prefix": "install", + "type": "tar.xz", + "url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/6cd98e86d7749ff98b82b7f2ae78eb4f01942788/wasm-binaries-arm64.tar.xz" + } + }, + "emscripten_bin_win": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "build_file_content": "\npackage(default_visibility = ['//visibility:public'])\n\nfilegroup(\n name = \"all\",\n srcs = glob([\"**\"]),\n)\n\nfilegroup(\n name = \"includes\",\n srcs = glob([\n \"emscripten/cache/sysroot/include/c++/v1/**\",\n \"emscripten/cache/sysroot/include/compat/**\",\n \"emscripten/cache/sysroot/include/**\",\n \"lib/clang/**/include/**\",\n ]),\n)\n\nfilegroup(\n name = \"emcc_common\",\n srcs = [\n \"emscripten/emcc.py\",\n \"emscripten/embuilder.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/cache/sysroot_install.stamp\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/third_party/**\",\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"compiler_files\",\n srcs = [\n \"bin/clang.exe\",\n \"bin/clang++.exe\",\n \":emcc_common\",\n \":includes\",\n ],\n)\n\nfilegroup(\n name = \"linker_files\",\n srcs = [\n \"bin/clang.exe\",\n \"bin/llvm-ar.exe\",\n \"bin/llvm-dwarfdump.exe\",\n \"bin/llvm-nm.exe\",\n \"bin/llvm-objcopy.exe\",\n \"bin/wasm-ctor-eval.exe\",\n \"bin/wasm-emscripten-finalize.exe\",\n \"bin/wasm-ld.exe\",\n \"bin/wasm-metadce.exe\",\n \"bin/wasm-opt.exe\",\n \"bin/wasm-split.exe\",\n \"bin/wasm2js.exe\",\n \":emcc_common\",\n ] + glob(\n include = [\n \"emscripten/cache/sysroot/lib/**\",\n \"emscripten/node_modules/**\",\n \"emscripten/src/**\",\n ],\n ),\n)\n\nfilegroup(\n name = \"ar_files\",\n srcs = [\n \"bin/llvm-ar.exe\",\n \"emscripten/emar.py\",\n \"emscripten/emscripten-version.txt\",\n \"emscripten/src/settings.js\",\n \"emscripten/src/settings_internal.js\",\n ] + glob(\n include = [\n \"emscripten/tools/**\",\n ],\n exclude = [\n \"**/__pycache__/**\",\n ],\n ),\n)\n", + "sha256": "32995a98db21951cb7e84b4898b235ba57553c9f35eeaa158cfff052fab83856", + "strip_prefix": "install", + "type": "zip", + "url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/6cd98e86d7749ff98b82b7f2ae78eb4f01942788/wasm-binaries.zip" + } + } + } + } + }, "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { "bzlTransitiveDigest": "Ga4z8lQy1YQ5rAMy+dOl0dqcCEBnYNCXku8x3YQmDZI=", @@ -290,6 +387,137 @@ } } }, + "@@rules_nodejs+//nodejs:extensions.bzl%node": { + "general": { + "bzlTransitiveDigest": "4pUxCNc22K4I+6+4Nxu52Hur12tFRfa1JMsN5mdDv60=", + "usagesDigest": "FvBWrdNTUrXyEUQ4cLS6ZvBDMhUc1qMqDU70KQC+LHY=", + "recordedInputs": [], + "generatedRepoSpecs": { + "nodejs_linux_amd64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "linux_amd64" + } + }, + "nodejs_linux_arm64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "linux_arm64" + } + }, + "nodejs_linux_s390x": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "linux_s390x" + } + }, + "nodejs_linux_ppc64le": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "linux_ppc64le" + } + }, + "nodejs_darwin_amd64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "darwin_amd64" + } + }, + "nodejs_darwin_arm64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "darwin_arm64" + } + }, + "nodejs_windows_amd64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "windows_amd64" + } + }, + "nodejs_windows_arm64": { + "repoRuleId": "@@rules_nodejs+//nodejs:repositories.bzl%_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "20.18.0", + "include_headers": false, + "platform": "windows_arm64" + } + }, + "nodejs": { + "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_host": { + "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_repo_host_os_alias.bzl%nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_toolchains": { + "repoRuleId": "@@rules_nodejs+//nodejs/private:nodejs_toolchains_repo.bzl%nodejs_toolchains_repo", + "attributes": { + "user_node_repository_name": "nodejs" + } + } + } + } + }, "@@rules_python+//python/uv:uv.bzl%uv": { "general": { "bzlTransitiveDigest": "I8FPZMevE2oI/peSpMBRVIN++WOtfjtJVjbPsBZQ87A=", diff --git a/docs/wasm_build.md b/docs/wasm_build.md new file mode 100644 index 00000000..9cfca6db --- /dev/null +++ b/docs/wasm_build.md @@ -0,0 +1,136 @@ +# WebAssembly (WASM) Build Guide + +This document explains how to build the DDS library and examples for WebAssembly using Bazel. + +## Prerequisites + +### Bazel + +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. + +## Building WASM Examples + +### Build All Examples + +```bash +cd /workspaces/dds +bazel build //examples:all_examples_wasm +``` + +### Build Specific Example + +```bash +bazel build //examples:solve_board_wasm +``` + +### Output Files + +the output files will be located in: +``` +bazel-bin/examples/ +``` + +Depending on the target, you'll get: +- `target.js` - JavaScript bindings +- `target.wasm` - WebAssembly binary + + +## Available WASM Targets + +The following example targets are available for WASM builds: + +### Implemented Examples +- `solve_board` - Solves a single board (produces .js and .wasm) + +- `analyse_play_bin` - Analyze play from binary format + + +## WASM Build Configuration + +The WASM build is configured through: + +1. **BUILD.bazel** - Defines the WASM config_setting: + ```python + config_setting( + name = "build_wasm", + values = {"cpu": "wasm"}, + ) + ``` + +2. **CPPVARIABLES.bzl** - Specifies WASM-specific compiler flags: + - Optimization: `-O3 -flto` + - Exceptions: `-fexceptions` + - Define: `-D__WASM__` + +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 + ``` + +## Running WASM Examples + +After building, you can run the examples: + +### Node.js (requires Node.js installed) + +```bash +node bazel-bin/examples/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 +``` + +## Compilation Flags + +The WASM build uses the following key flags: + +| Flag | Purpose | +|------|---------| +| `-O3` | Aggressive optimization | +| `-flto` | Link-time optimization | +| `-fexceptions` | Enable C++ exceptions | +| `-D__WASM__` | Defines `__WASM__` preprocessor constant | +| `-sWASM=1` | Emscripten WASM output (link flag) | +| `-sALLOW_MEMORY_GROWTH=1` | Allow heap growth at runtime | +| `-sINITIAL_MEMORY=268435456` | Configure 256MB initial memory | + +## C++ Standard + +The WASM build uses C++20 as specified in `.bazelrc`: +``` +build:wasm --cxxopt=-std=c++20 +``` + +## Related Documentation + +- [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) + +## 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 + +- 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 diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 307fe4a1..1ddb8500 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -1,9 +1,63 @@ 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", + ], +) + +wasm_cc_binary( + name = "analyse_play_bin_wasm", + cc_target = ":AnalysePlayBin", + outputs = [ + "AnalysePlayBin.js", + "AnalysePlayBin.wasm", + ], +) # Examples use legacy C-style code, so we need to suppress certain warnings EXAMPLES_CPPOPTS = DDS_CPPOPTS + select({ "//:build_windows": [], + "//:build_wasm": [], # em++ has different warning flags "//:debug_build_windows": [], "//conditions:default": [ "-Wno-deprecated-declarations", @@ -17,6 +71,17 @@ EXAMPLES_LOCAL_DEFINES = DDS_LOCAL_DEFINES + select({ "//conditions:default": [], }) +# WASM-specific link flags for em++ output (produces .html, .js, .wasm) +EXAMPLES_LINKOPTS_WASM = select({ + "//:build_wasm": [ + "-sWASM=1", + "-fexceptions", + "-sALLOW_MEMORY_GROWTH=1", + "-sINITIAL_MEMORY=268435456", + ], + "//conditions:default": [], +}) + # Shared utilities used by all examples cc_library( name = "hands", @@ -35,7 +100,7 @@ cc_binary( name = "analyse_all_plays_bin", srcs = ["analyse_all_plays_bin.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -48,7 +113,7 @@ cc_binary( name = "analyse_all_plays_pbn", srcs = ["analyse_all_plays_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -58,10 +123,10 @@ cc_binary( ) cc_binary( - name = "analyse_play_bin", + name = "AnalysePlayBin", srcs = ["analyse_play_bin.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -74,7 +139,7 @@ cc_binary( name = "analyse_play_pbn", srcs = ["analyse_play_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -87,7 +152,7 @@ cc_binary( name = "calc_all_tables", srcs = ["calc_all_tables.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -100,7 +165,7 @@ cc_binary( name = "calc_all_tables_pbn", srcs = ["calc_all_tables_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -113,7 +178,7 @@ cc_binary( name = "calc_dd_table", srcs = ["calc_dd_table.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -126,7 +191,7 @@ cc_binary( name = "calc_dd_table_pbn", srcs = ["calc_dd_table_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -139,7 +204,7 @@ cc_binary( name = "dealer_par", srcs = ["dealer_par.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -152,7 +217,7 @@ cc_binary( name = "par", srcs = ["par.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -165,7 +230,7 @@ cc_binary( name = "solve_all_boards", srcs = ["solve_all_boards.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -178,7 +243,7 @@ cc_binary( name = "solve_board", srcs = ["solve_board.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -191,7 +256,7 @@ cc_binary( name = "solve_board_pbn", srcs = ["solve_board_pbn.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -204,7 +269,7 @@ cc_binary( name = "migration_example", srcs = ["migration_example.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ "//library/src:dds", @@ -216,7 +281,7 @@ cc_binary( name = "calc_par_context_example", srcs = ["calc_par_context_example.cpp"], copts = EXAMPLES_CPPOPTS, - linkopts = DDS_LINKOPTS, + linkopts = DDS_LINKOPTS + EXAMPLES_LINKOPTS_WASM, local_defines = EXAMPLES_LOCAL_DEFINES, deps = [ ":hands", @@ -232,7 +297,7 @@ filegroup( srcs = [ ":analyse_all_plays_bin", ":analyse_all_plays_pbn", - ":analyse_play_bin", + ":AnalysePlayBin", ":analyse_play_pbn", ":calc_all_tables", ":calc_all_tables_pbn", @@ -247,3 +312,11 @@ filegroup( ":migration_example", ], ) + +filegroup( + name = "all_examples_wasm", + srcs = [ + ":analyse_play_bin_wasm", + ":solve_board_wasm", + ], +) diff --git a/examples/analyse_play_bin.cpp b/examples/analyse_play_bin.cpp index 6e77ba33..5b97cd68 100644 --- a/examples/analyse_play_bin.cpp +++ b/examples/analyse_play_bin.cpp @@ -30,7 +30,7 @@ auto main() -> int char line[80]; bool match; -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__WASM__) SetMaxThreads(0); #endif @@ -62,7 +62,12 @@ auto main() -> int if (res != RETURN_NO_FAULT) { + #ifdef __WASM__ + // For WASM, we can't use ErrorMessage, so we'll just print the error code + snprintf(line, sizeof(line), "error code %d", res); + #else ErrorMessage(res, line); + #endif printf("DDS error: %s\n", line); } diff --git a/examples/solve_board.cpp b/examples/solve_board.cpp index 64042f4a..b42bffb2 100644 --- a/examples/solve_board.cpp +++ b/examples/solve_board.cpp @@ -33,7 +33,7 @@ auto main() -> int bool match2; bool match3; -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__WASM__) SetMaxThreads(0); #endif diff --git a/examples/solve_board_pbn.cpp b/examples/solve_board_pbn.cpp index 4c23c0da..a24f5c7e 100644 --- a/examples/solve_board_pbn.cpp +++ b/examples/solve_board_pbn.cpp @@ -32,7 +32,7 @@ auto main() -> int bool match2, match3; -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__WASM__) SetMaxThreads(0); #endif diff --git a/library/src/BUILD.bazel b/library/src/BUILD.bazel index ef21a82c..ca141ddd 100644 --- a/library/src/BUILD.bazel +++ b/library/src/BUILD.bazel @@ -49,6 +49,9 @@ filegroup( srcs = glob([ "*.cpp", ],), + visibility = [ + "//examples:__pkg__", + ], ) filegroup( @@ -56,6 +59,19 @@ filegroup( srcs = glob([ "*.hpp", "*.h", ],), + visibility = [ + "//examples:__pkg__", + ], +) + +filegroup( + name = "dds_wasm_sources", + srcs = glob([ + "**/*.cpp", + ]), + visibility = [ + "//examples:__pkg__", + ], ) cc_library( diff --git a/library/src/heuristic_sorting/BUILD.bazel b/library/src/heuristic_sorting/BUILD.bazel index 6ce9cdcd..e6e7ffb1 100644 --- a/library/src/heuristic_sorting/BUILD.bazel +++ b/library/src/heuristic_sorting/BUILD.bazel @@ -44,4 +44,12 @@ 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 76f9c93f..2e35514c 100644 --- a/library/src/lookup_tables/BUILD.bazel +++ b/library/src/lookup_tables/BUILD.bazel @@ -14,3 +14,11 @@ 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 317f5645..75d13fff 100644 --- a/library/src/moves/BUILD.bazel +++ b/library/src/moves/BUILD.bazel @@ -35,4 +35,12 @@ 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 a566211b..d25dea9e 100644 --- a/library/src/solver_context/BUILD.bazel +++ b/library/src/solver_context/BUILD.bazel @@ -51,3 +51,11 @@ 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 fb05075a..8ef12ac3 100644 --- a/library/src/system/BUILD.bazel +++ b/library/src/system/BUILD.bazel @@ -59,3 +59,11 @@ 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 d9caef65..b3cf2f13 100644 --- a/library/src/trans_table/BUILD.bazel +++ b/library/src/trans_table/BUILD.bazel @@ -47,4 +47,15 @@ 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 18610f9e..874ade9b 100644 --- a/library/src/utility/BUILD.bazel +++ b/library/src/utility/BUILD.bazel @@ -19,4 +19,12 @@ cc_library( deps = [], ) +filegroup( + name = "wasm_sources", + srcs = ["constants.cpp"], + visibility = [ + "//examples:__pkg__", + ], +) +