diff options
| author | ruki <[email protected]> | 2022-08-06 10:29:49 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-06 10:29:49 +0800 |
| commit | 66cb9f9c860e4ddebfdc21c8361d8b24e5e80028 (patch) | |
| tree | 7373f76e2bed5a289ecdbcd99d6524b7e4d8f684 | |
| parent | 67a3575689b9761677b48bfb4588712f117924fb (diff) | |
| parent | 09e241de617adcbb8912cfe06424fd32117db2a8 (diff) | |
Merge pull request #2648 from SirLynix/wasm-fixes
Wasm fixes
| -rw-r--r-- | xmake/modules/core/tools/emcc.lua | 13 | ||||
| -rw-r--r-- | xmake/rules/c++/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/rules/platform/wasm/installfiles/xmake.lua | 33 | ||||
| -rw-r--r-- | xmake/rules/platform/xmake.lua | 3 |
4 files changed, 50 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/emcc.lua b/xmake/modules/core/tools/emcc.lua index 8c08e4b0d..1c9868906 100644 --- a/xmake/modules/core/tools/emcc.lua +++ b/xmake/modules/core/tools/emcc.lua @@ -45,6 +45,19 @@ end function nf_rpathdir(self, dir) end +-- make the symbol flag +function nf_symbol(self, level) + local kind = self:kind() + if kind == "ld" or kind == "sh" then + -- emscripten requires -g when linking to map JS/wasm code back to original source + if level == "debug" then + return "-g" + end + end + + return _super.nf_symbol(self, level) +end + -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua index 9ec8f57c4..bce2606d7 100644 --- a/xmake/rules/c++/xmake.lua +++ b/xmake/rules/c++/xmake.lua @@ -63,6 +63,7 @@ rule("c++") add_deps("utils.check.licenses") -- add platform rules + add_deps("platform.wasm") add_deps("platform.windows") -- add linker rules diff --git a/xmake/rules/platform/wasm/installfiles/xmake.lua b/xmake/rules/platform/wasm/installfiles/xmake.lua new file mode 100644 index 000000000..4ccc94e60 --- /dev/null +++ b/xmake/rules/platform/wasm/installfiles/xmake.lua @@ -0,0 +1,33 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author SirLynix, ruki +-- @file xmake.lua +-- + +-- copy other files generated by emcc (see https://emscripten.org/docs/tools_reference/emcc.html#emcc-o-target) +rule("platform.wasm.installfiles") + on_load("wasm", function (target) + if not target:is_binary() then + return + end + local targetfile = target:targetfile() + target:add("installfiles", targetfile:gsub("%.html", ".js"), { prefixdir = "bin" }) + target:add("installfiles", targetfile:gsub("%.html", ".mem"), { prefixdir = "bin" }) + target:add("installfiles", targetfile:gsub("%.html", ".mjs"), { prefixdir = "bin" }) + target:add("installfiles", targetfile:gsub("%.html", ".wasm"), { prefixdir = "bin" }) + end) + diff --git a/xmake/rules/platform/xmake.lua b/xmake/rules/platform/xmake.lua index 3b11a8047..7819d8cef 100644 --- a/xmake/rules/platform/xmake.lua +++ b/xmake/rules/platform/xmake.lua @@ -18,6 +18,9 @@ -- @file xmake.lua -- +rule("platform.wasm") + add_deps("platform.wasm.installfiles") + rule("platform.windows") if is_host("windows") then add_deps("platform.windows.def") |
