1313get_task_allow_plist = os .path .join (utils , 'get-task-allow.plist' )
1414
1515
16+ def file_path (string ):
17+ if os .path .isfile (string ):
18+ return string
19+ else :
20+ raise argparse .ArgumentTypeError (f"{ string } is not a valid path" )
21+
22+
1623def main (arguments ):
1724 parser = argparse .ArgumentParser (
1825 description = 'Postprocess binaries to prepare for \
1926 their execution on Darwin platforms' )
20- parser .add_argument ('bins' , nargs = '+' , help = 'one or more binary files' )
27+ parser .add_argument ('bins' , type = file_path , nargs = '+' , help = 'one or more binary files' )
2128
2229 args = parser .parse_args (arguments )
2330
@@ -37,12 +44,12 @@ def unrpathize(filename):
3744 # `dyldinfo` has been replaced with `dyld_info`, so we try it first
3845 # before falling back to `dyldinfo`
3946 dylibsOutput = subprocess .check_output (
40- ['xcrun' , 'dyld_info' , '-dependents' , filename ],
47+ ['/usr/bin/ xcrun' , 'dyld_info' , '-dependents' , filename ],
4148 universal_newlines = True )
4249 except subprocess .CalledProcessError :
4350 sys .stderr .write ("falling back to 'xcrun dyldinfo' ...\n " )
4451 dylibsOutput = subprocess .check_output (
45- ['xcrun' , 'dyldinfo' , '-dylibs' , filename ],
52+ ['/usr/bin/ xcrun' , 'dyldinfo' , '-dylibs' , filename ],
4653 universal_newlines = True )
4754
4855 # Do not rewrite @rpath-relative load commands for these libraries:
@@ -71,7 +78,7 @@ def unrpathize(filename):
7178 r"(^|.*\s)(?P<path>@rpath/(?P<filename>libswift.*\.dylib))\s*$" )
7279
7380 # Build a command to invoke install_name_tool.
74- command = ['install_name_tool' ]
81+ command = ['/usr/bin/xcrun' , ' install_name_tool' ]
7582 for line in dylibsOutput .splitlines ():
7683 match = dylib_regex .match (line )
7784 if match and match .group ('filename' ) not in allow_list :
@@ -82,7 +89,7 @@ def unrpathize(filename):
8289
8390 # Don't run the command if we didn't find any dylibs to change:
8491 # it's invalid to invoke install_name_tool without any operations.
85- if len (command ) == 1 :
92+ if len (command ) == 2 :
8693 return
8794
8895 # The last argument is the filename to operate on.
0 commit comments