Skip to content

Commit

Permalink
Search for nginx folder based on CARGO_MANIFEST_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
gabioprisan committed Oct 25, 2023
1 parent af739c5 commit 8e32fde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
apt install -y curl build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev libgd-dev libxml2 libxml2-dev uuid-dev clang
curl http://nginx.org/download/nginx-1.25.2.tar.gz | tar xz
ls -l
ls -l nginx-1.25.2
echo $PWD
cargo build --verbose
- name: Run tests
Expand Down
7 changes: 6 additions & 1 deletion nginx_module/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ fn main() {

fn search_nginx_root_folder() -> String {
fn check_nginx_root(path: &Path) -> bool {
if path.ends_with("nginx-1.25.2") {
println!("cargo:warning: Testing nginx folder");
}
INCLUDE_SUBDIRS.iter().all(|subdir| {
[path, Path::new(subdir)]
.iter()
Expand All @@ -96,15 +99,17 @@ fn search_nginx_root_folder() -> String {

// First, try to find the include folders in any of the parent folders of this folder,
// This is the case when this is a submodule of nginx
let manifest_dir = env!("CARGO_MANIFEST_DIR");
for base in base_locations {
let folder = base.to_string();
let folder = format!("{manifest_dir}/{base}");
if check_nginx_root(Path::new(&folder)) {
return folder;
}
}

// If we are not a nginx submodule, try to find the folder side by side
for base in base_locations {
let base = format!("{manifest_dir}/{base}");
for entry in std::fs::read_dir(base)
.expect("Cannot read directory")
.flatten()
Expand Down

0 comments on commit 8e32fde

Please sign in to comment.