From caf2e66bcecf3370472bcb9dca266ae5037f7284 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 5 Aug 2022 18:34:44 +0200 Subject: emcc: Handle -gsource-map (close #2646) --- xmake/modules/core/tools/emcc.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xmake/modules/core/tools/emcc.lua b/xmake/modules/core/tools/emcc.lua index 8c08e4b0d..18fc32848 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 -gsource-map when linking to map JS/wasm code back to original source + if level == "debug" then + return "-gsource-map" + end + end + + return _super.nf_symbol(self, level) +end + -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) -- cgit v1.3.1 From cdd5062919821da123cd84d5dbb3cb07cd889ee9 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 5 Aug 2022 18:35:24 +0200 Subject: wasm: install all files (close #2645) --- xmake/rules/platform/wasm/installfiles/xmake.lua | 33 ++++++++++++++++++++++++ xmake/rules/platform/xmake.lua | 5 ++++ 2 files changed, 38 insertions(+) create mode 100644 xmake/rules/platform/wasm/installfiles/xmake.lua 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..1e2cca8c6 100644 --- a/xmake/rules/platform/xmake.lua +++ b/xmake/rules/platform/xmake.lua @@ -18,6 +18,11 @@ -- @file xmake.lua -- +rule("platform.wasm") + if is_plat("wasm") then + add_deps("platform.wasm.installfiles") + end + rule("platform.windows") if is_host("windows") then add_deps("platform.windows.def") -- cgit v1.3.1 From 253bbdfb5ca3a78f53f024788cb13f57eb38d592 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 5 Aug 2022 18:40:18 +0200 Subject: Update xmake.lua --- xmake/rules/platform/xmake.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xmake/rules/platform/xmake.lua b/xmake/rules/platform/xmake.lua index 1e2cca8c6..7819d8cef 100644 --- a/xmake/rules/platform/xmake.lua +++ b/xmake/rules/platform/xmake.lua @@ -19,9 +19,7 @@ -- rule("platform.wasm") - if is_plat("wasm") then - add_deps("platform.wasm.installfiles") - end + add_deps("platform.wasm.installfiles") rule("platform.windows") if is_host("windows") then -- cgit v1.3.1 From 4711b6b0729fab030150f9d3acea44cfc095ad32 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 5 Aug 2022 18:44:25 +0200 Subject: Forgot to save this file --- xmake/rules/c++/xmake.lua | 1 + 1 file changed, 1 insertion(+) 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 -- cgit v1.3.1 From 09e241de617adcbb8912cfe06424fd32117db2a8 Mon Sep 17 00:00:00 2001 From: Jérôme Leclercq Date: Fri, 5 Aug 2022 22:05:11 +0200 Subject: emcc: use -g instead of -gsource-map (seems like it's enough) --- xmake/modules/core/tools/emcc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/modules/core/tools/emcc.lua b/xmake/modules/core/tools/emcc.lua index 18fc32848..1c9868906 100644 --- a/xmake/modules/core/tools/emcc.lua +++ b/xmake/modules/core/tools/emcc.lua @@ -49,9 +49,9 @@ end function nf_symbol(self, level) local kind = self:kind() if kind == "ld" or kind == "sh" then - -- emscripten requires -gsource-map when linking to map JS/wasm code back to original source + -- emscripten requires -g when linking to map JS/wasm code back to original source if level == "debug" then - return "-gsource-map" + return "-g" end end -- cgit v1.3.1