@@ -22,6 +22,7 @@ fn main() -> Result<()> {
2222 . context ( "Failed to get CARGO_MANIFEST_DIR environment variable" ) ?;
2323 let dest_path = PathBuf :: from ( out_dir. clone ( ) ) . join ( FINAL_FILE_NAME ) ;
2424 let manifest_path = PathBuf :: from ( manifest_dir) ;
25+ let bundled_core_path = manifest_path. join ( "bundled-core" ) ;
2526
2627 // Download the file using reqwest (blocking)
2728 // Using a blocking request is simpler in a build script
@@ -72,29 +73,31 @@ fn main() -> Result<()> {
7273 println ! ( "cargo:warning={:?} = {:?}" , str , version. trim( ) ) ;
7374 }
7475 if str == CORE_TGZ {
75- println ! ( "cargo:info=Found core.tar.gz in archive, extracting to core" , ) ;
76- let core_tgz_path = PathBuf :: from ( out_dir. clone ( ) ) . join ( "core.tar.gz" ) ;
77- entry. unpack ( & core_tgz_path) . with_context ( || {
78- format ! ( "Failed to unpack file {:?} to {:?}" , path, core_tgz_path)
79- } ) ?;
80- let bytes = std:: fs:: read ( core_tgz_path)
81- . with_context ( || format ! ( "Failed to read file {:?}" , path) ) ?;
82- let core_tar = GzDecoder :: new ( bytes. as_slice ( ) ) ;
83- let mut core_archive = Archive :: new ( core_tar) ;
76+ if !bundled_core_path. exists ( ) {
77+ println ! ( "cargo:info=Found core.tar.gz in archive, extracting to core" , ) ;
78+ let core_tgz_path = PathBuf :: from ( out_dir. clone ( ) ) . join ( "core.tar.gz" ) ;
79+ entry. unpack ( & core_tgz_path) . with_context ( || {
80+ format ! ( "Failed to unpack file {:?} to {:?}" , path, core_tgz_path)
81+ } ) ?;
82+ let bytes = std:: fs:: read ( core_tgz_path)
83+ . with_context ( || format ! ( "Failed to read file {:?}" , path) ) ?;
84+ let core_tar = GzDecoder :: new ( bytes. as_slice ( ) ) ;
85+ let mut core_archive = Archive :: new ( core_tar) ;
8486
85- let core_target = manifest_path. clone ( ) ;
86- let core_dir = manifest_path. join ( "core" ) ;
87- if core_dir. exists ( ) {
88- std:: fs:: remove_dir_all ( core_dir) . with_context ( || {
89- format ! (
90- "Failed to remove directory {:?}" ,
91- manifest_path. join( "core" )
92- )
87+ let core_target = manifest_path. clone ( ) ;
88+ let core_dir = manifest_path. join ( "core" ) ;
89+ if core_dir. exists ( ) {
90+ std:: fs:: remove_dir_all ( core_dir) . with_context ( || {
91+ format ! (
92+ "Failed to remove directory {:?}" ,
93+ manifest_path. join( "core" )
94+ )
95+ } ) ?;
96+ }
97+ core_archive. unpack ( & core_target) . with_context ( || {
98+ format ! ( "Failed to unpack file {:?} to {:?}" , path, core_target)
9399 } ) ?;
94100 }
95- core_archive. unpack ( & core_target) . with_context ( || {
96- format ! ( "Failed to unpack file {:?} to {:?}" , path, core_target)
97- } ) ?;
98101 }
99102 }
100103 }
0 commit comments