From 354980864633227069ba896c214c1acb664ae6a5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 24 May 2024 11:30:25 -0400 Subject: [PATCH] rust: Move to a workspace The current Rust crate is `composefs-core` and is a relatively thin wrapper for what is currently in the composefs tooling. Prep for adding a new `composefs-oci`. Signed-off-by: Colin Walters --- Cargo.toml | 39 ++++++++------------ rust/composefs-core/Cargo.toml | 27 ++++++++++++++ rust/{ => composefs-core}/src/dumpfile.rs | 2 +- rust/{ => composefs-core}/src/lib.rs | 0 rust/{ => composefs-core}/src/mkcomposefs.rs | 2 +- 5 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 rust/composefs-core/Cargo.toml rename rust/{ => composefs-core}/src/dumpfile.rs (99%) rename rust/{ => composefs-core}/src/lib.rs (100%) rename rust/{ => composefs-core}/src/mkcomposefs.rs (97%) diff --git a/Cargo.toml b/Cargo.toml index e454f610..9d55f0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,18 @@ -[package] -name = "composefs" -version = "0.1.0" -edition = "2021" -description = "Rust composefs" -keywords = ["composefs", "oci", "opencontainers", "docker", "podman"] -license = "MIT" -repository = "https://github.com/containers/composefs" -rust-version = "1.70.0" +[workspace] +members = ["rust/composefs-core"] +resolver = "2" -include = [ - "/COPYING", - "/README.md", - "/rust/**", -] +[profile.dev] +opt-level = 1 # No optimizations are too slow for us. -[lib] -name = "composefs" -path = "rust/src/lib.rs" +[profile.release] +lto = "thin" +# No need to support unwinding +panic = "abort" +# We assume we're being delivered via e.g. RPM which supports split debuginfo +debug = true -[dependencies] -anyhow = "1.0" -libc = "0.2" - -[dev-dependencies] -tar = "0.4.38" -tempfile = "3.2.0" \ No newline at end of file +[profile.releaselto] +codegen-units = 1 +inherits = "release" +lto = "yes" \ No newline at end of file diff --git a/rust/composefs-core/Cargo.toml b/rust/composefs-core/Cargo.toml new file mode 100644 index 00000000..7784d53b --- /dev/null +++ b/rust/composefs-core/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "composefs" +version = "0.1.0" +edition = "2021" +description = "Rust composefs" +keywords = ["composefs", "oci", "opencontainers", "docker", "podman"] +license = "MIT" +repository = "https://github.com/containers/composefs" +rust-version = "1.70.0" + +include = [ + "/COPYING", + "/README.md", + "/rust/composefs-core/**", +] + +[lib] +name = "composefs" +path = "src/lib.rs" + +[dependencies] +anyhow = "1.0" +libc = "0.2" + +[dev-dependencies] +tar = "0.4.38" +tempfile = "3.2.0" \ No newline at end of file diff --git a/rust/src/dumpfile.rs b/rust/composefs-core/src/dumpfile.rs similarity index 99% rename from rust/src/dumpfile.rs rename to rust/composefs-core/src/dumpfile.rs index 6e02a12e..6d71dbb2 100644 --- a/rust/src/dumpfile.rs +++ b/rust/composefs-core/src/dumpfile.rs @@ -433,7 +433,7 @@ mod tests { #[test] fn test_parse() { - const CONTENT: &str = include_str!("../../tests/assets/special.dump"); + const CONTENT: &str = include_str!("../../../tests/assets/special.dump"); for line in CONTENT.lines() { // Test a full round trip by parsing, serialize, parsing again let e = Entry::parse(line).unwrap(); diff --git a/rust/src/lib.rs b/rust/composefs-core/src/lib.rs similarity index 100% rename from rust/src/lib.rs rename to rust/composefs-core/src/lib.rs diff --git a/rust/src/mkcomposefs.rs b/rust/composefs-core/src/mkcomposefs.rs similarity index 97% rename from rust/src/mkcomposefs.rs rename to rust/composefs-core/src/mkcomposefs.rs index 9a42abdb..12c39e07 100644 --- a/rust/src/mkcomposefs.rs +++ b/rust/composefs-core/src/mkcomposefs.rs @@ -84,7 +84,7 @@ fn test_mkcomposefs() -> Result<()> { let outpath = &td.join("out"); let o = File::create(outpath)?; let (send, recv) = mpsc::sync_channel(5); - const CONTENT: &str = include_str!("../../tests/assets/special.dump"); + const CONTENT: &str = include_str!("../../../tests/assets/special.dump"); std::thread::scope(|s| { let producer = s.spawn(move || { for line in CONTENT.lines() {