Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #65

Closed
wants to merge 16 commits into from
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
DPDK_VERSION: 22.11.4

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt update && sudo apt install -y linux-headers-generic build-essential libnuma-dev git meson python3-pyelftools curl libclang-dev clang llvm-dev
- name: Install DPDK
run: |
wget -O dpdk.tar.xz https://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz
mkdir dpdk-src
tar -xvJf dpdk.tar.xz -C dpdk-src --strip-components=1
cd dpdk-src
meson setup '-Ddisable_drivers=event/*,net/a*,net/b*,net/c*,net/d*,net/f*,net/g*,net/h*,net/m*,net/n*,net/o*,net/p*,net/q*,net/r*,net/s*,net/t*,net/v*,b*,com*,cry*,d*,e*,g*,ml*,raw*,reg*,v*,common' build
ninja -C build
sudo ninja -C build install
sudo ldconfig
rm -rf dpdk-src
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
18 changes: 16 additions & 2 deletions dpdk-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl State {
) -> clang::TranslationUnit<'a> {
let mut argument = vec![
"-march=native".into(),
"-std=c99".into(),
format!(
"-I{}",
self.include_path.as_ref().unwrap().to_str().unwrap()
Expand Down Expand Up @@ -406,8 +407,10 @@ impl State {
let target_path = self.out_path.join("dpdk.h");
{
let clang = clang::Clang::new().unwrap();
let index = clang::Index::new(&clang, true, true);
let trans_unit = self.trans_unit_from_header(&index, target_path, false);
let index = clang::Index::new(&clang, false, true);
println!("cargo:warning=2.1");
let trans_unit = self.trans_unit_from_header(&index, target_path, true);
println!("cargo:warning=2.2");

// Iterate through each EAL header files and extract function definitions.
'each_function: for f in trans_unit
Expand Down Expand Up @@ -839,6 +842,7 @@ impl State {
let target_path = self.out_path.join("dpdk.rs");
bindgen::builder()
.header(header_path.to_str().unwrap())
.clang_arg("-std=c99")
.clang_arg(format!("-I{}", dpdk_include_path.to_str().unwrap()))
.clang_arg(format!("-I{}", self.out_path.to_str().unwrap()))
.clang_arg("-imacros")
Expand Down Expand Up @@ -1054,13 +1058,23 @@ impl State {
fn main() {
let mut state = State::new();
state.check_os();

println!("cargo:warning=1");
state.check_compiler();
state.find_dpdk();
state.find_link_libs();

println!("cargo:warning={:?}", state.system_include_path);
state.make_all_in_one_header();

println!("cargo:warning=2");
state.extract_eal_apis();
println!("cargo:warning=3");
state.generate_static_impls_and_link_pmds();
println!("cargo:warning=4");
state.generate_rust_def();
println!("cargo:warning=5");
state.generate_lib_rs();
println!("cargo:warning={:?}", state.system_include_path);
state.compile();
}
Loading