Skip to content

Commit bb12613

Browse files
committed
Swift: package Swift stdlib
1 parent fe2c47c commit bb12613

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

pkg_swift_llvm.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,38 @@ def export_sdk(tgt, swift_source_tree, swift_build_tree):
173173
ignore=shutil.ignore_patterns('CMakeLists.txt'))
174174

175175

176-
def export_libs(exported_dir, libs):
176+
def export_stdlibs(exported_dir, swift_build_tree):
177+
ext = 'dylib'
178+
platform = 'macosx'
179+
if get_platform() == "linux":
180+
platform = 'linux'
181+
ext = 'so'
182+
lib_dir = swift_build_tree / 'lib/swift' / platform
183+
stdlibs = [
184+
f'libswiftCore.{ext}',
185+
'libswiftCompatibility50.a',
186+
'libswiftCompatibility51.a',
187+
'libswiftCompatibilityConcurrency.a',
188+
'libswiftCompatibilityDynamicReplacements.a']
189+
for stdlib in stdlibs:
190+
lib_path = lib_dir / stdlib
191+
if lib_path.exists():
192+
print(f'Copying {stdlib}')
193+
shutil.copy(lib_path, exported_dir)
194+
else:
195+
print(f'Skipping {stdlib}')
196+
197+
198+
def export_libs(exported_dir, libs, swift_build_tree):
177199
print("exporting libraries")
178200
exportedlibs = [
179201
create_static_lib(exported_dir, libs),
180202
create_shared_lib(exported_dir, libs)
181203
]
204+
182205
for l in exportedlibs:
183206
l.rename(exported_dir / l.name)
207+
export_stdlibs(exported_dir, swift_build_tree)
184208

185209

186210
def export_headers(exported_dir, swift_source_tree, llvm_build_tree, swift_build_tree):
@@ -217,7 +241,7 @@ def main(opts):
217241

218242
exported = tmp / "exported"
219243
exported.mkdir()
220-
export_libs(exported, libs)
244+
export_libs(exported, libs, opts.swift_build_tree)
221245
export_headers(exported, opts.swift_source_tree, opts.llvm_build_tree, opts.swift_build_tree)
222246
export_sdk(exported / "sdk", opts.swift_source_tree, opts.swift_build_tree)
223247

0 commit comments

Comments
 (0)