diff --git a/.github/workflows/publish_crate.yml b/.github/workflows/publish_crate.yml index b545095..818166f 100644 --- a/.github/workflows/publish_crate.yml +++ b/.github/workflows/publish_crate.yml @@ -20,7 +20,7 @@ jobs: - name: Upload crate if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - run: cd rust && cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} - name: Build Rust bindings - run: cd rust && cargo build --release + run: cargo build --release diff --git a/.gitignore b/.gitignore index e433d8d..eb3b402 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,18 @@ cython_debug/ .vscode/ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + + +# Added by cargo + +/target diff --git a/rust/Cargo.toml b/Cargo.toml similarity index 83% rename from rust/Cargo.toml rename to Cargo.toml index 66407de..34d6f9e 100644 --- a/rust/Cargo.toml +++ b/Cargo.toml @@ -8,15 +8,19 @@ version = "1.5.4" edition = "2021" authors = ["Anghelo Carvajal "] description = "MIPS instruction decoder" -readme = "../README.md" +readme = "README.md" homepage = "https://github.com/Decompollaborate/rabbitizer" repository = "https://github.com/Decompollaborate/rabbitizer" license = "MIT" keywords = ["MIPS", "decoder"] -build = "build.rs" +build = "rust/build.rs" +include = ["/rust/src", "/rust/build.rs", "/src", "/include"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +path = "rust/src/lib.rs" + [dependencies] cty = "0.2.2" libc = "0.2.138" diff --git a/rust/.gitignore b/rust/.gitignore deleted file mode 100644 index 22d3516..0000000 --- a/rust/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - - -# Added by cargo - -/target diff --git a/rust/build.rs b/rust/build.rs index 0f51449..6165516 100644 --- a/rust/build.rs +++ b/rust/build.rs @@ -1,13 +1,6 @@ fn main() { - let mut c_paths: Vec = glob::glob("../src/**/*.c").unwrap().filter_map(|g| g.ok()).collect(); - let mut h_paths: Vec = glob::glob("../include/**/*.h").unwrap().filter_map(|g| g.ok()).collect(); - - // Needed because `cargo publish` is dumb - let mut c_paths_2: Vec = glob::glob("../../../../src/**/*.c").unwrap().filter_map(|g| g.ok()).collect(); - let mut h_paths_2: Vec = glob::glob("../../../../include/**/*.h").unwrap().filter_map(|g| g.ok()).collect(); - - c_paths.append(&mut c_paths_2); - h_paths.append(&mut h_paths_2); + let c_paths: Vec = glob::glob("src/**/*.c").unwrap().filter_map(|g| g.ok()).collect(); + let h_paths: Vec = glob::glob("include/**/*.h").unwrap().filter_map(|g| g.ok()).collect(); for path in c_paths.iter().chain(&h_paths) { println!("cargo:rerun-if-changed={}", path.to_string_lossy()); @@ -17,8 +10,7 @@ fn main() { cc::Build::new() .files(c_paths) - .include("../include") - .include("../../../../include") + .include("include") .warnings(false) .compile("rabbitizer"); }