Skip to content

Commit a2e20cb

Browse files
author
StArray
committed
ci(workflow): 切换 Windows DLL 构建为 Linux 交叉编译
- 将 Windows 工作流 Runner 从 windows-latest 改为 ubuntu-latest,使用 MinGW 交叉编译工具链 - 更新 MinGW 和相关工具安装命令,改为 apt-get 安装 - 修改 CMake 配置使用 Ninja 构建,并指定交叉编译编译器和资源编译器 - 改进生成 cimgui 导入库的工具调用,使用 x86_64-w64-mingw32 前缀命令 - 将 Windows DLL 打包格式由 tar.gz 改为 zip - 删除 Android UnityResolve C++ 与 C# 相关代码,简化代码库 - Android Managed 添加 IL2CPP 动态初始化
1 parent af2a834 commit a2e20cb

12 files changed

Lines changed: 75 additions & 4191 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,41 @@ jobs:
4343
name: library-release.aar
4444
path: Android/library/build/outputs/aar/library-release.aar
4545

46-
# ──── Windows Native + .NET DLL ────
46+
# ──── Windows Native + .NET DLL (cross-compiled on Linux) ────
4747
windows:
4848
name: Windows
49-
runs-on: windows-latest
50-
defaults:
51-
run:
52-
shell: bash
49+
runs-on: ubuntu-latest
5350
steps:
5451
- uses: actions/checkout@v4
5552
with:
5653
submodules: recursive
5754

58-
- name: Set up MSYS2 (MinGW)
59-
uses: msys2/setup-msys2@v2
60-
with:
61-
msystem: mingw64
62-
update: true
63-
install: >-
64-
mingw-w64-x86_64-gcc
65-
mingw-w64-x86_64-cmake
66-
mingw-w64-x86_64-toolchain
55+
- name: Install MinGW cross-compiler
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y \
59+
gcc-mingw-w64-x86-64 \
60+
g++-mingw-w64-x86-64 \
61+
mingw-w64-tools \
62+
cmake \
63+
ninja-build
6764
6865
- name: Set up .NET 10
6966
uses: actions/setup-dotnet@v4
7067
with:
7168
dotnet-version: '10.0.x'
7269

73-
- name: Build Native (CMake + MinGW)
74-
shell: msys2 {0}
70+
- name: Build Native (CMake + MinGW cross)
7571
run: |
7672
cd StArray.ModManager.Windows/Native
77-
# Generate cimgui import lib from DLL
78-
gendef - ../dlls/cimgui.dll > cimgui.def
79-
dlltool -d cimgui.def -l libcimgui.a -D ../dlls/cimgui.dll
80-
cmake -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
73+
# Generate cimgui import lib from pre-built DLL
74+
x86_64-w64-mingw32-gendef - ../dlls/cimgui.dll > cimgui.def
75+
x86_64-w64-mingw32-dlltool -d cimgui.def -l libcimgui.a -D ../dlls/cimgui.dll
76+
cmake -B build -G Ninja \
77+
-DCMAKE_BUILD_TYPE=Release \
78+
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
79+
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
80+
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres
8181
cmake --build build
8282
8383
- name: Build C#
@@ -90,13 +90,13 @@ jobs:
9090
mkdir -p "$dst"
9191
cp -r "$src"/* "$dst/"
9292
rm -rf "$dst/runtimes"
93-
tar -czf windows-dll.tar.gz -C "$dst" .
93+
cd "$dst" && zip -r ../windows-dll.zip . && cd ..
9494
9595
- name: Upload
9696
uses: actions/upload-artifact@v4
9797
with:
9898
name: windows-dll
99-
path: windows-dll.tar.gz
99+
path: windows-dll.zip
100100

101101
# ──── Android .NET DLL ────
102102
android-dll:

‎Android/gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

‎Android/library/src/main/cpp/CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ add_compile_options(-Wno-deprecated-declarations)
2323
# ---- Source files ----
2424
set(MODMANAGER_SOURCES
2525
core/dobby_hook.cpp
26-
core/unity_resolve.cpp
27-
core/jni_helper.c
26+
core/jni_helper.c
27+
core/misc.c
2828
)
2929

3030
set(MONODROID_SOURCES
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Created by StArray on 2026/7/19.
3+
//
4+
#include <stdio.h>
5+
#include <dlfcn.h>
6+
void* modmanager_il2cpp_init() {
7+
void* handle = dlopen("libil2cpp.so", RTLD_LAZY | RTLD_NOLOAD);
8+
if (dlerror() == NULL) {
9+
return handle;
10+
}
11+
return 0;
12+
}

0 commit comments

Comments
 (0)