Commit ac79cef4 authored by nanahira's avatar nanahira

improve wasm build to cjs/esm

parent 3ad02226
Pipeline #42724 passed with stages
in 4 minutes and 51 seconds
...@@ -98,11 +98,18 @@ build_linux_x32: ...@@ -98,11 +98,18 @@ build_linux_x32:
before_script: before_script:
- apt update; apt -y install gcc-multilib g++-multilib - apt update; apt -y install gcc-multilib g++-multilib
build_wasm: build_wasm_cjs:
extends: .build_unix extends: .build_unix
variables: variables:
PREMAKE_OS: emscripten PREMAKE_OS: emscripten
BUILD_TYPE: wasm BUILD_TYPE: wasm_cjs
image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian12
build_wasm_esm:
extends: .build_unix
variables:
PREMAKE_OS: emscripten
BUILD_TYPE: wasm_esm
image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian12 image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian12
.build_windows: .build_windows:
...@@ -183,7 +190,8 @@ upload_to_minio: ...@@ -183,7 +190,8 @@ upload_to_minio:
- build_windows_x32 - build_windows_x32
- build_windows_x64 - build_windows_x64
- build_macos - build_macos
- build_wasm - build_wasm_cjs
- build_wasm_esm
tags: tags:
- linux - linux
script: script:
......
...@@ -33,7 +33,7 @@ workspace "ocgcoredll" ...@@ -33,7 +33,7 @@ workspace "ocgcoredll"
language "C++" language "C++"
cppdialect "C++14" cppdialect "C++14"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
platforms { "x64", "x32", "arm64", "wasm" } platforms { "x64", "x32", "arm64", "wasm_cjs", "wasm_esm" }
if USE_LONGJMP then if USE_LONGJMP then
defines { "LUA_USE_LONGJMP" } defines { "LUA_USE_LONGJMP" }
...@@ -87,7 +87,7 @@ workspace "ocgcoredll" ...@@ -87,7 +87,7 @@ workspace "ocgcoredll"
linkoptions { "-static-libstdc++", "-static-libgcc" } linkoptions { "-static-libstdc++", "-static-libgcc" }
end end
filter "platforms:wasm" filter "platforms:wasm_cjs or platforms:wasm_esm"
toolset "emcc" toolset "emcc"
defines { "LUA_USE_C89" } defines { "LUA_USE_C89" }
pic "On" pic "On"
...@@ -105,9 +105,28 @@ project "ocgcore" ...@@ -105,9 +105,28 @@ project "ocgcore"
includedirs { LUA_DIR .. "/src" } includedirs { LUA_DIR .. "/src" }
filter "platforms:wasm" filter "platforms:wasm_cjs or platforms:wasm_esm"
targetextension ".wasm" local wasmLinkOptions = {
linkoptions { "-s MODULARIZE=1", "-s EXPORT_NAME=\"createOcgcore\"", "--no-entry", "-s ENVIRONMENT=web,node", "-s EXPORTED_RUNTIME_METHODS=[\"ccall\",\"cwrap\",\"addFunction\",\"removeFunction\"]", "-s EXPORTED_FUNCTIONS=[\"_malloc\",\"_free\"]", "-s ALLOW_TABLE_GROWTH=1", "-s ALLOW_MEMORY_GROWTH=1", "-o ../build/bin/wasm/Release/libocgcore.js" } "-s MODULARIZE=1",
"-s EXPORT_NAME=\"createOcgcore\"",
"--no-entry",
"-s ENVIRONMENT=web,worker,node",
"-s EXPORTED_RUNTIME_METHODS=[\"ccall\",\"cwrap\",\"addFunction\",\"removeFunction\"]",
"-s EXPORTED_FUNCTIONS=[\"_malloc\",\"_free\"]",
"-s ALLOW_TABLE_GROWTH=1",
"-s ALLOW_MEMORY_GROWTH=1",
}
linkoptions(wasmLinkOptions)
filter "platforms:wasm_esm"
-- Build as ES module
targetextension ".mjs"
linkoptions { "-s EXPORT_ES6=1" }
filter "platforms:wasm_cjs"
targetextension ".cjs"
filter {}
if not WASM and SQLITE3_DIR and os.isdir(SQLITE3_DIR) then if not WASM and SQLITE3_DIR and os.isdir(SQLITE3_DIR) then
project "sqlite3" project "sqlite3"
......
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