@@ -19,7 +19,7 @@ mod build {
1919 pub const GLOBAL_API_SCRIPT_FILE_LIST_PATH : & str = "__global-api-script.js" ;
2020
2121 /// 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 ) {
2323 println ! (
2424 "cargo:{GLOBAL_API_SCRIPT_PATH_KEY}={}" ,
2525 path
@@ -31,18 +31,27 @@ mod build {
3131
3232 /// Collects the path of all the global API scripts defined with [`define_global_api_script_path`]
3333 /// 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 > ) {
3538 let mut scripts = Vec :: new ( ) ;
3639
3740 for ( key, value) in vars_os ( ) {
3841 let key = key. to_string_lossy ( ) ;
3942
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 ) {
4146 let script_path = PathBuf :: from ( value) ;
4247 scripts. push ( script_path) ;
4348 }
4449 }
4550
51+ if let Some ( tauri_global_scripts) = tauri_global_scripts {
52+ scripts. insert ( 0 , tauri_global_scripts) ;
53+ }
54+
4655 fs:: write (
4756 out_dir. join ( GLOBAL_API_SCRIPT_FILE_LIST_PATH ) ,
4857 serde_json:: to_string ( & scripts) . expect ( "failed to serialize global API script paths" ) ,
0 commit comments