diff --git a/GDMP/io/BUILD b/GDMP/io/BUILD index 4592ee7..73371a7 100644 --- a/GDMP/io/BUILD +++ b/GDMP/io/BUILD @@ -9,6 +9,7 @@ cc_library( ] + select({ "//mediapipe:android": [":camera_helper_android"], "//mediapipe:ios": [":camera_helper_ios"], + "//GDMP/web:web": [], "//conditions:default": [":camera_helper_cv"], }), ) diff --git a/GDMP/web/BUILD b/GDMP/web/BUILD new file mode 100644 index 0000000..77e325c --- /dev/null +++ b/GDMP/web/BUILD @@ -0,0 +1,23 @@ +load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") + +config_setting( + name = "web", + values = { + "crosstool_top": "@emsdk//emscripten_toolchain:everything", + }, + visibility = ["//visibility:public"], +) + +cc_binary( + name = "GDMP", + linkopts = [ + "-s STANDALONE_WASM=1", + "--no-entry", + ], + deps = ["//GDMP"], +) + +wasm_cc_binary( + name = "GDMP_wasm", + cc_target = ":GDMP", +) diff --git a/build.py b/build.py index d84c59e..058c85d 100755 --- a/build.py +++ b/build.py @@ -18,6 +18,7 @@ "android": "//GDMP/android:GDMP", "desktop": "//GDMP/desktop:GDMP", "ios": "//GDMP/ios:GDMP", + "web": "//GDMP/web:GDMP_wasm", } TARGET_ARGS = { @@ -39,6 +40,11 @@ "--apple_generate_dsym=false", "--config=ios", ], + "web": [ + "--crosstool_top=@emsdk//emscripten_toolchain:everything", + "--host_crosstool_top=@bazel_tools//tools/cpp:toolchain", + "--define', 'MEDIAPIPE_DISABLE_GPU=1", + ], } @@ -153,6 +159,9 @@ def copy_ios(args: Namespace): f.extractall(output) +def copy_web(args: Namespace): + pass + def copy_output(args: Namespace): target: str = args.target output: str = args.output @@ -163,6 +172,7 @@ def copy_output(args: Namespace): "android": copy_android, "desktop": copy_desktop, "ios": copy_ios, + "web": copy_web, } copy_actions[target](args) diff --git a/patch/mediapipe/00-WORKSPACE.diff b/patch/mediapipe/00-WORKSPACE.diff index b143754..e3f49d0 100644 --- a/patch/mediapipe/00-WORKSPACE.diff +++ b/patch/mediapipe/00-WORKSPACE.diff @@ -22,3 +22,24 @@ diff --git a/WORKSPACE b/WORKSPACE # Protobuf expects an //external:python_headers target bind( name = "python_headers", +@@ -519,6 +533,20 @@ http_archive( + load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") + build_bazel_rules_nodejs_dependencies() + ++# Emscripten toolchain ++http_archive( ++ name = "emsdk", ++ sha256 = "d55e3c73fc4f8d1fecb7aabe548de86bdb55080fe6b12ce593d63b8bade54567", ++ strip_prefix = "emsdk-3891e7b04bf8cbb3bc62758e9c575ae096a9a518/bazel", ++ url = "https://github.com/emscripten-core/emsdk/archive/3891e7b04bf8cbb3bc62758e9c575ae096a9a518.tar.gz", ++) ++ ++load("@emsdk//:deps.bzl", emsdk_deps = "deps") ++emsdk_deps() ++ ++load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps") ++emsdk_emscripten_deps(emscripten_version = "2.0.31") ++ + # fetches nodejs, npm, and yarn + load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") + node_repositories()