Skip to content

Commit d8eabb1

Browse files
committed
Build script: search Nginx folder based on CARGO_TARGET_DIR as well
1 parent 0ddd8d0 commit d8eabb1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

nginx_module/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nginx_module"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
build = "build.rs"
66
authors = ["Gabriel Oprisan <gabriel.oprisan@gcore.com>"]

nginx_module/build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ fn search_nginx_root_folder() -> String {
104104
}
105105
}
106106

107+
let target_dir = std::env::var("CARGO_TARGET_DIR");
108+
if let Ok(target_dir) = target_dir.as_ref() {
109+
for base in base_locations {
110+
let folder = format!("{target_dir}/{base}");
111+
if check_nginx_root(Path::new(&folder)) {
112+
return folder;
113+
}
114+
}
115+
}
116+
107117
// If we are not a nginx submodule, try to find the folder side by side
108118
for base in base_locations {
109119
let base = format!("{manifest_dir}/{base}");
@@ -117,6 +127,20 @@ fn search_nginx_root_folder() -> String {
117127
}
118128
}
119129

130+
if let Ok(target_dir) = target_dir {
131+
for base in base_locations {
132+
let base = format!("{target_dir}/{base}");
133+
for entry in std::fs::read_dir(base)
134+
.expect("Cannot read directory")
135+
.flatten()
136+
{
137+
if entry.path().is_dir() && check_nginx_root(&entry.path()) {
138+
return entry.path().to_str().unwrap().to_owned();
139+
}
140+
}
141+
}
142+
}
143+
120144
panic!("We need to generate the Rust bindings from the Nginx header files but the Nginx folder cannot be found. Please git clone the nginx repo in any of these locations relative to this folder: {base_locations:?}");
121145
}
122146

0 commit comments

Comments
 (0)