@@ -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 )
@@ -640,6 +648,8 @@ def build_runtimes(targets, sandbox_path, args):
640
648
target_copy .name = 'PackageDescription'
641
649
target_copy .release = args .release
642
650
target_copy .swiftflags = ["-DPACKAGE_DESCRIPTION_%s" % (version )]
651
+ if platform .system () == 'Darwin' :
652
+ target_copy .enable_module_interface = True
643
653
build = llbuild (
644
654
os .path .join (sandbox_path , "runtimes" , version ), [target_copy ], args )
645
655
build .create_manifest ()
@@ -650,6 +660,8 @@ def build_runtimes(targets, sandbox_path, args):
650
660
def process_runtime_libraries (build , args , lib_path ):
651
661
module_input_path = os .path .join (
652
662
build .module_dir , "PackageDescription.swiftmodule" )
663
+ moduleinterface_input_path = os .path .join (
664
+ build .module_dir , "PackageDescription.swiftinterface" )
653
665
swiftdoc_input_path = os .path .join (
654
666
build .module_dir , "PackageDescription.swiftdoc" )
655
667
input_lib_path = os .path .join (
@@ -658,13 +670,19 @@ def process_runtime_libraries(build, args, lib_path):
658
670
mkdir_p (lib_path )
659
671
runtime_module_path = os .path .join (
660
672
lib_path , "PackageDescription.swiftmodule" )
673
+ runtime_moduleinterface_path = os .path .join (
674
+ lib_path , "PackageDescription.swiftinterface" )
661
675
runtime_swiftdoc_path = os .path .join (
662
676
lib_path , "PackageDescription.swiftdoc" )
663
677
664
- distutils .file_util .copy_file (module_input_path , runtime_module_path ,
665
- update = 1 )
666
- distutils .file_util .copy_file (swiftdoc_input_path , runtime_swiftdoc_path ,
667
- update = 1 )
678
+ if platform .system () == 'Darwin' :
679
+ distutils .file_util .copy_file (moduleinterface_input_path , runtime_moduleinterface_path ,
680
+ update = 1 )
681
+ else :
682
+ distutils .file_util .copy_file (module_input_path , runtime_module_path ,
683
+ update = 1 )
684
+ distutils .file_util .copy_file (swiftdoc_input_path , runtime_swiftdoc_path ,
685
+ update = 1 )
668
686
669
687
if platform .system () == 'Darwin' :
670
688
runtime_lib_path = os .path .join (lib_path , "libPackageDescription.dylib" )
@@ -673,6 +691,7 @@ def process_runtime_libraries(build, args, lib_path):
673
691
"-Xlinker" , "-all_load" ,
674
692
input_lib_path ,
675
693
"-sdk" , args .sysroot ,
694
+ "-enable-library-evolution" ,
676
695
"-target" , "x86_64-apple-macosx10.10" ]
677
696
elif platform .system () == 'Windows' :
678
697
runtime_lib_path = os .path .join (lib_path , "PackageDescription.dll" )
@@ -696,7 +715,7 @@ def process_runtime_libraries(build, args, lib_path):
696
715
cmd .extend (["-module-cache-path" , os .path .join (args .sandbox_path , "ModuleCache" )])
697
716
698
717
subprocess .check_call (cmd )
699
- return (runtime_module_path , runtime_swiftdoc_path , runtime_lib_path )
718
+ return (runtime_moduleinterface_path , runtime_module_path , runtime_swiftdoc_path , runtime_lib_path )
700
719
701
720
702
721
def get_swift_build_tool_path ():
@@ -1368,29 +1387,38 @@ def main():
1368
1387
1369
1388
# Install the runtimes.
1370
1389
for version , runtime in processed_runtimes .items ():
1371
- runtime_module_path , runtime_swiftdoc_path , runtime_lib_path = runtime
1390
+ runtime_moduleinterface_path , runtime_module_path , runtime_swiftdoc_path , runtime_lib_path = runtime
1372
1391
install_path = os .path .join (lib_install_path , version )
1373
1392
1374
1393
# Install library.
1375
1394
installBinary (runtime_lib_path , install_path , args )
1376
1395
1377
- # Install module.
1378
- cmd = ["install" , "-m" , "0644" ,
1379
- runtime_module_path , install_path ]
1380
- note ("installing %s: %s" % (
1381
- os .path .basename (runtime_module_path ), ' ' .join (cmd )))
1382
- result = subprocess .call (cmd )
1383
- if result != 0 :
1384
- error ("module install failed with exit status %d" % (result ,))
1396
+ if platform .system () == 'Darwin' :
1397
+ cmd = ["install" , "-m" , "0644" ,
1398
+ runtime_moduleinterface_path , install_path ]
1399
+ note ("installing %s: %s" % (
1400
+ os .path .basename (runtime_moduleinterface_path ), ' ' .join (cmd )))
1401
+ result = subprocess .call (cmd )
1402
+ if result != 0 :
1403
+ error ("module install failed with exit status %d" % (result ,))
1404
+ else :
1405
+ # Install module.
1406
+ cmd = ["install" , "-m" , "0644" ,
1407
+ runtime_module_path , install_path ]
1408
+ note ("installing %s: %s" % (
1409
+ os .path .basename (runtime_module_path ), ' ' .join (cmd )))
1410
+ result = subprocess .call (cmd )
1411
+ if result != 0 :
1412
+ error ("module install failed with exit status %d" % (result ,))
1385
1413
1386
- # Install swiftdoc.
1387
- cmd = ["install" , "-m" , "0644" ,
1388
- runtime_swiftdoc_path , install_path ]
1389
- note ("installing %s: %s" % (
1390
- os .path .basename (runtime_swiftdoc_path ), ' ' .join (cmd )))
1391
- result = subprocess .call (cmd )
1392
- if result != 0 :
1393
- error ("swiftdoc install failed with exit status %d" % (result ,))
1414
+ # Install swiftdoc.
1415
+ cmd = ["install" , "-m" , "0644" ,
1416
+ runtime_swiftdoc_path , install_path ]
1417
+ note ("installing %s: %s" % (
1418
+ os .path .basename (runtime_swiftdoc_path ), ' ' .join (cmd )))
1419
+ result = subprocess .call (cmd )
1420
+ if result != 0 :
1421
+ error ("swiftdoc install failed with exit status %d" % (result ,))
1394
1422
1395
1423
1396
1424
# Copy the libSwiftPM library to a directory, if we've been asked to do so.
0 commit comments