Skip to content

Commit

Permalink
scx_rustland_core: separate crate source code from assets
Browse files Browse the repository at this point in the history
scx_rustland_core needs to ship both a binary part and a source code
part, which will be used to build schedulers based on it.

To effectively publish the scx_rustland_core crate on crates.io we need
to properly separate the source code assets from the crate's main source
code.

To achieve this, move the assets into a separate directory and declare
them inside a [lib] section in Cargo.toml.

This allows to publish the crate on crates.io, providing also a clear
separation between source code and assets.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Apr 4, 2024
1 parent 163e96d commit 85a32a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions rust/scx_rustland_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ license = "GPL-2.0-only"
repository = "https://github.com/sched-ext/scx"
description = "Framework to implement sched_ext schedulers running in user space"

include = [
"src/bpf/intf.h",
"src/bpf/main.bpf.c",
"src/bpf.rs",
]

[dependencies]
anyhow = "1.0"
libbpf-rs = "0.23"
Expand All @@ -24,3 +18,13 @@ scx_utils = { path = "../scx_utils", version = "0.7" }
tar = "0.4"
walkdir = "2.4"
scx_utils = { path = "../scx_utils", version = "0.7" }

[lib]
name = "scx_rustland_core"
path = "src/lib.rs"

include = [
"assets/bpf/intf.h",
"assets/bpf/main.bpf.c",
"assets/bpf.rs",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions rust/scx_rustland_core/src/rustland_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ impl RustLandBuilder {

pub fn build(&mut self) -> Result<()> {
// Embed the BPF source files.
let intf = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bpf/intf.h"));
let skel = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bpf/main.bpf.c"));
let bpf = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bpf.rs"));
let intf = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/bpf/intf.h"));
let skel = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/bpf/main.bpf.c"));
let bpf = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/bpf.rs"));

// Generate BPF backend code (C).
self.create_file("intf.h", intf);
Expand Down

0 comments on commit 85a32a7

Please sign in to comment.