@@ -38,19 +38,15 @@ fn main() -> Result<()> {
3838 println ! ( "cargo::rerun-if-changed={ASM_DIR}/" ) ;
3939 println ! ( "cargo::rerun-if-env-changed=BUILD_GENERATED_FILES_IN_SRC" ) ;
4040
41- // Copies the MASM code to the build directory
4241 let crate_dir = env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ;
4342 let build_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
44- let src = Path :: new ( & crate_dir) . join ( ASM_DIR ) ;
4543
4644 // generate canonical zeros in `asm/agglayer/bridge/canonical_zeros.masm`
47- generate_canonical_zeros ( & src. join ( ASM_AGGLAYER_BRIDGE_DIR ) ) ?;
45+ let crate_path = Path :: new ( & crate_dir) ;
46+ generate_canonical_zeros ( & crate_path. join ( ASM_DIR ) . join ( ASM_AGGLAYER_BRIDGE_DIR ) ) ?;
4847
49- let dst = Path :: new ( & build_dir) . to_path_buf ( ) ;
50- shared:: copy_directory ( src, & dst, ASM_DIR ) ?;
51-
52- // set source directory to {OUT_DIR}/asm
53- let source_dir = dst. join ( ASM_DIR ) ;
48+ // Read MASM sources directly from the crate's asm/ directory.
49+ let source_dir = crate_path. join ( ASM_DIR ) ;
5450
5551 // set target directory to {OUT_DIR}/assets
5652 let target_dir = Path :: new ( & build_dir) . join ( ASSETS_DIR ) ;
@@ -328,54 +324,6 @@ mod shared {
328324 use regex:: Regex ;
329325 use walkdir:: WalkDir ;
330326
331- /// Recursively copies `src` into `dst`.
332- ///
333- /// This function will overwrite the existing files if re-executed.
334- pub fn copy_directory < T : AsRef < Path > , R : AsRef < Path > > (
335- src : T ,
336- dst : R ,
337- asm_dir : & str ,
338- ) -> Result < ( ) > {
339- let mut prefix = src. as_ref ( ) . canonicalize ( ) . unwrap ( ) ;
340- // keep all the files inside the `asm` folder
341- prefix. pop ( ) ;
342-
343- let target_dir = dst. as_ref ( ) . join ( asm_dir) ;
344- if target_dir. exists ( ) {
345- // Clear existing asm files that were copied earlier which may no longer exist.
346- fs:: remove_dir_all ( & target_dir)
347- . into_diagnostic ( )
348- . wrap_err ( "failed to remove ASM directory" ) ?;
349- }
350-
351- // Recreate the directory structure.
352- fs:: create_dir_all ( & target_dir)
353- . into_diagnostic ( )
354- . wrap_err ( "failed to create ASM directory" ) ?;
355-
356- let dst = dst. as_ref ( ) ;
357- let mut todo = vec ! [ src. as_ref( ) . to_path_buf( ) ] ;
358-
359- while let Some ( goal) = todo. pop ( ) {
360- for entry in fs:: read_dir ( goal) . unwrap ( ) {
361- let path = entry. unwrap ( ) . path ( ) ;
362- if path. is_dir ( ) {
363- let src_dir = path. canonicalize ( ) . unwrap ( ) ;
364- let dst_dir = dst. join ( src_dir. strip_prefix ( & prefix) . unwrap ( ) ) ;
365- if !dst_dir. exists ( ) {
366- fs:: create_dir_all ( & dst_dir) . unwrap ( ) ;
367- }
368- todo. push ( src_dir) ;
369- } else {
370- let dst_file = dst. join ( path. strip_prefix ( & prefix) . unwrap ( ) ) ;
371- fs:: copy ( & path, dst_file) . unwrap ( ) ;
372- }
373- }
374- }
375-
376- Ok ( ( ) )
377- }
378-
379327 /// Returns a vector with paths to all MASM files in the specified directory.
380328 ///
381329 /// All non-MASM files are skipped.
0 commit comments