From 9603ac1ccc510b91e6b4295aee86989e20c1d159 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 5 Aug 2016 11:21:57 +0200 Subject: [PATCH] Create a cargo workspace for subcrates (#202) --- Cargo.toml | 2 ++ blog/post/2016-04-11-kernel-heap.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 35dcf09c..e658a294 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,8 @@ features = ["spin_no_std"] [lib] crate-type = ["staticlib"] +[workspace] + [profile.dev] panic = "abort" diff --git a/blog/post/2016-04-11-kernel-heap.md b/blog/post/2016-04-11-kernel-heap.md index 53157cb8..1229d357 100644 --- a/blog/post/2016-04-11-kernel-heap.md +++ b/blog/post/2016-04-11-kernel-heap.md @@ -45,6 +45,20 @@ For our own allocator, we start simple. We create an allocator crate in a new `l > cd bump_allocator ``` +Normally, this subcrate would have its own `Cargo.lock` and its own `target` output folder. To avoid this, we can create a so-called _[workspace]_. For that we only need to add a single line to our `Cargo.toml`: + +[workspace]: http://doc.crates.io/manifest.html#the-workspace-section + +```toml +# in Cargo.toml + +[workspace] +``` +We don't need to add any keys to the `workspace` section, since they have [sensible defaults]. Now our `bump_allocator` subcrate shares the `Cargo.toml` and `target` folder of the root project. + +[sensible defaults]: https://github.com/rust-lang/rfcs/blob/master/text/1525-cargo-workspace.md#implicit-relations + +### Implementation Our allocator is very basic. It only keeps track of the next free address: ``` rust