-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
52 lines (46 loc) · 1.7 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Moosync
// Copyright (C) 2024, 2025 Moosync <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use std::{
env, fs,
path::{Path, PathBuf},
};
fn find_function_details_json(target_dir: &Path) -> Option<PathBuf> {
println!("Looking in {:?}", target_dir);
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);
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");
}
}