updates
This commit is contained in:
71
flake.nix
71
flake.nix
@@ -46,7 +46,7 @@
|
||||
|
||||
shellEnv = {
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${mingwCC}/bin/x86_64-w64-mingw32-gcc";
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS = "-L ${mingwPkgs.windows.pthreads}/lib";
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS = "-L ${mingwPkgs.windows.pthreads}/lib -C link-args=-static-libgcc -C link-args=-static-libstdc++";
|
||||
CC_x86_64_pc_windows_gnu = "${mingwCC}/bin/x86_64-w64-mingw32-gcc";
|
||||
CXX_x86_64_pc_windows_gnu = "${mingwCC}/bin/x86_64-w64-mingw32-g++";
|
||||
AR_x86_64_pc_windows_gnu = "${mingwCC}/bin/x86_64-w64-mingw32-ar";
|
||||
@@ -97,6 +97,68 @@
|
||||
cargo check --target x86_64-pc-windows-gnu
|
||||
'';
|
||||
|
||||
startScript = pkgs.writeShellScriptBin "start" ''
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(pwd)"
|
||||
SCRIPTS_PATH="$SCRIPT_DIR/scripts"
|
||||
|
||||
export WINEPREFIX="$SCRIPT_DIR/.wine"
|
||||
export WINEARCH=win64
|
||||
export DISPLAY=:0
|
||||
export WINEDLLOVERRIDES="mscoree,mshtml="
|
||||
export WINEDEBUG=-all
|
||||
# Add MinGW DLLs to Wine's search path
|
||||
export WINEDLLPATH="${mingwPkgs.windows.pthreads}/bin:${mingwCC.cc}/x86_64-w64-mingw32/lib"
|
||||
|
||||
# Cleanup function to ensure processes are killed on exit
|
||||
cleanup() {
|
||||
echo ""
|
||||
echo "Cleaning up processes..."
|
||||
if [ -n "$XVFB_PID" ] && kill -0 $XVFB_PID 2>/dev/null; then
|
||||
echo "Stopping Xvfb..."
|
||||
kill $XVFB_PID 2>/dev/null || true
|
||||
fi
|
||||
if [ -n "$BOT_PID" ] && kill -0 $BOT_PID 2>/dev/null; then
|
||||
echo "Stopping protossbot..."
|
||||
kill $BOT_PID 2>/dev/null || true
|
||||
fi
|
||||
killall StarCraft.exe 2>/dev/null || true
|
||||
echo "Cleanup complete."
|
||||
}
|
||||
|
||||
# Register cleanup function to run on script exit (success or failure)
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ ! -d "$WINEPREFIX" ]; then
|
||||
wine wineboot --init
|
||||
fi
|
||||
|
||||
echo "Starting Xvfb virtual display..."
|
||||
Xvfb :0 -auth ~/.Xauthority -screen 0 640x480x24 > /dev/null 2>&1 &
|
||||
XVFB_PID=$!
|
||||
|
||||
cd scripts
|
||||
./4-configure-bwapi.sh
|
||||
cd ..
|
||||
|
||||
echo "Building protossbot..."
|
||||
build-protossbot-debug
|
||||
echo "Starting protossbot..."
|
||||
cd "$SCRIPT_DIR/protossbot"
|
||||
|
||||
RUST_BACKTRACE=1 RUST_BACKTRACE=full wine target/x86_64-pc-windows-gnu/debug/protossbot.exe &
|
||||
BOT_PID=$!
|
||||
echo "protossbot started (PID: $BOT_PID)"
|
||||
|
||||
|
||||
echo "Launching StarCraft with BWAPI via Chaoslauncher..."
|
||||
cd "$SCRIPT_DIR/starcraft/BWAPI/Chaoslauncher"
|
||||
wine Chaoslauncher.exe
|
||||
|
||||
echo "StarCraft closed."
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell (shellEnv // {
|
||||
@@ -105,6 +167,7 @@
|
||||
buildDebugScript
|
||||
cleanScript
|
||||
checkScript
|
||||
startScript
|
||||
|
||||
# Additional development tools
|
||||
pkgs.cargo-watch
|
||||
@@ -128,6 +191,7 @@
|
||||
echo " build-protossbot-debug - Build debug version for Windows"
|
||||
echo " check-protossbot - Quick check without building"
|
||||
echo " clean-protossbot - Clean build artifacts"
|
||||
echo " start - Run the bot with StarCraft"
|
||||
'';
|
||||
});
|
||||
|
||||
@@ -180,6 +244,11 @@
|
||||
program = "${checkScript}/bin/check-protossbot";
|
||||
};
|
||||
|
||||
start = {
|
||||
type = "app";
|
||||
program = "${startScript}/bin/start";
|
||||
};
|
||||
|
||||
default = self.apps.${system}.build;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user