Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/publish-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish SDK

on:
push:
tags:
- 'sdk-v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 0.2.0)'
required: false

jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
working-directory: sdk
run: pnpm install

- name: Build SDK
working-directory: sdk
run: pnpm run build

- name: Publish to npm
working-directory: sdk
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,18 @@ html,body{width:100%;height:100%;overflow:hidden;background:#1a1a1a}
</html>
]=])
endif()

# WeChat MiniGame SDK (CommonJS compatible)
if(ES_BUILD_WXGAME)
add_executable(esengine_wxgame src/esengine/bindings/WebSDKEntry.cpp)
target_link_libraries(esengine_wxgame PRIVATE -Wl,--whole-archive esengine -Wl,--no-whole-archive)
es_apply_wxgame_sdk_settings(esengine_wxgame)

set_target_properties(esengine_wxgame PROPERTIES
OUTPUT_NAME "esengine.wxgame"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
endif()

if(ES_BUILD_TESTS)
Expand Down
39 changes: 31 additions & 8 deletions cmake/Emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,25 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
)
endif()

# WeChat MiniGame specific settings
if(ES_BUILD_WXGAME)
list(APPEND ES_EMSCRIPTEN_LINK_FLAGS
-sENVIRONMENT=web
-sMODULARIZE=1
"-sEXPORT_NAME='ESEngineModule'"
)
endif()
# WeChat MiniGame SDK link flags (CommonJS compatible, no ES6)
set(ES_EMSCRIPTEN_WXGAME_SDK_FLAGS
--bind
-sWASM=1
-sUSE_WEBGL2=1
-sFULL_ES3=1
-sALLOW_MEMORY_GROWTH=1
-sNO_EXIT_RUNTIME=1
-sENVIRONMENT=web,node
-sEXPORT_ES6=0
-sMODULARIZE=1
-sNO_FILESYSTEM=1
-sDYNAMIC_EXECUTION=0
"-sEXPORT_NAME='ESEngineModule'"
"-sEXPORTED_FUNCTIONS=['_malloc','_free']"
"-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','HEAPF32','HEAPU8','HEAPU32','GL']"
-O3
--closure=0
)

# Helper function to apply Emscripten settings to a target (monolithic build)
function(es_apply_emscripten_settings TARGET_NAME)
Expand Down Expand Up @@ -209,6 +220,18 @@ function(es_apply_single_file_settings TARGET_NAME)
endif()
endfunction()

function(es_apply_wxgame_sdk_settings TARGET_NAME)
if(ES_BUILD_WXGAME)
target_compile_options(${TARGET_NAME} PRIVATE ${ES_EMSCRIPTEN_COMPILE_FLAGS})

string(REPLACE ";" " " LINK_FLAGS_STR "${ES_EMSCRIPTEN_WXGAME_SDK_FLAGS}")
set_target_properties(${TARGET_NAME} PROPERTIES
SUFFIX ".js"
LINK_FLAGS "${LINK_FLAGS_STR}"
)
endif()
endfunction()

message(STATUS "Emscripten configuration loaded")
if(ES_BUILD_MODULAR)
message(STATUS "Modular build enabled: MAIN_MODULE + SIDE_MODULE architecture")
Expand Down
Loading
Loading