@@ -27,10 +27,11 @@ from helpers import note, error, symlink_force, mkdir_p, call, call_output
27
27
28
28
g_macos_deployment_target = '10.15'
29
29
30
+ g_shared_lib_prefix = "lib"
30
31
if platform .system () == 'Darwin' :
31
- g_shared_lib_ext = ".dylib"
32
+ g_shared_lib_suffix = ".dylib"
32
33
else :
33
- g_shared_lib_ext = ".so"
34
+ g_shared_lib_suffix = ".so"
34
35
35
36
def main ():
36
37
parser = argparse .ArgumentParser (description = """
@@ -366,7 +367,7 @@ def install(args):
366
367
"PackageGraph" , "SPMBuildCore" , "Build" ,
367
368
"Xcodeproj" , "Workspace"
368
369
]
369
- install_libswiftpm_dylib (args , "SwiftPM" , args .libswiftpm_install_dir , libswiftpm_modules )
370
+ install_dylib (args , "SwiftPM" , args .libswiftpm_install_dir , libswiftpm_modules )
370
371
371
372
# Install libSwiftPMDataModel if an install directory was provided.
372
373
if args .libswiftpmdatamodel_install_dir :
@@ -377,67 +378,49 @@ def install(args):
377
378
"PackageGraph" , "SPMBuildCore" ,
378
379
"Xcodeproj" , "Workspace"
379
380
]
380
- install_libswiftpm_dylib (args , "SwiftPMDataModel" , args .libswiftpmdatamodel_install_dir , libswiftpmdatamodel_modules )
381
+ install_dylib (args , "SwiftPMDataModel" , args .libswiftpmdatamodel_install_dir , libswiftpmdatamodel_modules )
381
382
383
+ # Installs the SwiftPM tools and runtime support libraries.
382
384
def install_swiftpm (prefix , args ):
383
- # Install swiftpm binary and create tool symlinks.
385
+ # Install the swift-package tool and create symlinks to it .
384
386
cli_tool_dest = os .path .join (prefix , "bin" )
385
387
install_binary (args , "swift-package" , cli_tool_dest )
386
388
for tool in ["swift-build" , "swift-test" , "swift-run" , "swift-package-collection" ]:
387
389
src = "swift-package"
388
390
dest = os .path .join (cli_tool_dest , tool )
389
391
note ("Creating tool symlink from %s to %s" % (src , dest ))
390
392
symlink_force (src , dest )
391
-
393
+
394
+ # On Darwin, also install the swiftpm-xctest-helper tool.
392
395
if platform .system () == 'Darwin' :
393
396
dest = os .path .join (prefix , "libexec" , "swift" , "pm" )
394
397
install_binary (args , "swiftpm-xctest-helper" , dest )
395
398
396
- # Install PackageDescription runtime libraries.
397
- runtime_lib_dest = os .path .join (prefix , "lib" , "swift" , "pm" )
398
- runtime_lib_src = os .path .join (args .bootstrap_dir , "pm" )
399
-
400
- files_to_install = ["libPackageDescription" + g_shared_lib_ext ]
401
- if platform .system () == 'Darwin' :
402
- files_to_install .append ("PackageDescription.swiftinterface" )
403
- else :
404
- files_to_install .append ("PackageDescription.swiftmodule" )
405
- files_to_install .append ("PackageDescription.swiftdoc" )
406
-
407
- for file in files_to_install :
408
- src = os .path .join (runtime_lib_src , "ManifestAPI" , file )
409
- dest = os .path .join (runtime_lib_dest , "ManifestAPI" , file )
410
- mkdir_p (os .path .dirname (dest ))
411
-
412
- note ("Installing %s to %s" % (src , dest ))
413
-
414
- file_util .copy_file (src , dest , update = 1 )
415
-
416
- files_to_install = ["libPackagePlugin" + g_shared_lib_ext ]
417
- if platform .system () == 'Darwin' :
418
- files_to_install .append ("PackagePlugin.swiftinterface" )
419
- else :
420
- files_to_install .append ("PackagePlugin.swiftmodule" )
421
- files_to_install .append ("PackagePlugin.swiftdoc" )
422
-
423
- for file in files_to_install :
424
- src = os .path .join (runtime_lib_src , "PluginAPI" , file )
425
- dest = os .path .join (runtime_lib_dest , "PluginAPI" , file )
426
- mkdir_p (os .path .dirname (dest ))
427
-
428
- note ("Installing %s to %s" % (src , dest ))
429
-
430
- file_util .copy_file (src , dest , update = 1 )
399
+ # Install the PackageDescription library and associated modules.
400
+ dest = os .path .join (prefix , "lib" , "swift" , "pm" , "ManifestAPI" )
401
+ install_dylib (args , "PackageDescription" , dest , ["PackageDescription" ])
402
+
403
+ # Install the PackagePlugin library and associated modules.
404
+ dest = os .path .join (prefix , "lib" , "swift" , "pm" , "PluginAPI" )
405
+ install_dylib (args , "PackagePlugin" , dest , ["PackagePlugin" ])
431
406
432
407
433
- def install_libswiftpm_dylib (args , library_name , install_dir , module_names ):
434
- # FIXME: Don't hardcode the prefix and suffix.
435
- install_binary (args , "lib" + library_name + ".dylib" , install_dir )
408
+ # Helper function that installs a dynamic library and a set of modules to a particular directory.
409
+ def install_dylib (args , library_name , install_dir , module_names ):
410
+ # Install the dynamic library itself.
411
+ install_binary (args , g_shared_lib_prefix + library_name + g_shared_lib_suffix , install_dir )
436
412
437
- # Install the swiftmodule and swiftdoc files.
413
+ # Install the swiftmodule/swiftinterface and swiftdoc files for all the modules .
438
414
for module in module_names :
439
- install_binary (args , module + ".swiftmodule" , install_dir )
440
- if not args .cross_compile_hosts : # When compiling for multiple arches, swiftdoc is part of the swiftmodule directory
415
+ # If we're cross-compiling, we expect the .swiftmodule to be a directory that contains everything.
416
+ if args .cross_compile_hosts :
417
+ install_binary (args , module + ".swiftmodule" , install_dir )
418
+ else :
419
+ # Otherwise we have either a .swiftinterface or a .swiftmodule, plus a .swiftdoc.
420
+ if os .path .exists (os .path .join (args .bin_dir , module + ".swiftinterface" )):
421
+ install_binary (args , module + ".swiftinterface" , install_dir )
422
+ else :
423
+ install_binary (args , module + ".swiftmodule" , install_dir )
441
424
install_binary (args , module + ".swiftdoc" , install_dir )
442
425
443
426
# Install the C headers.
@@ -446,17 +429,18 @@ def install_libswiftpm_dylib(args, library_name, install_dir, module_names):
446
429
dir_util .copy_tree (tscclibc_include_dir , tscclibc_include_dir_dest )
447
430
448
431
432
+ # Helper function that installs a single built artifact to a particular directory. The source may be either a file or a directory.
449
433
def install_binary (args , binary , dest_dir ):
450
434
src = os .path .join (args .bin_dir , binary )
451
435
dest = os .path .join (dest_dir , binary )
452
436
453
437
note ("Installing %s to %s" % (src , dest ))
454
438
455
439
mkdir_p (os .path .dirname (dest ))
456
- if os .path .isdir (src ) and args . cross_compile_hosts : # Handle swiftmodule directories if compiling for multiple arches.
457
- dir_util .copy_tree (src , dest )
440
+ if os .path .isdir (src ):
441
+ dir_util .copy_tree (src , dest , update = 1 , verbose = 1 )
458
442
else :
459
- file_util .copy_file (src , dest , update = 1 )
443
+ file_util .copy_file (src , dest , update = 1 , verbose = 1 )
460
444
461
445
# -----------------------------------------------------------
462
446
# Build functions
@@ -651,6 +635,8 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
651
635
if integrated_swift_driver :
652
636
swiftpm_args .append ("--use-integrated-swift-driver" )
653
637
638
+ swiftpm_args .append ("--enable-parseable-module-interfaces" )
639
+
654
640
call_swiftpm (args , swiftpm_args )
655
641
656
642
# Setup symlinks that'll allow using swiftpm from the build directory.
0 commit comments