@@ -202,6 +202,7 @@ def parse_build_args(args):
202
202
args .target_dir = os .path .join (args .build_dir , get_build_target (args ))
203
203
args .bootstrap_dir = os .path .join (args .target_dir , "bootstrap" )
204
204
args .conf = 'release' if args .release else 'debug'
205
+ args .pkgdesc_version = "4_2"
205
206
args .bin_dir = os .path .join (args .target_dir , args .conf )
206
207
args .bootstrap = not args .skip_cmake_bootstrap or \
207
208
not os .path .exists (os .path .join (os .path .split (args .swiftc_path )[0 ], "swift-build" ))
@@ -389,42 +390,16 @@ def install_swiftpm(prefix, args):
389
390
dest = os .path .join (prefix , "libexec" , "swift" , "pm" )
390
391
install_binary (args , "swiftpm-xctest-helper" , dest )
391
392
392
- # Install PackageDescription runtime libraries.
393
- runtime_lib_dest = os .path .join (prefix , "lib" , "swift" , "pm" )
394
- runtime_lib_src = os .path .join (args .bootstrap_dir , "pm" )
395
-
396
- for runtime in ["4" , "4_2" ]:
397
- files_to_install = ["libPackageDescription" + g_shared_lib_ext ]
398
- if platform .system () == 'Darwin' :
399
- files_to_install .append ("PackageDescription.swiftinterface" )
400
- else :
401
- files_to_install .append ("PackageDescription.swiftmodule" )
402
- files_to_install .append ("PackageDescription.swiftdoc" )
403
-
404
- for file in files_to_install :
405
- src = os .path .join (runtime_lib_src , runtime , file )
406
- dest = os .path .join (runtime_lib_dest , runtime , file )
407
- mkdir_p (os .path .dirname (dest ))
408
-
409
- note ("Installing %s to %s" % (src , dest ))
410
-
411
- file_util .copy_file (src , dest , update = 1 )
412
-
413
- files_to_install = ["libPackagePlugin" + g_shared_lib_ext ]
414
- if platform .system () == 'Darwin' :
415
- files_to_install .append ("PackagePlugin.swiftinterface" )
416
- else :
417
- files_to_install .append ("PackagePlugin.swiftmodule" )
418
- files_to_install .append ("PackagePlugin.swiftdoc" )
419
-
420
- for file in files_to_install :
421
- src = os .path .join (runtime_lib_src , file )
422
- dest = os .path .join (runtime_lib_dest , 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 )
393
+ # Install the current variant of PackageDescription.
394
+ install_dylib (args , "PackageDescription" , os .path .join (prefix , "lib" , "swift" , "pm" , "4_2" ), ["PackageDescription" ])
395
+
396
+ # Install the legacy variant of PackageDescription.
397
+ args_pd4 = args
398
+ args_pd4 .build_dir = os .path .join (args .build_dir , "PD4" )
399
+ install_dylib (args_pd4 , "PackageDescription" , os .path .join (prefix , "lib" , "swift" , "pm" , "4" ), ["PackageDescription" ])
400
+
401
+ # Install PackagePlugin.
402
+ install_dylib (args , "PackagePlugin" , os .path .join (prefix , "lib" , "swift" , "pm" ), ["PackagePlugin" ])
428
403
429
404
430
405
def install_libswiftpm_dylib (args , library_name , install_dir , module_names ):
@@ -443,6 +418,18 @@ def install_libswiftpm_dylib(args, library_name, install_dir, module_names):
443
418
dir_util .copy_tree (tscclibc_include_dir , tscclibc_include_dir_dest )
444
419
445
420
421
+ def install_dylib (args , library_name , install_dir , module_names ):
422
+ # Install the dynamic library itself.
423
+ # FIXME: Don't hardcode the library prefix.
424
+ install_binary (args , "lib" + library_name + g_shared_lib_ext , install_dir )
425
+
426
+ # Install the swiftmodule/swiftinterface and swiftdoc files for all the modules.
427
+ for module in module_names :
428
+ install_binary (args , module + ".swiftmodule" , install_dir )
429
+ if not args .cross_compile_hosts : # When compiling for multiple arches, swiftdoc is part of the swiftmodule directory
430
+ install_binary (args , module + ".swiftdoc" , install_dir )
431
+
432
+
446
433
def install_binary (args , binary , dest_dir ):
447
434
src = os .path .join (args .bin_dir , binary )
448
435
dest = os .path .join (dest_dir , binary )
@@ -647,8 +634,18 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
647
634
648
635
if integrated_swift_driver :
649
636
swiftpm_args .append ("--use-integrated-swift-driver" )
650
-
637
+
638
+ # Build SwiftPM, including libSwiftPM, all the command line tools, and the current variant of PackageDescription.
651
639
call_swiftpm (args , swiftpm_args )
640
+
641
+ # Also build the legacy variant of PackageDescription into a subdirectory of the build directory.
642
+ args_pd4 = args
643
+ args_pd4 .build_dir = os .path .join (args .build_dir , "PD4" )
644
+ args_pd4 .pkgdesc_version = "4"
645
+ swiftpm_args_pd4 = swiftpm_args
646
+ swiftpm_args_pd4 .append ("--product" )
647
+ swiftpm_args_pd4 .append ("PackageDescription" )
648
+ call_swiftpm (args_pd4 , swiftpm_args_pd4 )
652
649
653
650
# Setup symlinks that'll allow using swiftpm from the build directory.
654
651
symlink_force (args .swiftc_path , os .path .join (args .target_dir , args .conf , "swiftc" ))
@@ -713,6 +710,7 @@ def get_swiftpm_env_cmd(args):
713
710
env_cmd .append ("SWIFTPM_LLBUILD_FWK=1" )
714
711
env_cmd .append ("SWIFTCI_USE_LOCAL_DEPS=1" )
715
712
env_cmd .append ("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target )
713
+ env_cmd .append ("SWIFTPM_PACKAGE_DESCRIPTION_VERSION=%s" % args .pkgdesc_version )
716
714
717
715
if args .bootstrap :
718
716
libs_joined = ":" .join ([
0 commit comments