feat: custom target directory support

pull/110/head
Sandeep Nambiar 6 months ago
parent a006355e62
commit b55766232b

@ -32,7 +32,8 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
// profile we are building (release or debug)
let profile = if opts.release { "release" } else { "debug" };
let bin_path = format!("target/{profile}/{{project-name}}");
let target_dir = std::env!("CARGO_TARGET_DIR");
let bin_path = format!("{target_dir}/{profile}/{{project-name}}");
// arguments to pass to the application
let mut run_args: Vec<_> = opts.run_args.iter().map(String::as_str).collect();

@ -86,13 +86,15 @@ async fn main() -> Result<(), anyhow::Error> {
// like to specify the eBPF program at runtime rather than at compile-time, you can
// reach for `Bpf::load_file` instead.
#[cfg(debug_assertions)]
let mut bpf = Bpf::load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/debug/{{project-name}}"
))?;
let mut bpf = Bpf::load(include_bytes_aligned!(concat!(
std::env!("CARGO_TARGET_DIR"),
"/bpfel-unknown-none/debug/{{project-name}}"
)))?;
#[cfg(not(debug_assertions))]
let mut bpf = Bpf::load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/release/{{project-name}}"
))?;
let mut bpf = Bpf::load(include_bytes_aligned!(concat!(
std::env!("CARGO_TARGET_DIR"),
"/bpfel-unknown-none/release/{{project-name}}"
)))?;
if let Err(e) = BpfLogger::init(&mut bpf) {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger: {}", e);

Loading…
Cancel
Save