@@ -19,7 +19,7 @@ mod build {
19
19
pub const GLOBAL_API_SCRIPT_FILE_LIST_PATH : & str = "__global-api-script.js" ;
20
20
21
21
/// Defines the path to the global API script using Cargo instructions.
22
- pub fn define_global_api_script_path ( path : PathBuf ) {
22
+ pub fn define_global_api_script_path ( path : & Path ) {
23
23
println ! (
24
24
"cargo:{GLOBAL_API_SCRIPT_PATH_KEY}={}" ,
25
25
path
@@ -31,18 +31,27 @@ mod build {
31
31
32
32
/// Collects the path of all the global API scripts defined with [`define_global_api_script_path`]
33
33
/// and saves them to the out dir with filename [`GLOBAL_API_SCRIPT_FILE_LIST_PATH`].
34
- pub fn save_global_api_scripts_paths ( out_dir : & Path ) {
34
+ ///
35
+ /// `tauri_global_scripts` is only used in Tauri's monorepo for the examples to work
36
+ /// since they don't have a build script to run `tauri-build` and pull in the deps env vars
37
+ pub fn save_global_api_scripts_paths ( out_dir : & Path , mut tauri_global_scripts : Option < PathBuf > ) {
35
38
let mut scripts = Vec :: new ( ) ;
36
39
37
40
for ( key, value) in vars_os ( ) {
38
41
let key = key. to_string_lossy ( ) ;
39
42
40
- if key. starts_with ( "DEP_" ) && key. ends_with ( GLOBAL_API_SCRIPT_PATH_KEY ) {
43
+ if key == format ! ( "DEP_TAURI_{GLOBAL_API_SCRIPT_PATH_KEY}" ) {
44
+ tauri_global_scripts = Some ( PathBuf :: from ( value) ) ;
45
+ } else if key. starts_with ( "DEP_" ) && key. ends_with ( GLOBAL_API_SCRIPT_PATH_KEY ) {
41
46
let script_path = PathBuf :: from ( value) ;
42
47
scripts. push ( script_path) ;
43
48
}
44
49
}
45
50
51
+ if let Some ( tauri_global_scripts) = tauri_global_scripts {
52
+ scripts. insert ( 0 , tauri_global_scripts) ;
53
+ }
54
+
46
55
fs:: write (
47
56
out_dir. join ( GLOBAL_API_SCRIPT_FILE_LIST_PATH ) ,
48
57
serde_json:: to_string ( & scripts) . expect ( "failed to serialize global API script paths" ) ,
0 commit comments