Start porting to rust

This commit is contained in:
Greg Shuflin 2023-07-23 03:03:23 -07:00
parent cb4873e2ab
commit ec74203e70
6 changed files with 34 additions and 1 deletions

5
.gitignore vendored
View File

@ -1,3 +1,8 @@
bin/*
obj/*
.vs
# 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 = "nmsrust"
version = "0.1.0"

12
Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "nmsrust"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["staticlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -18,7 +18,7 @@ CFLAGS ?= -Wextra -Wall -O2
.PHONY: all install uninstall clean
nms: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^
$(CC) $(CFLAGS) -o $(BIN)/$@ $^ target/release/libnmsrust.a
sneakers: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN)
$(CC) $(CFLAGS) -o $(BIN)/$@ $^

6
src/lib.rs Normal file
View File

@ -0,0 +1,6 @@
#[no_mangle]
pub extern "C" fn rust_main() {
println!("Hello from rust");
}

View File

@ -15,8 +15,11 @@
#define VERSION "1.0.1"
extern void rust_main();
int main(int argc, char *argv[])
{
rust_main();
int r, o;
unsigned char *input;