Skip to content

Commit 6fa3c81

Browse files
authored
Merge pull request #5 from dsp-testing/alexdenisov/package-swift-stdlib
Package Swift stdlib
2 parents fe2c47c + 32ed413 commit 6fa3c81

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.tar.gz
2+
*.zip
3+

pkg_swift_llvm.py

Lines changed: 26 additions & 9 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):
@@ -200,12 +224,6 @@ def zip_dir(src, tgt):
200224
archive = shutil.make_archive(tgt, 'zip', src)
201225
print(f"created {archive}")
202226

203-
def tar_dir(src, tgt):
204-
tgt = get_tgt(tgt, f"swift-prebuilt-{get_platform()}.tar.gz")
205-
print(f"compressing {src.name} to {tgt}")
206-
archive = shutil.make_archive(tgt, 'gztar', src)
207-
print(f"created {archive}")
208-
209227

210228
def main(opts):
211229
tmp = pathlib.Path('/tmp/llvm-swift')
@@ -217,12 +235,11 @@ def main(opts):
217235

218236
exported = tmp / "exported"
219237
exported.mkdir()
220-
export_libs(exported, libs)
238+
export_libs(exported, libs, opts.swift_build_tree)
221239
export_headers(exported, opts.swift_source_tree, opts.llvm_build_tree, opts.swift_build_tree)
222240
export_sdk(exported / "sdk", opts.swift_source_tree, opts.swift_build_tree)
223241

224242
zip_dir(exported, opts.output)
225-
tar_dir(exported, opts.output)
226243

227244

228245
if __name__ == "__main__":

0 commit comments

Comments
 (0)