A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: Add QuickJS scripting engine integration and CI workflow
esengine5735482594f7
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlnew file mode 100644index 000000000..c18c65137--- /dev/null+++ b/.github/workflows/build.yml@@ -0,0 +1,115 @@+name: Build++on:+ push:+ branches: [ master ]+ pull_request:+ branches: [ master ]++jobs:+ build-linux:+ name: Linux (Ubuntu GCC)+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v4+ with:+ submodules: recursive++ - name: Install dependencies+ run: |+ sudo apt-get update+ sudo apt-get install -y \+ cmake \+ ninja-build \+ libglfw3-dev \+ libgl1-mesa-dev \+ xorg-dev++ - name: Configure CMake+ run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug++ - name: Build+ run: cmake --build build++ - name: Test+ working-directory: build+ run: ctest --output-on-failure++ build-macos:+ name: macOS (Clang)+ runs-on: macos-latest++ steps:+ - uses: actions/checkout@v4+ with:+ submodules: recursive++ - name: Install dependencies+ run: |+ brew install cmake ninja glfw++ - name: Configure CMake+ run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug++ - name: Build+ run: cmake --build build++ - name: Test+ working-directory: build+ run: ctest --output-on-failure++ build-windows-mingw:+ name: Windows (MinGW-w64)+ runs-on: windows-latest++ defaults:+ run:+ shell: msys2 {0}++ steps:+ - uses: actions/checkout@v4+ with:+ submodules: recursive++ - name: Setup MSYS2+ uses: msys2/setup-msys2@v2+ with:+ msystem: MINGW64+ update: true+ install: >-+ mingw-w64-x86_64-gcc+ mingw-w64-x86_64-cmake+ mingw-w64-x86_64-ninja+ mingw-w64-x86_64-glfw+ mingw-w64-x86_64-glm++ - name: Configure CMake+ run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug++ - name: Build+ run: cmake --build build++ - name: Test+ working-directory: build+ run: ctest --output-on-failure++ build-emscripten:+ name: Web (Emscripten)+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v4+ with:+ submodules: recursive++ - name: Setup Emscripten+ uses: mymindstorm/setup-emsdk@v14+ with:+ version: latest++ - name: Configure CMake+ run: emcmake cmake -B build_web -G Ninja -DES_BUILD_WEB=ON++ - name: Build+ run: cmake --build build_webdiff --git a/.gitmodules b/.gitmodulesindex f6823d312..586cd7564 100644--- a/.gitmodules+++ b/.gitmodules@@ -4,3 +4,6 @@[submodule "third_party/glfw"]path = third_party/glfwurl = https://github.com/glfw/glfw.git+[submodule "third_party/quickjs"]+ path = third_party/quickjs+ url = https://github.com/bellard/quickjs.gitdiff --git a/CMakeLists.txt b/CMakeLists.txtindex 94a0e92fd..9873d326c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1,5 +1,5 @@cmake_minimum_required(VERSION 3.16)-project(ESEngine VERSION 0.1.0 LANGUAGES CXX)+project(ESEngine VERSION 0.1.0 LANGUAGES C CXX)set(CMAKE_CXX_STANDARD 20)set(CMAKE_CXX_STANDARD_REQUIRED ON)@@ -168,10 +168,10 @@ if(ES_BUILD_WEB OR ES_BUILD_WXGAME)target_compile_definitions(esengine PUBLIC ES_PLATFORM_WXGAME)endif()else()- # Native platform - link GLFW, GLAD, and OpenGL+ # Native platform - link GLFW, GLAD, OpenGL, and QuickJSfind_package(OpenGL REQUIRED)target_compile_definitions(esengine PUBLIC ES_PLATFORM_NATIVE)- target_link_libraries(esengine PUBLIC glfw glad OpenGL::GL)+ target_link_libraries(esengine PUBLIC glfw glad OpenGL::GL quickjs)target_include_directories(esengine PUBLIC${CMAKE_SOURCE_DIR}/third_party/glad/include)diff --git a/cmake/ESEngineConfig.cmake b/cmake/ESEngineConfig.cmakeindex 92b3a2d23..a61539f1c 100644--- a/cmake/ESEngineConfig.cmake+++ b/cmake/ESEngineConfig.cmake@@ -26,6 +26,16 @@ elseif(UNIX)add_compile_definitions(ES_PLATFORM_LINUX)endif()+# Native platform detection (for scripting support)+if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)+ add_compile_definitions(ES_PLATFORM_NATIVE)+endif()++# Scripting support (Native platform only)+if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)+ add_compile_definitions(ES_SCRIPTING_ENABLED)+endif()+# Export compile commands for IDE supportset(CMAKE_EXPORT_COMPILE_COMMANDS ON)@@ -97,3 +107,8 @@ message(STATUS " Web Build: ${ES_BUILD_WEB}")message(STATUS " WxGame Build: ${ES_BUILD_WXGAME}")message(STATUS " Build Examples: ${ES_BUILD_EXAMPLES}")message(STATUS " Build Tests: ${ES_BUILD_TESTS}")+if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)+ message(STATUS " Scripting Enabled: YES (QuickJS)")+else()+ message(STATUS " Scripting Enabled: NO (Web platform)")+endif()diff --git a/cmake/QuickJSMinGW.cmake b/cmake/QuickJSMinGW.cmakenew file mode 100644index 000000000..e6a66cd88--- /dev/null+++ b/cmake/QuickJSMinGW.cmake@@ -0,0 +1,37 @@+# =============================================================================+# QuickJS Build Configuration Helper+# =============================================================================+# QuickJS requires GCC/MinGW on Windows, cannot compile with MSVC++if(WIN32 AND MSVC)+ message(FATAL_ERROR "+========================================================================+QuickJS requires MinGW-w64 (GCC) on Windows, cannot use MSVC.++Please choose one of the following options:++Option 1 (Recommended): Use MinGW-w64 for the entire project+ 1. Install MSYS2: https://www.msys2.org/+ 2. In MSYS2 terminal: pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake+ 3. Use MSYS2 MinGW terminal to build:+ cmake -B build -G \"MinGW Makefiles\"+ cmake --build build++Option 2: Use MSYS2 UCRT64 environment (Modern Windows API)+ 1. Install MSYS2+ 2. In MSYS2 terminal: pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-cmake+ 3. Use UCRT64 terminal to build++Option 3: Mixed toolchain (Advanced)+ Use ExternalProject to build QuickJS with MinGW separately+ (Not currently implemented)++For now, please rebuild using MinGW-w64 instead of MSVC.+========================================================================+")+endif()++# GCC/MinGW-specific settings for QuickJS+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")+ message(STATUS "QuickJS: Using GCC/MinGW compiler")+endif()diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txtindex a4532149e..c24721a57 100644--- a/third_party/CMakeLists.txt+++ b/third_party/CMakeLists.txt@@ -31,4 +31,42 @@ if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)target_include_directories(glad PUBLIC${CMAKE_CURRENT_SOURCE_DIR}/glad/include)++ # =============================================================================+ # QuickJS - JavaScript Engine (Native Platform Only)+ # =============================================================================+ # QuickJS uses Unix APIs and requires MinGW on Windows (not MSVC)++ # Check compiler compatibility+ include(${CMAKE_SOURCE_DIR}/cmake/QuickJSMinGW.cmake)++ set(QUICKJS_SOURCES+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs/quickjs.c+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs/libregexp.c+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs/libunicode.c+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs/cutils.c+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs/quickjs-libc.c+ )++ add_library(quickjs STATIC ${QUICKJS_SOURCES})+ target_include_directories(quickjs PUBLIC+ ${CMAKE_CURRENT_SOURCE_DIR}/quickjs+ )++ # QuickJS specific settings+ if(WIN32)+ # On Windows, QuickJS requires MinGW (GCC), not MSVC+ # CMake will automatically use MinGW if available+ target_compile_definitions(quickjs PRIVATE+ _GNU_SOURCE+ CONFIG_VERSION="2025-09-13"+ )+ else()+ target_compile_definitions(quickjs PRIVATE+ _GNU_SOURCE+ CONFIG_VERSION="2025-09-13"+ )+ endif()++ target_compile_definitions(quickjs PUBLIC ES_SCRIPTING_ENABLED)endif()diff --git a/third_party/quickjs b/third_party/quickjsnew file mode 160000index 000000000..f1139494d--- /dev/null+++ b/third_party/quickjs@@ -0,0 +1 @@+Subproject commit f1139494d18a2053630c5ed3384a42bb70db3c53