Use cargo as a build system instead of makefiles

This commit is contained in:
Thibaud Gasser 2024-02-18 12:36:07 +01:00
parent e3c86e0e37
commit c05f984698
9 changed files with 39 additions and 10 deletions

5
.gitignore vendored
View File

@ -1 +1,6 @@
bin/
# Added by cargo
/target

7
Cargo.lock generated Normal file
View File

@ -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"

13
Cargo.toml Normal file
View File

@ -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"

View File

@ -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/$@

View File

@ -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
```

8
build.rs Normal file
View File

@ -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");
}