mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-07 03:15:49 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b30a602bf | |||
| 83a5ccdb8e | |||
| 44d8184d8b |
@@ -5,5 +5,5 @@ rustflags = [
|
||||
#"-C", "link-args=-O3 --closure 1",
|
||||
"-C", "link-args=-sASYNCIFY -sALLOW_MEMORY_GROWTH=1",
|
||||
"-C", "link-args=-sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS=['png']",
|
||||
"-C", "link-args=--preload-file assets/ -lidbfs.js",
|
||||
"-C", "link-args=--preload-file assets/",
|
||||
]
|
||||
|
||||
@@ -9,20 +9,50 @@ SDL_TTF_VERSION="2.20.2"
|
||||
SDL="https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/SDL2-devel-${SDL_VERSION}-mingw.tar.gz"
|
||||
SLD_IMAGE="https://github.com/libsdl-org/SDL_image/releases/download/release-${SDL_IMAGE_VERSION}/SDL2_image-devel-${SDL_IMAGE_VERSION}-mingw.tar.gz"
|
||||
SDL_MIXER="https://github.com/libsdl-org/SDL_mixer/releases/download/release-${SDL_MIXER_VERSION}/SDL2_mixer-devel-${SDL_MIXER_VERSION}-mingw.tar.gz"
|
||||
SDL_TTF="https://github.com/libsdl-org/SDL_ttf/releases/download/release-${SDL_TTF_VERSION}/SDL_ttf-devel-${SDL_TTF_VERSION}-mingw.tar.gz"
|
||||
SDL_TTF="https://github.com/libsdl-org/SDL_ttf/releases/download/release-${SDL_TTF_VERSION}/SDL2_ttf-devel-${SDL_TTF_VERSION}-mingw.tar.gz"
|
||||
|
||||
# Verify that toolchain is installed
|
||||
EXTRACT_DIR="./target/x86_64-pc-windows-gnu/release/deps"
|
||||
|
||||
if [ ! -f $EXTRACT_DIR/libSDL2.a ]; then
|
||||
if [ ! -f ./sdl2.tar.gz ]; then
|
||||
echo "Downloading SDL2@$SDL_VERSION..."
|
||||
curl -L -o ./sdl2.tar.gz $SDL
|
||||
fi
|
||||
echo "Extracting SDL2..."
|
||||
tar -xzf ./sdl2.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2-$SDL_VERSION/x86_64-w64-mingw32/lib/libSDL2.a"
|
||||
rm -f ./sdl2.tar.gz
|
||||
fi
|
||||
|
||||
# EXTRACT_DIR="~/.rustup/"
|
||||
EXTRACT_DIR="~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/"
|
||||
# if [ ! -d "~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/" ]; then
|
||||
# ls $EXTRACT_DIR
|
||||
# echo "Toolchain not installed. Run rustup target add x86_64-pc-windows-gnu. This may not work on environments besides Linux GNU."
|
||||
# exit 1
|
||||
# fi
|
||||
if [ ! -f $EXTRACT_DIR/libSDL2_image.a ]; then
|
||||
if [ ! -f ./sdl2_image.tar.gz ]; then
|
||||
echo "Downloading SDL2_image@$SDL_IMAGE_VERSION..."
|
||||
curl -L -o ./sdl2_image.tar.gz $SLD_IMAGE
|
||||
fi
|
||||
echo "Extracting SDL2_image..."
|
||||
tar -xzf ./sdl2_image.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_image-$SDL_IMAGE_VERSION/x86_64-w64-mingw32/lib/libSDL2_image.a"
|
||||
fi
|
||||
rm -f ./sdl2_image.tar.gz
|
||||
|
||||
echo "Downloading..."
|
||||
curl -L -o ./sdl2.tar.gz $SDL
|
||||
curl -L -o ./sdl2_image.tar.gz $SLD_IMAGE
|
||||
echo "Done."
|
||||
if [ ! -f $EXTRACT_DIR/libSDL2_mixer.a ]; then
|
||||
if [ ! -f ./sdl2_mixer.tar.gz ]; then
|
||||
echo "Downloading SDL2_mixer@$SDL_MIXER_VERSION..."
|
||||
curl -L -o ./sdl2_mixer.tar.gz $SDL_MIXER
|
||||
fi
|
||||
echo "Extracting SDL2_mixer..."
|
||||
tar -xzf ./sdl2_mixer.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_mixer-$SDL_MIXER_VERSION/x86_64-w64-mingw32/lib/libSDL2_mixer.a"
|
||||
rm -f ./sdl2_mixer.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -f $EXTRACT_DIR/libSDL2_ttf.a ]; then
|
||||
|
||||
if [ ! -f ./sdl2_ttf.tar.gz ]; then
|
||||
echo "Downloading SDL2_ttf@$SDL_TTF_VERSION..."
|
||||
curl -L -o ./sdl2_ttf.tar.gz $SDL_TTF
|
||||
fi
|
||||
echo "Extracting SDL2_ttf..."
|
||||
tar -xzf ./sdl2_ttf.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_ttf-$SDL_TTF_VERSION/x86_64-w64-mingw32/lib/libSDL2_ttf.a"
|
||||
rm -f ./sdl2_ttf.tar.gz
|
||||
fi
|
||||
|
||||
echo "Building..."
|
||||
cargo zigbuild --release --target x86_64-pc-windows-gnu
|
||||
9
scripts/clean-windows.sh
Executable file
9
scripts/clean-windows.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
echo "Cleaning library files from ./target/x86_64-pc-windows-gnu/release/deps"
|
||||
rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2.a
|
||||
rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_image.a
|
||||
rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_mixer.a
|
||||
rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_ttf.a
|
||||
echo "Done."
|
||||
@@ -1,49 +0,0 @@
|
||||
// taken from https://github.com/Gigoteur/PX8/blob/master/src/px8/emscripten.rs
|
||||
#[cfg(target_os = "emscripten")]
|
||||
pub mod emscripten {
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::os::raw::{c_char, c_float, c_int, c_void};
|
||||
use std::ptr::null_mut;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
type em_callback_func = unsafe extern "C" fn();
|
||||
|
||||
extern "C" {
|
||||
// void emscripten_set_main_loop(em_callback_func func, int fps, int simulate_infinite_loop)
|
||||
pub fn emscripten_set_main_loop(
|
||||
func: em_callback_func,
|
||||
fps: c_int,
|
||||
simulate_infinite_loop: c_int,
|
||||
);
|
||||
|
||||
pub fn emscripten_cancel_main_loop();
|
||||
pub fn emscripten_pause_main_loop();
|
||||
pub fn emscripten_get_now() -> c_float;
|
||||
}
|
||||
|
||||
thread_local!(static MAIN_LOOP_CALLBACK: RefCell<*mut c_void> = RefCell::new(null_mut()));
|
||||
|
||||
pub fn set_main_loop_callback<F>(callback: F)
|
||||
where
|
||||
F: FnMut(),
|
||||
{
|
||||
MAIN_LOOP_CALLBACK.with(|log| {
|
||||
*log.borrow_mut() = &callback as *const _ as *mut c_void;
|
||||
});
|
||||
|
||||
unsafe {
|
||||
emscripten_set_main_loop(wrapper::<F>, -1, 1);
|
||||
}
|
||||
|
||||
unsafe extern "C" fn wrapper<F>()
|
||||
where
|
||||
F: FnMut(),
|
||||
{
|
||||
MAIN_LOOP_CALLBACK.with(|z| {
|
||||
let closure = *z.borrow_mut() as *mut F;
|
||||
(*closure)();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user