Fix wasm build (normal build is broken)
This commit is contained in:
parent
09159a1f53
commit
9f602ba465
5 changed files with 35 additions and 14 deletions
28
src/lib.rs
28
src/lib.rs
|
@ -1,17 +1,27 @@
|
|||
use agnostic_interface::raylib_impl::RaylibGame;
|
||||
use faux_quicksilver::Window;
|
||||
use original_impl::GameState;
|
||||
|
||||
mod agnostic_interface;
|
||||
mod faux_quicksilver;
|
||||
mod original_impl;
|
||||
mod shaders;
|
||||
|
||||
use agnostic_interface::raylib_impl::RaylibGame;
|
||||
use faux_quicksilver::Window;
|
||||
use original_impl::GameState;
|
||||
|
||||
struct WasmState {
|
||||
pub window: Window,
|
||||
pub game_state: GameState,
|
||||
}
|
||||
|
||||
impl WasmState {
|
||||
pub fn get_window_mut(&mut self) -> &mut Window {
|
||||
&mut self.window
|
||||
}
|
||||
|
||||
pub fn get_state_mut(&mut self) -> &mut GameState {
|
||||
&mut self.game_state
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ld45_initialize() -> *mut ::std::os::raw::c_void {
|
||||
let game_interface = RaylibGame::new_boxed(800, 600);
|
||||
|
@ -25,14 +35,14 @@ pub extern "C" fn ld45_initialize() -> *mut ::std::os::raw::c_void {
|
|||
pub extern "C" fn ld45_iterate(context: *mut ::std::os::raw::c_void) {
|
||||
let state_ptr = context as *mut WasmState;
|
||||
unsafe {
|
||||
(*state_ptr).window.update_music().unwrap();
|
||||
(*state_ptr).get_window_mut().update_music().unwrap();
|
||||
(*state_ptr)
|
||||
.game_state
|
||||
.update(&mut (*state_ptr).window)
|
||||
.get_state_mut()
|
||||
.update(&mut (*state_ptr).get_window_mut())
|
||||
.unwrap();
|
||||
(*state_ptr)
|
||||
.game_state
|
||||
.draw(&mut (*state_ptr).window)
|
||||
.get_state_mut()
|
||||
.draw(&mut (*state_ptr).get_window_mut())
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,22 @@ all: ld45.html
|
|||
ld45.html: src/main.c ../target/wasm32-unknown-emscripten/release/libld45_lib.a
|
||||
${CC} -o ld45.html -s USE_GLFW=3 -Iinclude \
|
||||
-Llib -lraylib \
|
||||
-L../target/wasm32-unknown-emscripten/debug -lld45_lib \
|
||||
-sSAFE_HEAP=1 \
|
||||
-L../target/wasm32-unknown-emscripten/release -lld45_lib \
|
||||
-sTOTAL_MEMORY=1024MB \
|
||||
-sALLOW_MEMORY_GROWTH=1 \
|
||||
-O2 \
|
||||
-sEXPORTED_FUNCTIONS="['_malloc', '_main']" \
|
||||
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap \
|
||||
-fsanitize=address \
|
||||
-sWARN_UNALIGNED=1 \
|
||||
--preload-file ../static src/main.c
|
||||
ln -sf ld45.html index.html
|
||||
|
||||
../target/wasm32-unknown-emscripten/debug/libld45_lib.a: ../src/lib.rs
|
||||
cd ..; source "${HOME}/git/emsdk/emsdk_env.sh"; cargo build --lib --target wasm32-unknown-emscripten
|
||||
#-fsanitize=address \
|
||||
#-sWARN_UNALIGNED=1 \
|
||||
|
||||
../target/wasm32-unknown-emscripten/release/libld45_lib.a: ../src/lib.rs
|
||||
cd ..; source "${HOME}/git/emsdk/emsdk_env.sh"; cargo build --lib --release --target wasm32-unknown-emscripten
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
|
@ -22,3 +30,4 @@ clean:
|
|||
rm -f ld45.wasm
|
||||
rm -f ld45.data
|
||||
rm -f index.html
|
||||
cd ..; cargo clean
|
||||
|
|
|
@ -1 +1 @@
|
|||
../raylib/raylib.h
|
||||
../../raylib/raylib.h
|
Binary file not shown.
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <ld45_lib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void main_loop(void *ud) {
|
||||
ld45_iterate(ud);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue