@@ -159,6 +159,7 @@ class Target(object):
159
159
self .is_swift = False
160
160
# FIXME: Currently only C libraries are supported in bootstrap script.
161
161
self .is_c = False
162
+ self .enable_module_interface = False
162
163
163
164
self .sources = []
164
165
self .module_root_dir = os .path .join (g_source_root , subpath or self .name )
@@ -202,6 +203,7 @@ class Target(object):
202
203
link_input_nodes , predecessor_node , target_map ):
203
204
# Compute the derived paths.
204
205
module_path = os .path .join (module_dir , "%s.swiftmodule" % (self .name ,))
206
+ module_interface_path = os .path .join (module_dir , "%s.swiftinterface" % (self .name ,))
205
207
206
208
# Create the per-file entries.
207
209
swift_objects = []
@@ -230,7 +232,13 @@ class Target(object):
230
232
compile_swift_node = '<compile-swift-%s>' % (self .name ,)
231
233
link_input_nodes .append (compile_swift_node )
232
234
233
- other_args .extend (["-swift-version" , "4" ])
235
+ if self .enable_module_interface :
236
+ other_args .extend (["-enable-library-evolution" , "-emit-module-interface-path" , module_interface_path ])
237
+ other_args .extend (["-swift-version" , "5" ])
238
+ else :
239
+ # FIXME: We should just update to the newer version.
240
+ other_args .extend (["-swift-version" , "4" ])
241
+
234
242
other_args .extend (["-module-cache-path" , os .path .join (args .sandbox_path , "ModuleCache" )])
235
243
236
244
print (" %s:" % json .dumps (compile_swift_node ), file = output )
@@ -641,6 +649,8 @@ def build_runtimes(targets, sandbox_path, args):
641
649
target_copy .name = 'PackageDescription'
642
650
target_copy .release = args .release
643
651
target_copy .swiftflags = ["-DPACKAGE_DESCRIPTION_%s" % (version )]
652
+ if platform .system () == 'Darwin' :
653
+ target_copy .enable_module_interface = True
644
654
build = llbuild (
645
655
os .path .join (sandbox_path , "runtimes" , version ), [target_copy ], args )
646
656
build .create_manifest ()
@@ -651,6 +661,8 @@ def build_runtimes(targets, sandbox_path, args):
651
661
def process_runtime_libraries (build , args , lib_path ):
652
662
module_input_path = os .path .join (
653
663
build .module_dir , "PackageDescription.swiftmodule" )
664
+ moduleinterface_input_path = os .path .join (
665
+ build .module_dir , "PackageDescription.swiftinterface" )
654
666
swiftdoc_input_path = os .path .join (
655
667
build .module_dir , "PackageDescription.swiftdoc" )
656
668
input_lib_path = os .path .join (
@@ -659,13 +671,19 @@ def process_runtime_libraries(build, args, lib_path):
659
671
mkdir_p (lib_path )
660
672
runtime_module_path = os .path .join (
661
673
lib_path , "PackageDescription.swiftmodule" )
674
+ runtime_moduleinterface_path = os .path .join (
675
+ lib_path , "PackageDescription.swiftinterface" )
662
676
runtime_swiftdoc_path = os .path .join (
663
677
lib_path , "PackageDescription.swiftdoc" )
664
678
665
- distutils .file_util .copy_file (module_input_path , runtime_module_path ,
666
- update = 1 )
667
- distutils .file_util .copy_file (swiftdoc_input_path , runtime_swiftdoc_path ,
668
- update = 1 )
679
+ if platform .system () == 'Darwin' :
680
+ distutils .file_util .copy_file (moduleinterface_input_path , runtime_moduleinterface_path ,
681
+ update = 1 )
682
+ else :
683
+ distutils .file_util .copy_file (module_input_path , runtime_module_path ,
684
+ update = 1 )
685
+ distutils .file_util .copy_file (swiftdoc_input_path , runtime_swiftdoc_path ,
686
+ update = 1 )
669
687
670
688
if platform .system () == 'Darwin' :
671
689
runtime_lib_path = os .path .join (lib_path , "libPackageDescription.dylib" )
@@ -674,6 +692,7 @@ def process_runtime_libraries(build, args, lib_path):
674
692
"-Xlinker" , "-all_load" ,
675
693
input_lib_path ,
676
694
"-sdk" , args .sysroot ,
695
+ "-enable-library-evolution" ,
677
696
"-target" , "x86_64-apple-macosx10.10" ]
678
697
elif platform .system () == 'Windows' :
679
698
runtime_lib_path = os .path .join (lib_path , "PackageDescription.dll" )
@@ -697,7 +716,7 @@ def process_runtime_libraries(build, args, lib_path):
697
716
cmd .extend (["-module-cache-path" , os .path .join (args .sandbox_path , "ModuleCache" )])
698
717
699
718
subprocess .check_call (cmd )
700
- return (runtime_module_path , runtime_swiftdoc_path , runtime_lib_path )
719
+ return (runtime_moduleinterface_path , runtime_module_path , runtime_swiftdoc_path , runtime_lib_path )
701
720
702
721
703
722
def get_swift_build_tool_path ():
@@ -1376,29 +1395,38 @@ def main():
1376
1395
1377
1396
# Install the runtimes.
1378
1397
for version , runtime in processed_runtimes .items ():
1379
- runtime_module_path , runtime_swiftdoc_path , runtime_lib_path = runtime
1398
+ runtime_moduleinterface_path , runtime_module_path , runtime_swiftdoc_path , runtime_lib_path = runtime
1380
1399
install_path = os .path .join (lib_install_path , version )
1381
1400
1382
1401
# Install library.
1383
1402
installBinary (runtime_lib_path , install_path , args )
1384
1403
1385
- # Install module.
1386
- cmd = ["install" , "-m" , "0644" ,
1387
- runtime_module_path , install_path ]
1388
- note ("installing %s: %s" % (
1389
- os .path .basename (runtime_module_path ), ' ' .join (cmd )))
1390
- result = subprocess .call (cmd )
1391
- if result != 0 :
1392
- error ("module install failed with exit status %d" % (result ,))
1404
+ if platform .system () == 'Darwin' :
1405
+ cmd = ["install" , "-m" , "0644" ,
1406
+ runtime_moduleinterface_path , install_path ]
1407
+ note ("installing %s: %s" % (
1408
+ os .path .basename (runtime_moduleinterface_path ), ' ' .join (cmd )))
1409
+ result = subprocess .call (cmd )
1410
+ if result != 0 :
1411
+ error ("module install failed with exit status %d" % (result ,))
1412
+ else :
1413
+ # Install module.
1414
+ cmd = ["install" , "-m" , "0644" ,
1415
+ runtime_module_path , install_path ]
1416
+ note ("installing %s: %s" % (
1417
+ os .path .basename (runtime_module_path ), ' ' .join (cmd )))
1418
+ result = subprocess .call (cmd )
1419
+ if result != 0 :
1420
+ error ("module install failed with exit status %d" % (result ,))
1393
1421
1394
- # Install swiftdoc.
1395
- cmd = ["install" , "-m" , "0644" ,
1396
- runtime_swiftdoc_path , install_path ]
1397
- note ("installing %s: %s" % (
1398
- os .path .basename (runtime_swiftdoc_path ), ' ' .join (cmd )))
1399
- result = subprocess .call (cmd )
1400
- if result != 0 :
1401
- error ("swiftdoc install failed with exit status %d" % (result ,))
1422
+ # Install swiftdoc.
1423
+ cmd = ["install" , "-m" , "0644" ,
1424
+ runtime_swiftdoc_path , install_path ]
1425
+ note ("installing %s: %s" % (
1426
+ os .path .basename (runtime_swiftdoc_path ), ' ' .join (cmd )))
1427
+ result = subprocess .call (cmd )
1428
+ if result != 0 :
1429
+ error ("swiftdoc install failed with exit status %d" % (result ,))
1402
1430
1403
1431
1404
1432
# Copy the libSwiftPM library to a directory, if we've been asked to do so.
0 commit comments