Commit 78edd60d authored by nanahira's avatar nanahira

support wasm build

parent 8489cd62
...@@ -7,3 +7,5 @@ ...@@ -7,3 +7,5 @@
/dll.lua /dll.lua
/*.sh /*.sh
/test-wasm
/wasm
newoption { trigger = "lua-dir", description = "", value = "PATH", default = "./lua" } newoption { trigger = "lua-dir", description = "", value = "PATH", default = "./lua" }
newoption { trigger = "wasm", description = "" }
function GetParam(param) function GetParam(param)
return _OPTIONS[param] or os.getenv(string.upper(string.gsub(param,"-","_"))) return _OPTIONS[param] or os.getenv(string.upper(string.gsub(param,"-","_")))
...@@ -9,13 +10,19 @@ if not os.isdir(LUA_DIR) then ...@@ -9,13 +10,19 @@ if not os.isdir(LUA_DIR) then
LUA_DIR="../lua" LUA_DIR="../lua"
end end
WASM = GetParam("wasm")
workspace "ocgcoredll" workspace "ocgcoredll"
location "build" location "build"
language "C++" language "C++"
cppdialect "C++14" cppdialect "C++14"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
platforms { "x32", "x64" } if WASM then
toolset "emcc"
platforms { "wasm" }
else
platforms { "x32", "x64" }
end
filter "platforms:x32" filter "platforms:x32"
architecture "x32" architecture "x32"
...@@ -61,6 +68,10 @@ workspace "ocgcoredll" ...@@ -61,6 +68,10 @@ workspace "ocgcoredll"
defines { "LUA_USE_LINUX" } defines { "LUA_USE_LINUX" }
buildoptions { "-fPIC" } buildoptions { "-fPIC" }
filter "system:emscripten"
defines { "LUA_USE_LONGJMP" }
buildoptions { "-fPIC" }
filter {} filter {}
include(LUA_DIR) include(LUA_DIR)
...@@ -74,3 +85,7 @@ project "ocgcore" ...@@ -74,3 +85,7 @@ project "ocgcore"
links { "lua" } links { "lua" }
includedirs { LUA_DIR .. "/src" } includedirs { LUA_DIR .. "/src" }
filter "system:emscripten"
targetextension ".wasm"
linkoptions { "-s MODULARIZE=1", "-s EXPORT_NAME=\"createOcgcore\"", "--no-entry", "-s EXPORTED_FUNCTIONS=[\"_set_script_reader\",\"_set_card_reader\",\"_set_message_handler\",\"_create_duel\",\"_start_duel\",\"_end_duel\",\"_set_player_info\",\"_get_log_message\",\"_get_message\",\"_process\",\"_new_card\",\"_new_tag_card\",\"_query_card\",\"_query_field_count\",\"_query_field_card\",\"_query_field_info\",\"_set_responsei\",\"_set_responseb\",\"_preload_script\"]", "-s ENVIRONMENT=web,node", "-s EXPORTED_RUNTIME_METHODS=[\"ccall\",\"cwrap\",\"addFunction\",\"removeFunction\"]", "-s ALLOW_TABLE_GROWTH=1", "-s ALLOW_MEMORY_GROWTH=1", "-o ../wasm/ocgcore.js" }
project "lua" project "lua"
kind "StaticLib" kind "StaticLib"
compileas "C++" compileas "C++"
if WASM then
toolset "emcc"
end
files { "src/*.c", "src/*.h" } files { "src/*.c", "src/*.h" }
removefiles { "src/lua.c", "src/luac.c", "src/linit.c", "src/onelua.c" } removefiles { "src/lua.c", "src/luac.c", "src/onelua.c" }
if not GetParam("no-lua-safe") then
removefiles { "src/linit.c" }
end
filter "configurations:Debug" filter "configurations:Debug"
defines { "LUA_USE_APICHECK" } defines { "LUA_USE_APICHECK" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment