summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-04-10 22:59:59 +0800
committerruki <[email protected]>2023-04-10 22:59:59 +0800
commit83b7bcc4c2030cacba953ea0729117d015dec5e4 (patch)
tree492bb33ed11c75c3d767c0fa88a7fee246458498
parentca6f3733a24d04a7c698a4f1b460f3bc5f111b48 (diff)
add preloadfiles for wasm #3613
-rw-r--r--xmake/rules/platform/wasm/preloadfiles/xmake.lua34
-rw-r--r--xmake/rules/platform/xmake.lua1
2 files changed, 35 insertions, 0 deletions
diff --git a/xmake/rules/platform/wasm/preloadfiles/xmake.lua b/xmake/rules/platform/wasm/preloadfiles/xmake.lua
new file mode 100644
index 000000000..d53b0cdb4
--- /dev/null
+++ b/xmake/rules/platform/wasm/preloadfiles/xmake.lua
@@ -0,0 +1,34 @@
+--!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 ruki
+-- @file xmake.lua
+--
+
+-- @see https://github.com/xmake-io/xmake/issues/3613
+rule("platform.wasm.preloadfiles")
+ on_load("wasm", function (target)
+ if not target:is_binary() then
+ return
+ end
+ local preloadfiles = target:values("wasm.preloadfiles")
+ if preloadfiles then
+ for _, preloadfile in ipairs(preloadfiles) do
+ target:add("ldflags", {"--preload-file", preloadfile}, {force = true, expand = false})
+ end
+ end
+ end)
+
diff --git a/xmake/rules/platform/xmake.lua b/xmake/rules/platform/xmake.lua
index 7819d8cef..918e48b2f 100644
--- a/xmake/rules/platform/xmake.lua
+++ b/xmake/rules/platform/xmake.lua
@@ -19,6 +19,7 @@
--
rule("platform.wasm")
+ add_deps("platform.wasm.preloadfiles")
add_deps("platform.wasm.installfiles")
rule("platform.windows")