Skip to content

Commit 426e296

Browse files
authored
Restore the bootstrap script changes to install the SwiftPM-built PackageDescription and PackagePlugin libraries (#3545)
* Restore the bootstrap script changes to install the SwiftPM-built PackageDescription and PackagePlugin libraries" This reverts commit 9a52971. * Filter out `*.swiftmodule` and `Project` entries when installing binaries, since these should not be part of the installed toolchain.
1 parent be4822e commit 426e296

File tree

1 file changed

+10
-41
lines changed

1 file changed

+10
-41
lines changed

Utilities/bootstrap

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from __future__ import print_function
1616

1717
import argparse
18-
from distutils import dir_util
19-
from distutils import file_util
2018
import json
2119
import os
2220
import 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

Comments
 (0)