Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.tar.gz
*.zip

35 changes: 26 additions & 9 deletions pkg_swift_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,38 @@ def export_sdk(tgt, swift_source_tree, swift_build_tree):
ignore=shutil.ignore_patterns('CMakeLists.txt'))


def export_libs(exported_dir, libs):
def export_stdlibs(exported_dir, swift_build_tree):
ext = 'dylib'
platform = 'macosx'
if get_platform() == "linux":
platform = 'linux'
ext = 'so'
lib_dir = swift_build_tree / 'lib/swift' / platform
stdlibs = [
f'libswiftCore.{ext}',
'libswiftCompatibility50.a',
'libswiftCompatibility51.a',
'libswiftCompatibilityConcurrency.a',
'libswiftCompatibilityDynamicReplacements.a']
for stdlib in stdlibs:
lib_path = lib_dir / stdlib
if lib_path.exists():
print(f'Copying {stdlib}')
shutil.copy(lib_path, exported_dir)
else:
print(f'Skipping {stdlib}')


def export_libs(exported_dir, libs, swift_build_tree):
print("exporting libraries")
exportedlibs = [
create_static_lib(exported_dir, libs),
create_shared_lib(exported_dir, libs)
]

for l in exportedlibs:
l.rename(exported_dir / l.name)
export_stdlibs(exported_dir, swift_build_tree)


def export_headers(exported_dir, swift_source_tree, llvm_build_tree, swift_build_tree):
Expand All @@ -200,12 +224,6 @@ def zip_dir(src, tgt):
archive = shutil.make_archive(tgt, 'zip', src)
print(f"created {archive}")

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


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

exported = tmp / "exported"
exported.mkdir()
export_libs(exported, libs)
export_libs(exported, libs, opts.swift_build_tree)
export_headers(exported, opts.swift_source_tree, opts.llvm_build_tree, opts.swift_build_tree)
export_sdk(exported / "sdk", opts.swift_source_tree, opts.swift_build_tree)

zip_dir(exported, opts.output)
tar_dir(exported, opts.output)


if __name__ == "__main__":
Expand Down