Skip to content

Commit 6971a84

Browse files
authored
Merge pull request #2355 from apple/revert-2343-revert-2340-module-interface
[bootstrap] Install swiftinterface instead of swiftmodule for PD
2 parents 128a793 + 82b7408 commit 6971a84

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)
@@ -641,6 +649,8 @@ def build_runtimes(targets, sandbox_path, args):
641649
target_copy.name = 'PackageDescription'
642650
target_copy.release = args.release
643651
target_copy.swiftflags = ["-DPACKAGE_DESCRIPTION_%s" % (version)]
652+
if platform.system() == 'Darwin':
653+
target_copy.enable_module_interface = True
644654
build = llbuild(
645655
os.path.join(sandbox_path, "runtimes", version), [target_copy], args)
646656
build.create_manifest()
@@ -651,6 +661,8 @@ def build_runtimes(targets, sandbox_path, args):
651661
def process_runtime_libraries(build, args, lib_path):
652662
module_input_path = os.path.join(
653663
build.module_dir, "PackageDescription.swiftmodule")
664+
moduleinterface_input_path = os.path.join(
665+
build.module_dir, "PackageDescription.swiftinterface")
654666
swiftdoc_input_path = os.path.join(
655667
build.module_dir, "PackageDescription.swiftdoc")
656668
input_lib_path = os.path.join(
@@ -659,13 +671,19 @@ def process_runtime_libraries(build, args, lib_path):
659671
mkdir_p(lib_path)
660672
runtime_module_path = os.path.join(
661673
lib_path, "PackageDescription.swiftmodule")
674+
runtime_moduleinterface_path = os.path.join(
675+
lib_path, "PackageDescription.swiftinterface")
662676
runtime_swiftdoc_path = os.path.join(
663677
lib_path, "PackageDescription.swiftdoc")
664678

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

670688
if platform.system() == 'Darwin':
671689
runtime_lib_path = os.path.join(lib_path, "libPackageDescription.dylib")
@@ -674,6 +692,7 @@ def process_runtime_libraries(build, args, lib_path):
674692
"-Xlinker", "-all_load",
675693
input_lib_path,
676694
"-sdk", args.sysroot,
695+
"-enable-library-evolution",
677696
"-target", "x86_64-apple-macosx10.10"]
678697
elif platform.system() == 'Windows':
679698
runtime_lib_path = os.path.join(lib_path, "PackageDescription.dll")
@@ -697,7 +716,7 @@ def process_runtime_libraries(build, args, lib_path):
697716
cmd.extend(["-module-cache-path", os.path.join(args.sandbox_path, "ModuleCache")])
698717

699718
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)
701720

702721

703722
def get_swift_build_tool_path():
@@ -1376,29 +1395,38 @@ def main():
13761395

13771396
# Install the runtimes.
13781397
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
13801399
install_path = os.path.join(lib_install_path, version)
13811400

13821401
# Install library.
13831402
installBinary(runtime_lib_path, install_path, args)
13841403

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

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

14031431

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

0 commit comments

Comments
 (0)