Fix native build

This commit is contained in:
Stephen Seo 2023-02-22 14:21:50 +09:00
parent 9f602ba465
commit f7a635ba7f
6 changed files with 27 additions and 53 deletions

8
Cargo.lock generated
View file

@ -247,18 +247,18 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.137" version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.137" version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -14,15 +14,11 @@ serde = { version = "1.0.101", features = ["derive"] }
[build-dependencies] [build-dependencies]
bindgen = "0.64" bindgen = "0.64"
[features]
default = []
no_link_libs = []
[lib] [lib]
name = "ld45_lib" name = "ld45_lib"
crate-type = ["staticlib"] path = "src/lib.rs"
required-features = ["no_link_libs"] crate-type = ["rlib", "staticlib"]
[[bin]] [[bin]]
name = "ld45_bin" name = "ld45_bin"
path = "src/main.rs" path = "src/bin.rs"

View file

@ -3,17 +3,9 @@ extern crate bindgen;
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
#[cfg(not(feature = "no_link_libs"))] fn main() {
fn linking_libs() {
println!("cargo:rustc-link-lib=raylib"); println!("cargo:rustc-link-lib=raylib");
println!("cargo:rustc-link-lib=OpenGL"); println!("cargo:rustc-link-lib=OpenGL");
}
#[cfg(feature = "no_link_libs")]
fn linking_libs() {}
fn main() {
linking_libs();
println!("cargo:rerun-if-changed=raylib/raylib.h"); println!("cargo:rerun-if-changed=raylib/raylib.h");
let bindings = bindgen::Builder::default() let bindings = bindgen::Builder::default()

17
src/bin.rs Normal file
View file

@ -0,0 +1,17 @@
use ld45_lib::agnostic_interface;
fn will_close() -> bool {
unsafe { agnostic_interface::raylib_impl::ffi::WindowShouldClose() }
}
fn main() {
let state_ptr = ld45_lib::ld45_initialize();
while !will_close() {
ld45_lib::ld45_iterate(state_ptr);
}
unsafe {
drop(Box::from_raw(state_ptr as *mut ld45_lib::WasmState));
}
}

View file

@ -1,4 +1,4 @@
mod agnostic_interface; pub mod agnostic_interface;
mod faux_quicksilver; mod faux_quicksilver;
mod original_impl; mod original_impl;
mod shaders; mod shaders;
@ -7,7 +7,7 @@ use agnostic_interface::raylib_impl::RaylibGame;
use faux_quicksilver::Window; use faux_quicksilver::Window;
use original_impl::GameState; use original_impl::GameState;
struct WasmState { pub struct WasmState {
pub window: Window, pub window: Window,
pub game_state: GameState, pub game_state: GameState,
} }

View file

@ -1,31 +0,0 @@
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;
fn will_close() -> bool {
unsafe { agnostic_interface::raylib_impl::ffi::WindowShouldClose() }
}
fn main() {
// TODO
//run::<GameState>(
// "One And All - a Ludum Dare 45 compo entry",
// Vector::new(800, 600),
// Settings::default(),
//);
let game_interface = RaylibGame::new_boxed(800, 600);
let mut window = Window::new(game_interface);
let mut game_state = GameState::new(&mut window).unwrap();
while !will_close() {
window.update_music().unwrap();
game_state.update(&mut window).unwrap();
game_state.draw(&mut window).unwrap();
}
}