diff --git a/.gitignore b/.gitignore index e660fd9..de9d97c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ bin/ + + +# Added by cargo + +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..285d523 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "test-raylib-rust" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b96f96d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "test-raylib-rust" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[[bin]] +name = "rect" +path = "src/rect.rs" + +[[bin]] +name = "bounce" +path = "src/bounce.rs" diff --git a/Makefile b/Makefile deleted file mode 100644 index a847980..0000000 --- a/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -.PHONY: all - -all: rect bounce - -rect: rect.rs - rustc -L./raylib/ -lraylib $< -o bin/$@ - -bounce: bounce.rs - rustc -L./raylib/ -lraylib $< -o bin/$@ - diff --git a/README.md b/README.md index 1782f2c..78686f4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # Rust and raylib playground A sample project to play with rust, raylib, and rust/c interoperability + +## How to run + +```shell +$ cargo run --bin rect +``` diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..ce741d9 --- /dev/null +++ b/build.rs @@ -0,0 +1,8 @@ +fn main() { + // https://doc.rust-lang.org/cargo/reference/build-scripts.html + // cargo-equivalent to running rustc -L./raylib/ -lraylib test.rs -o bin/test + // to link against the libraylib.a static library + println!("cargo:rustc-link-search=./raylib"); + println!("cargo:rustc-link-lib=static=raylib"); +} + diff --git a/bounce.rs b/src/bounce.rs similarity index 100% rename from bounce.rs rename to src/bounce.rs diff --git a/raylib.rs b/src/raylib.rs similarity index 100% rename from raylib.rs rename to src/raylib.rs diff --git a/rect.rs b/src/rect.rs similarity index 100% rename from rect.rs rename to src/rect.rs