From 9579dc6742e85f4a78f788e806fe5b51f26459d4 Mon Sep 17 00:00:00 2001 From: jinke18 Date: Thu, 5 Feb 2026 10:36:35 +0800 Subject: feat: add support for running wasm target in browser --- xmake/actions/run/main.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 6cfe09d3a..080804ad6 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -59,6 +59,16 @@ function _do_run_target(target) targetfile = wine.program end + -- run wasm target in browser + if target:is_plat("wasm") then + local python = assert(find_tool("python3"), "python not found! python is required for running wasm target in browser!") + local url = "http://localhost:8000/" .. path.relative(targetfile, rundir):gsub("\\", "/") + print("please open the url in browser") + cprint("${color.success}%s${clear}", url) + os.execv(python.program, {"-m", "http.server"}, {curdir = rundir, detach = option.get("detach"), addenvs = addenvs, setenvs = setenvs}) + return + end + -- debugging? if option.get("debug") then debugger.run(targetfile, args, {curdir = rundir, addenvs = addenvs, setenvs = setenvs}) -- cgit v1.3.1