Skip to content

Commit

Permalink
Fix linking static inline functions and update xdp-tools to v1.4.0
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanial Lattimer <[email protected]>
  • Loading branch information
d0nutptr authored and chenhengqi committed Oct 20, 2023
1 parent f185b4b commit 0969af5
Show file tree
Hide file tree
Showing 5 changed files with 786 additions and 1,365 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
.idea/
target/
Cargo.lock
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "libxdp-sys"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "Rust bindings for libxdp"
repository = "https://github.com/chenhengqi/libxdp-sys"
homepage = "https://github.com/chenhengqi/libxdp-sys"
keywords = ["libxdp", "xdp"]
authors = ["Hengqi Chen <[email protected]>"]
authors = ["Hengqi Chen <[email protected]>", "Nathanial Lattimer <[email protected]>"]
license = "LGPL-2.1 OR BSD-2-Clause"
build = "build.rs"
links = "libxdp"

[build-dependencies]
bindgen = "0.64.0"
bindgen = "0.68.1"
10 changes: 9 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ fn main() {
let libxdp_dir = xdptools_dir.join("lib/libxdp");
let headers_dir = xdptools_dir.join("headers/xdp");

let libbpf_dir = xdptools_dir.join("lib/libbpf/src");
let bpf_headers_dir = libbpf_dir.join("root/usr/include");

let status = process::Command::new("make")
.arg("libxdp")
.current_dir(&xdptools_dir)
Expand All @@ -16,12 +19,17 @@ fn main() {

assert!(status.success(), "make failed");

println!("cargo:include={}", headers_dir.display());
println!("cargo:rustc-link-search={}", libbpf_dir.display());
println!("cargo:rustc-link-search={}", libxdp_dir.display());
println!("cargo:rustc-link-lib=static=bpf");
println!("cargo:rustc-link-lib=static=xdp");
println!("cargo:rustc-link-lib=elf");
println!("cargo:rustc-link-lib=z");

bindgen::Builder::default()
.header("bindings.h")
.generate_inline_functions(true)
.clang_arg(format!("-I{}", bpf_headers_dir.display()))
.clang_arg(format!("-I{}", headers_dir.display()))
.generate()
.expect("Unable to generate bindings")
Expand Down
Loading

0 comments on commit 0969af5

Please sign in to comment.