-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,35 @@ | ||
use std::{env, path::Path}; | ||
use std::{ | ||
env, fs, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
fn find_function_details_json(target_dir: &Path) -> Option<PathBuf> { | ||
for entry in fs::read_dir(target_dir).ok()? { | ||
let entry = entry.ok()?; | ||
let path = entry.path(); | ||
|
||
if path.is_dir() { | ||
if let Some(found) = find_function_details_json(&path) { | ||
return Some(found); | ||
} | ||
} else if path.ends_with("function_details.json") { | ||
return Some(path); | ||
} | ||
} | ||
|
||
None | ||
} | ||
|
||
fn main() { | ||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set"); | ||
let manifest_dir = Path::new(&manifest_dir); | ||
let profile = env::var("PROFILE").expect("PROFILE environment variable is not set"); | ||
|
||
let file_path = manifest_dir.join("target").join(profile).join("build"); | ||
|
||
println!( | ||
"cargo:rustc-env=TAURI_INVOKE_PROC_DIR={}", | ||
file_path.to_string_lossy() | ||
); | ||
if let Some(file_path) = find_function_details_json(manifest_dir.join("target").as_path()) { | ||
println!( | ||
"cargo:rustc-env=TAURI_INVOKE_PROC_DIR={}", | ||
file_path.to_string_lossy() | ||
); | ||
} else { | ||
println!("cargo:warning=Could not find function_details.json"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters