summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjinke18 <[email protected]>2026-02-05 10:36:35 +0800
committerjinke18 <[email protected]>2026-02-05 10:36:35 +0800
commit9579dc6742e85f4a78f788e806fe5b51f26459d4 (patch)
tree036898febaadfaf2011117a5b742b5e8a3fb39b1
parent53bd7f85c3e78eb960b40d879bac30079107815c (diff)
feat: add support for running wasm target in browser
-rw-r--r--xmake/actions/run/main.lua10
1 files changed, 10 insertions, 0 deletions
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})