15
15
from __future__ import print_function
16
16
17
17
import argparse
18
- from distutils import dir_util
19
- from distutils import file_util
20
18
import json
21
19
import os
22
20
import platform
@@ -406,42 +404,13 @@ def install_swiftpm(prefix, args):
406
404
dest = os .path .join (prefix , "libexec" , "swift" , "pm" )
407
405
install_binary (args , "swiftpm-xctest-helper" , dest )
408
406
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" ] )
412
410
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" ])
445
414
446
415
447
416
# 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):
453
422
for module in module_names :
454
423
# If we're cross-compiling, we expect the .swiftmodule to be a directory that contains everything.
455
424
if args .cross_compile_hosts :
456
- install_binary (args , module + ".swiftmodule" , install_dir )
425
+ install_binary (args , module + ".swiftmodule" , install_dir , [ 'Project' , '*.swiftmodule' ] )
457
426
else :
458
427
# Otherwise we have either a .swiftinterface or a .swiftmodule, plus a .swiftdoc.
459
428
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):
464
433
465
434
466
435
# 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 = [] ):
468
437
src = os .path .join (args .bin_dir , binary )
469
438
dest = os .path .join (dest_dir , binary )
470
439
471
440
note ("Installing %s to %s" % (src , dest ))
472
441
mkdir_p (os .path .dirname (dest ))
473
442
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 ) )
475
444
else :
476
- file_util . copy_file (src , dest , update = 1 , verbose = 1 )
445
+ shutil . copy2 (src , dest )
477
446
478
447
# -----------------------------------------------------------
479
448
# Build functions
0 commit comments