fix: goldmapper on ci

This commit is contained in:
neoapps-dev
2026-09-01 14:01:39 +03:00
parent 5d21aaee3e
commit 9a9c11c716
7 changed files with 159 additions and 50 deletions
+81
View File
@@ -0,0 +1,81 @@
import { spawnSync } from "node:child_process";
import { existsSync, copyFileSync, mkdirSync, readdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.resolve(SCRIPT_DIR, "..");
const GOLDMAPPER_DIR = path.join(ROOT_DIR, "GoldMapper");
const BUILD_DIR = path.join(GOLDMAPPER_DIR, "build");
const RESOURCES_DIR = path.join(ROOT_DIR, "src-tauri", "resources");
const TOOLCHAIN_MINGW = path.join(SCRIPT_DIR, "toolchain-mingw.cmake");
const IS_WINDOWS = process.platform === "win32";
function run(cmd, args, cwd) {
console.log(`> ${cmd} ${args.join(" ")}`);
const res = spawnSync(cmd, args, {
cwd,
stdio: "inherit",
shell: IS_WINDOWS,
});
if (res.status !== 0) {
process.exit(res.status ?? 1);
}
}
if (
!existsSync(
path.join(GOLDMAPPER_DIR, "third_party", "minhook", "include", "MinHook.h"),
)
) {
console.log("Initializing minhook submodule...");
run(
"git",
["-C", GOLDMAPPER_DIR, "submodule", "update", "--init", "--recursive"],
ROOT_DIR,
);
}
console.log("Configuring GoldMapper...");
const configureArgs = ["-B", BUILD_DIR, "-DCMAKE_BUILD_TYPE=Release"];
if (!IS_WINDOWS) {
configureArgs.push("-DCMAKE_TOOLCHAIN_FILE=" + TOOLCHAIN_MINGW);
}
configureArgs.push(GOLDMAPPER_DIR);
run("cmake", configureArgs, ROOT_DIR);
console.log("Building GoldMapper...");
run("cmake", ["--build", BUILD_DIR, "--config", "Release"], ROOT_DIR);
console.log("Copying binaries to resources...");
mkdirSync(RESOURCES_DIR, { recursive: true });
const outputs = [
{
source: "GoldMapperLib.dll",
names: ["GoldMapperLib.dll", "libGoldMapperLib.dll"], //neo: dont ask me vro idk why it does that
},
{ source: "GoldMapperLauncher.exe", names: ["GoldMapperLauncher.exe"] },
{
source: "SDL2.dll",
names: ["SDL2.dll"],
dir: path.join(GOLDMAPPER_DIR, "third_party", "SDL2-2.32.6", "lib", "x64"),
},
];
for (const entry of outputs) {
const dir = entry.dir ?? BUILD_DIR;
const file = path.join(dir, entry.source);
if (existsSync(file)) {
copyFileSync(file, path.join(RESOURCES_DIR, entry.source));
continue;
}
const candidate = readdirSync(dir).find((f) =>
entry.names.some((n) => f.toLowerCase() === n.toLowerCase()),
);
if (!candidate) {
console.error(`Missing build output: ${entry.source}`);
process.exit(1);
}
copyFileSync(
path.join(dir, candidate),
path.join(RESOURCES_DIR, entry.source),
);
}
console.log("GoldMapper build complete.");
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
GOLDMAPPER_DIR="$ROOT_DIR/GoldMapper"
BUILD_DIR="$GOLDMAPPER_DIR/build"
RESOURCES_DIR="$ROOT_DIR/src-tauri/resources"
if ! command -v xwin &> /dev/null; then
echo "Installing xwin..."
cargo install xwin
fi
if [ ! -d "$HOME/.cache/xwin/splat" ]; then
echo "Downloading Windows SDK and CRT..."
xwin --accept-license 16299.309000601.3633040603 splat --output "$HOME/.cache/xwin/splat"
fi
if [ ! -f "$GOLDMAPPER_DIR/third_party/minhook/include/MinHook.h" ]; then
echo "Initializing minhook submodule..."
git -C "$GOLDMAPPER_DIR" submodule update --init --recursive
fi
echo "Configuring GoldMapper..."
cmake -B "$BUILD_DIR" \
-DCMAKE_TOOLCHAIN_FILE="$GOLDMAPPER_DIR/toolchain-xwin.cmake" \
-DCMAKE_BUILD_TYPE=Release \
"$GOLDMAPPER_DIR"
echo "Building GoldMapper..."
cmake --build "$BUILD_DIR" --config Release
echo "Copying binaries to resources..."
mkdir -p "$RESOURCES_DIR"
cp "$BUILD_DIR/GoldMapperLib.dll" "$RESOURCES_DIR/"
cp "$BUILD_DIR/GoldMapperLauncher.exe" "$RESOURCES_DIR/"
cp "$BUILD_DIR/../third_party/SDL2-2.32.6/lib/x64/SDL2.dll" "$RESOURCES_DIR/"
echo "GoldMapper build complete."
+5
View File
@@ -0,0 +1,5 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)