Fix C files not being packaged on Rust crates

This commit is contained in:
Angie 2022-12-18 19:43:40 -03:00
parent 59f143b21d
commit 6102f2cf7d
5 changed files with 26 additions and 30 deletions

View File

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

15
.gitignore vendored
View File

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

View File

@ -8,15 +8,19 @@ version = "1.5.4"
edition = "2021"
authors = ["Anghelo Carvajal <angheloalf95@gmail.com>"]
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"

15
rust/.gitignore vendored
View File

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

View File

@ -1,13 +1,6 @@
fn main() {
let mut c_paths: Vec<std::path::PathBuf> = glob::glob("../src/**/*.c").unwrap().filter_map(|g| g.ok()).collect();
let mut h_paths: Vec<std::path::PathBuf> = glob::glob("../include/**/*.h").unwrap().filter_map(|g| g.ok()).collect();
// Needed because `cargo publish` is dumb
let mut c_paths_2: Vec<std::path::PathBuf> = glob::glob("../../../../src/**/*.c").unwrap().filter_map(|g| g.ok()).collect();
let mut h_paths_2: Vec<std::path::PathBuf> = 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<std::path::PathBuf> = glob::glob("src/**/*.c").unwrap().filter_map(|g| g.ok()).collect();
let h_paths: Vec<std::path::PathBuf> = 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");
}