@@ -64,9 +64,11 @@ class ArgumentType(Protocol):
6464 strip : bool
6565
6666
67- symlink_warning = '''Warning: trying to copy a symlink that points to a file. This will copy the file,
68- but this will be changed in a future version of Meson to copy the symlink as is. Please update your
69- build definitions so that it will not break when the change happens.'''
67+ symlink_warning = '''\
68+ Warning: trying to copy a symlink that points to a file. This currently copies
69+ the file by default, but will be changed in a future version of Meson to copy
70+ the link instead. Set follow_symlinks to true to preserve current behavior, or
71+ false to copy the link.'''
7072
7173selinux_updates : T .List [str ] = []
7274
@@ -389,7 +391,8 @@ def should_preserve_existing_file(self, from_file: str, to_file: str) -> bool:
389391 return from_time <= to_time
390392
391393 def do_copyfile (self , from_file : str , to_file : str ,
392- makedirs : T .Optional [T .Tuple [T .Any , str ]] = None ) -> bool :
394+ makedirs : T .Optional [T .Tuple [T .Any , str ]] = None ,
395+ follow_symlinks : T .Optional [bool ] = None ) -> bool :
393396 outdir = os .path .split (to_file )[0 ]
394397 if not os .path .isfile (from_file ) and not os .path .islink (from_file ):
395398 raise MesonException (f'Tried to install something that isn\' t a file: { from_file !r} ' )
@@ -417,10 +420,10 @@ def do_copyfile(self, from_file: str, to_file: str,
417420 # Dangling symlink. Replicate as is.
418421 self .copy (from_file , outdir , follow_symlinks = False )
419422 else :
420- # Remove this entire branch when changing the behaviour to duplicate
421- # symlinks rather than copying what they point to.
422- print (symlink_warning )
423- self .copy2 (from_file , to_file )
423+ if follow_symlinks is None :
424+ follow_symlinks = True # TODO: change to False when removing the warning
425+ print (symlink_warning )
426+ self .copy2 (from_file , to_file , follow_symlinks = follow_symlinks )
424427 else :
425428 self .copy2 (from_file , to_file )
426429 selinux_updates .append (to_file )
@@ -454,7 +457,7 @@ def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str, al
454457
455458 def do_copydir (self , data : InstallData , src_dir : str , dst_dir : str ,
456459 exclude : T .Optional [T .Tuple [T .Set [str ], T .Set [str ]]],
457- install_mode : 'FileMode' , dm : DirMaker ) -> None :
460+ install_mode : 'FileMode' , dm : DirMaker , follow_symlinks : T . Optional [ bool ] = None ) -> None :
458461 '''
459462 Copies the contents of directory @src_dir into @dst_dir.
460463
@@ -519,7 +522,7 @@ def do_copydir(self, data: InstallData, src_dir: str, dst_dir: str,
519522 dm .makedirs (parent_dir )
520523 self .copystat (os .path .dirname (abs_src ), parent_dir )
521524 # FIXME: what about symlinks?
522- self .do_copyfile (abs_src , abs_dst )
525+ self .do_copyfile (abs_src , abs_dst , follow_symlinks = follow_symlinks )
523526 self .set_mode (abs_dst , install_mode , data .install_umask )
524527
525528 def do_install (self , datafilename : str ) -> None :
@@ -613,7 +616,8 @@ def install_subdirs(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix
613616 full_dst_dir = get_destdir_path (destdir , fullprefix , i .install_path )
614617 self .log (f'Installing subdir { i .path } to { full_dst_dir } ' )
615618 dm .makedirs (full_dst_dir , exist_ok = True )
616- self .do_copydir (d , i .path , full_dst_dir , i .exclude , i .install_mode , dm )
619+ self .do_copydir (d , i .path , full_dst_dir , i .exclude , i .install_mode , dm ,
620+ follow_symlinks = i .follow_symlinks )
617621
618622 def install_data (self , d : InstallData , dm : DirMaker , destdir : str , fullprefix : str ) -> None :
619623 for i in d .data :
@@ -622,7 +626,7 @@ def install_data(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: s
622626 fullfilename = i .path
623627 outfilename = get_destdir_path (destdir , fullprefix , i .install_path )
624628 outdir = os .path .dirname (outfilename )
625- if self .do_copyfile (fullfilename , outfilename , makedirs = (dm , outdir )):
629+ if self .do_copyfile (fullfilename , outfilename , makedirs = (dm , outdir ), follow_symlinks = i . follow_symlinks ):
626630 self .did_install_something = True
627631 self .set_mode (outfilename , i .install_mode , d .install_umask )
628632
@@ -668,7 +672,8 @@ def install_headers(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix
668672 fname = os .path .basename (fullfilename )
669673 outdir = get_destdir_path (destdir , fullprefix , t .install_path )
670674 outfilename = os .path .join (outdir , fname )
671- if self .do_copyfile (fullfilename , outfilename , makedirs = (dm , outdir )):
675+ if self .do_copyfile (fullfilename , outfilename , makedirs = (dm , outdir ),
676+ follow_symlinks = t .follow_symlinks ):
672677 self .did_install_something = True
673678 self .set_mode (outfilename , t .install_mode , d .install_umask )
674679
0 commit comments