Skip to content

Commit f562016

Browse files
authored
Merge pull request #2340 from aciidb0mb3r/module-interface
[bootstrap] Install swiftinterface instead of swiftmodule for PD
2 parents ccc14e9 + 02ad2f2 commit f562016

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

Utilities/bootstrap

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class Target(object):
159159
self.is_swift = False
160160
# FIXME: Currently only C libraries are supported in bootstrap script.
161161
self.is_c = False
162+
self.enable_module_interface = False
162163

163164
self.sources = []
164165
self.module_root_dir = os.path.join(g_source_root, subpath or self.name)
@@ -202,6 +203,7 @@ class Target(object):
202203
link_input_nodes, predecessor_node, target_map):
203204
# Compute the derived paths.
204205
module_path = os.path.join(module_dir, "%s.swiftmodule" % (self.name,))
206+
module_interface_path = os.path.join(module_dir, "%s.swiftinterface" % (self.name,))
205207

206208
# Create the per-file entries.
207209
swift_objects = []
@@ -230,7 +232,13 @@ class Target(object):
230232
compile_swift_node = '<compile-swift-%s>' % (self.name,)
231233
link_input_nodes.append(compile_swift_node)
232234

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+
234242
other_args.extend(["-module-cache-path", os.path.join(args.sandbox_path, "ModuleCache")])
235243

236244
print(" %s:" % json.dumps(compile_swift_node), file=output)
@@ -640,6 +648,8 @@ def build_runtimes(targets, sandbox_path, args):
640648
target_copy.name = 'PackageDescription'
641649
target_copy.release = args.release
642650
target_copy.swiftflags = ["-DPACKAGE_DESCRIPTION_%s" % (version)]
651+
if platform.system() == 'Darwin':
652+
target_copy.enable_module_interface = True
643653
build = llbuild(
644654
os.path.join(sandbox_path, "runtimes", version), [target_copy], args)
645655
build.create_manifest()
@@ -650,6 +660,8 @@ def build_runtimes(targets, sandbox_path, args):
650660
def process_runtime_libraries(build, args, lib_path):
651661
module_input_path = os.path.join(
652662
build.module_dir, "PackageDescription.swiftmodule")
663+
moduleinterface_input_path = os.path.join(
664+
build.module_dir, "PackageDescription.swiftinterface")
653665
swiftdoc_input_path = os.path.join(
654666
build.module_dir, "PackageDescription.swiftdoc")
655667
input_lib_path = os.path.join(
@@ -658,13 +670,19 @@ def process_runtime_libraries(build, args, lib_path):
658670
mkdir_p(lib_path)
659671
runtime_module_path = os.path.join(
660672
lib_path, "PackageDescription.swiftmodule")
673+
runtime_moduleinterface_path = os.path.join(
674+
lib_path, "PackageDescription.swiftinterface")
661675
runtime_swiftdoc_path = os.path.join(
662676
lib_path, "PackageDescription.swiftdoc")
663677

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)
668686

669687
if platform.system() == 'Darwin':
670688
runtime_lib_path = os.path.join(lib_path, "libPackageDescription.dylib")
@@ -673,6 +691,7 @@ def process_runtime_libraries(build, args, lib_path):
673691
"-Xlinker", "-all_load",
674692
input_lib_path,
675693
"-sdk", args.sysroot,
694+
"-enable-library-evolution",
676695
"-target", "x86_64-apple-macosx10.10"]
677696
elif platform.system() == 'Windows':
678697
runtime_lib_path = os.path.join(lib_path, "PackageDescription.dll")
@@ -696,7 +715,7 @@ def process_runtime_libraries(build, args, lib_path):
696715
cmd.extend(["-module-cache-path", os.path.join(args.sandbox_path, "ModuleCache")])
697716

698717
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)
700719

701720

702721
def get_swift_build_tool_path():
@@ -1368,29 +1387,38 @@ def main():
13681387

13691388
# Install the runtimes.
13701389
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
13721391
install_path = os.path.join(lib_install_path, version)
13731392

13741393
# Install library.
13751394
installBinary(runtime_lib_path, install_path, args)
13761395

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,))
13851413

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,))
13941422

13951423

13961424
# Copy the libSwiftPM library to a directory, if we've been asked to do so.

0 commit comments

Comments
 (0)