@@ -42,18 +42,16 @@ def overlapping_lipo_architectures(file_paths, lipo_executable):
42
42
return False
43
43
44
44
45
- # Copy the file
46
- def copy_file (file , src_root_dirs , dest_root_dir ):
45
+ # Determine the path to the first file and where it should be installed.
46
+ def get_first_file_and_dest_path (file , src_root_dirs , dest_root_dir ):
47
47
for dir in src_root_dirs :
48
48
orig_file = os .path .join (dir , file )
49
49
if os .path .exists (orig_file ):
50
- dest_file = os .path .join (
50
+ dest_path = os .path .join (
51
51
dest_root_dir , os .path .relpath (orig_file , dir ))
52
- print ("-- Copying file %s" % dest_file )
53
- shutil .copy2 (orig_file , dest_file )
54
- return
52
+ return (orig_file , dest_path )
55
53
56
- print ( "-- Warning: unable to copy file %s" % file )
54
+ return None
57
55
58
56
59
57
def merge_lipo_files (src_root_dirs , file_list , dest_root_dir , verbose = False ,
@@ -79,8 +77,10 @@ def merge_lipo_files(src_root_dirs, file_list, dest_root_dir, verbose=False,
79
77
print ("-- Warning: Can't locate source file %s" % file )
80
78
continue
81
79
82
- dest_path = os .path .join (
83
- dest_root_dir , os .path .relpath (file_paths [0 ], src_root_dirs [0 ]))
80
+ first_file_and_dest = get_first_file_and_dest_path (
81
+ file , src_root_dirs , dest_root_dir )
82
+ orig_file = first_file_and_dest [0 ]
83
+ dest_path = first_file_and_dest [1 ]
84
84
85
85
if all ([os .path .islink (item ) for item in file_paths ]):
86
86
# It's a symlink in all found instances, copy the link.
@@ -100,12 +100,14 @@ def merge_lipo_files(src_root_dirs, file_list, dest_root_dir, verbose=False,
100
100
# identical.
101
101
if all ([filecmp .cmp (item , file_paths [0 ]) for item in file_paths ]):
102
102
# All instances are identical, just copy the unique file.
103
- copy_file (file , src_root_dirs , dest_root_dir )
103
+ print ("-- Copying file %s" % dest_path )
104
+ shutil .copy2 (orig_file , dest_path )
104
105
elif all ([os .access (item , os .X_OK ) for item in file_paths ]):
105
106
if overlapping_lipo_architectures (file_paths , lipo_executable ):
106
107
# lipo will fail due to overlapping architectures, so
107
108
# copy the file directly.
108
- copy_file (file , src_root_dirs , dest_root_dir )
109
+ print ("-- Copying file verbatim %s" % dest_path )
110
+ shutil .copy2 (orig_file , dest_path )
109
111
else :
110
112
# Multiple instances are different and executable, try lipo.
111
113
if verbose :
0 commit comments