Skip to content

Commit cd561b7

Browse files
committed
fix using pkg-config
1 parent 71e39d7 commit cd561b7

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

dpdk-sys/build.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ struct State {
6868
/// DPDK config file (will be included as a predefined macro file).
6969
dpdk_config: Option<PathBuf>,
7070

71+
// DPDK pkg-config result
72+
dpdk: Option<pkg_config::Library>,
73+
7174
/// Use definitions for automatically found EAL APIs.
7275
eal_function_use_defs: Vec<String>,
7376

@@ -96,6 +99,7 @@ impl State {
9699
dpdk_headers: Default::default(),
97100
dpdk_links: Default::default(),
98101
dpdk_config: Default::default(),
102+
dpdk: Default::default(),
99103
eal_function_use_defs: Default::default(),
100104
global_eal_function_use_defs: Default::default(),
101105
static_functions: Default::default(),
@@ -217,6 +221,7 @@ impl State {
217221
println!("cargo:rerun-if-env-changed=RTE_TARGET");
218222

219223
self.dpdk_config = Some(config_header);
224+
self.dpdk = Some(lib);
220225
}
221226

222227
/// Search through DPDK's link dir and extract library names.
@@ -480,24 +485,32 @@ impl State {
480485
if target_bin_path.exists() {
481486
fs::remove_file(target_bin_path.clone()).unwrap();
482487
}
483-
let ret = Command::new(cc_name.clone())
488+
let dpdk = self.dpdk.as_ref().unwrap();
489+
let includes = dpdk.include_paths.iter().map(|x| format!("-I{}", x.to_str().unwrap()));
490+
let libs = dpdk.libs.iter().map(|x| format!("-l{}", x));
491+
let ret: std::result::Result<std::process::Output, Error> = Command::new(cc_name.clone())
484492
.arg("-Wall")
485493
.arg("-Wextra")
486-
.arg("-std=c99")
487-
.arg(format!("-I{}", dpdk_include))
494+
.arg("-std=gnu11")
495+
.args(includes)
488496
.arg(format!("-I{}", output_include))
489-
.arg("-imacros")
497+
.arg("-include")
490498
.arg(dpdk_config_path)
491499
.arg("-march=native")
492500
.arg(format!("-D__CHECK_FN={}", name))
493501
.arg("-o")
494502
.arg(target_bin_path.clone())
503+
.args(libs)
495504
.arg(test_template.clone())
496505
.output();
497506
if let Ok(ret) = ret {
498507
if ret.status.success() {
499508
success = true;
500-
println!("cargo:warning={} compile success {}", name, success);
509+
// println!("cargo:warning={} compile success {}", name, success);
510+
}else{
511+
512+
println!("cargo:warning={:?} compile failed",ret);
513+
panic!("@@@");
501514
}
502515
}
503516
is_always_inline_fn.insert(name.clone(), success);
@@ -740,7 +753,7 @@ impl State {
740753
.arg("-Wall")
741754
.arg("-Wextra")
742755
.arg("-Werror")
743-
.arg("-std=c99")
756+
.arg("-std=gnu11")
744757
.arg(format!("-I{}", dpdk_include))
745758
.arg(format!("-I{}", output_include))
746759
.arg("-imacros")
@@ -861,7 +874,7 @@ impl State {
861874
total_string += "\n}\n";
862875
self.static_constants = total_string;
863876
}
864-
// gcc -S test.c -Wall -Wextra -std=c99 -Werror
877+
// gcc -S test.c -Wall -Wextra -std=gnu11 -Werror
865878

866879
let header_path: PathBuf = self.out_path.join("static.h");
867880
let header_template = self.project_path.join("gen/static.h.template");

dpdk-sys/gen/static.c.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static const struct rte_mempool_ops ops_sp_mc = {
138138
.get_count = common_ring_get_count,
139139
};
140140

141-
MEMPOOL_REGISTER_OPS(ops_mp_mc);
142-
MEMPOOL_REGISTER_OPS(ops_sp_sc);
143-
MEMPOOL_REGISTER_OPS(ops_mp_sc);
144-
MEMPOOL_REGISTER_OPS(ops_sp_mc);
141+
RTE_MEMPOOL_REGISTER_OPS(ops_mp_mc);
142+
RTE_MEMPOOL_REGISTER_OPS(ops_sp_sc);
143+
RTE_MEMPOOL_REGISTER_OPS(ops_mp_sc);
144+
RTE_MEMPOOL_REGISTER_OPS(ops_sp_mc);

0 commit comments

Comments
 (0)