commit
9e1c761d8d
@ -0,0 +1,13 @@
|
|||||||
|
### https://raw.github.com/github/gitignore/master/Rust.gitignore
|
||||||
|
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
debug/
|
||||||
|
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
|
@ -0,0 +1,2 @@
|
|||||||
|
[workspace]
|
||||||
|
members = ["{{project-name}}", "{{project-name}}-common"]
|
@ -0,0 +1,27 @@
|
|||||||
|
# {{project-name}}
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
1. Install a rust stable toolchain: `rustup install stable`
|
||||||
|
1. Install a rust nightly toolchain: `rustup install nightly`
|
||||||
|
1. Install bpf-linker: `cargo install bpf-linker`
|
||||||
|
|
||||||
|
## Build eBPF
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pushd {{project-name}}-ebpf
|
||||||
|
cargo +nightly build
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build Userspace
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --package {{project-name}} -bin {{project-name}}
|
||||||
|
```
|
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "{{project-name}}-common"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
userspace = [ "aya" ]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aya = { git = "https://github.com/alessandrod/aya", branch="main", optional=true }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
@ -0,0 +1 @@
|
|||||||
|
#![no_std]
|
@ -0,0 +1,9 @@
|
|||||||
|
[build]
|
||||||
|
target-dir = "../target"
|
||||||
|
target = "bpfel-unknown-none"
|
||||||
|
|
||||||
|
[target.bpfel-unknown-none]
|
||||||
|
rustflags = "-Z build-std=core --target bpfel-unknown-none"
|
||||||
|
|
||||||
|
[target.bpfeb-unknown-none]
|
||||||
|
rustflags = "-Z build-std=core --target bpfel-unknown-none"
|
@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "{{project-name}}-ebpf"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aya-bpf = { git = "http://github.com/alessandrod/aya", branch = "main" }
|
||||||
|
{{project-name}}-common = { path = "../{{project-name}}-common" }
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "{{project-name}}"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
panic = "abort"
|
||||||
|
overflow-checks = false
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = []
|
@ -0,0 +1,7 @@
|
|||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
#[panic_handler]
|
||||||
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
|
unreachable!()
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "{{project-name}}"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aya = { git = "https://github.com/alessandrod/aya", branch="main", optional=true }
|
||||||
|
{{project-name}}-common = { path = "../{{project-name}}-common", features=["userspace"] }
|
||||||
|
anyhow = "1.0.42"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "{{project-name}}"
|
||||||
|
path = "src/main.rs"
|
@ -0,0 +1,9 @@
|
|||||||
|
fn main() {
|
||||||
|
if let Err(e) = try_main() {
|
||||||
|
eprintln!("error: {:#}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_main() -> Result<(), anyhow::Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in New Issue