1515from __future__ import print_function
1616
1717import argparse
18- from distutils import dir_util
19- from distutils import file_util
2018import json
2119import os
2220import platform
@@ -406,42 +404,13 @@ def install_swiftpm(prefix, args):
406404 dest = os .path .join (prefix , "libexec" , "swift" , "pm" )
407405 install_binary (args , "swiftpm-xctest-helper" , dest )
408406
409- # Install PackageDescription runtime libraries .
410- runtime_lib_dest = os .path .join (prefix , "lib" , "swift" , "pm" )
411- runtime_lib_src = os . path . join (args . bootstrap_dir , "pm" )
407+ # Install the PackageDescription library and associated modules .
408+ dest = os .path .join (prefix , "lib" , "swift" , "pm" , "ManifestAPI " )
409+ install_dylib (args , "PackageDescription" , dest , [ "PackageDescription" ] )
412410
413- files_to_install = ["libPackageDescription" + g_shared_lib_suffix ]
414- if platform .system () == 'Darwin' :
415- files_to_install .append ("PackageDescription.swiftinterface" )
416- else :
417- files_to_install .append ("PackageDescription.swiftmodule" )
418- files_to_install .append ("PackageDescription.swiftdoc" )
419-
420- for file in files_to_install :
421- src = os .path .join (runtime_lib_src , "ManifestAPI" , file )
422- dest = os .path .join (runtime_lib_dest , "ManifestAPI" , file )
423- mkdir_p (os .path .dirname (dest ))
424-
425- note ("Installing %s to %s" % (src , dest ))
426-
427- file_util .copy_file (src , dest , update = 1 )
428-
429- # Install PackagePlugin runtime libraries.
430- files_to_install = ["libPackagePlugin" + g_shared_lib_suffix ]
431- if platform .system () == 'Darwin' :
432- files_to_install .append ("PackagePlugin.swiftinterface" )
433- else :
434- files_to_install .append ("PackagePlugin.swiftmodule" )
435- files_to_install .append ("PackagePlugin.swiftdoc" )
436-
437- for file in files_to_install :
438- src = os .path .join (runtime_lib_src , "PluginAPI" , file )
439- dest = os .path .join (runtime_lib_dest , "PluginAPI" , file )
440- mkdir_p (os .path .dirname (dest ))
441-
442- note ("Installing %s to %s" % (src , dest ))
443-
444- file_util .copy_file (src , dest , update = 1 )
411+ # Install the PackagePlugin library and associated modules.
412+ dest = os .path .join (prefix , "lib" , "swift" , "pm" , "PluginAPI" )
413+ install_dylib (args , "PackagePlugin" , dest , ["PackagePlugin" ])
445414
446415
447416# Helper function that installs a dynamic library and a set of modules to a particular directory.
@@ -453,7 +422,7 @@ def install_dylib(args, library_name, install_dir, module_names):
453422 for module in module_names :
454423 # If we're cross-compiling, we expect the .swiftmodule to be a directory that contains everything.
455424 if args .cross_compile_hosts :
456- install_binary (args , module + ".swiftmodule" , install_dir )
425+ install_binary (args , module + ".swiftmodule" , install_dir , [ 'Project' , '*.swiftmodule' ] )
457426 else :
458427 # Otherwise we have either a .swiftinterface or a .swiftmodule, plus a .swiftdoc.
459428 if os .path .exists (os .path .join (args .bin_dir , module + ".swiftinterface" )):
@@ -464,16 +433,16 @@ def install_dylib(args, library_name, install_dir, module_names):
464433
465434
466435# Helper function that installs a single built artifact to a particular directory. The source may be either a file or a directory.
467- def install_binary (args , binary , dest_dir ):
436+ def install_binary (args , binary , dest_dir , ignored_patterns = [] ):
468437 src = os .path .join (args .bin_dir , binary )
469438 dest = os .path .join (dest_dir , binary )
470439
471440 note ("Installing %s to %s" % (src , dest ))
472441 mkdir_p (os .path .dirname (dest ))
473442 if os .path .isdir (src ):
474- dir_util . copy_tree (src , dest , update = 1 , verbose = 1 )
443+ shutil . copytree (src , dest , ignore = shutil . ignore_patterns ( * ignored_patterns ) )
475444 else :
476- file_util . copy_file (src , dest , update = 1 , verbose = 1 )
445+ shutil . copy2 (src , dest )
477446
478447# -----------------------------------------------------------
479448# Build functions
0 commit comments