Skip to content

Add more swift libs #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 22, 2023
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
35 changes: 19 additions & 16 deletions pkg_swift_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,27 @@ def export_sdk(tgt, swift_source_tree, swift_build_tree):
ignore=shutil.ignore_patterns('CMakeLists.txt'))


def export_toolchain(tgt, toolchain_dir):
print("assembling toolchain")
shutil.copytree(toolchain_dir, tgt)


def export_stdlibs(exported_dir, swift_build_tree):
ext = 'dylib'
platform = 'macosx'
if get_platform() == "linux":
platform = 'linux'
ext = 'so'
platform = 'linux' if get_platform() == 'linux' else 'macosx'
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():
patterns = [f'lib{dep}.*' for dep in (
"dispatch",
"BlocksRuntime",
"swiftCore",
"swift_*",
"swiftGlibc",
"swiftCompatibility*",
)]
for pattern in patterns:
for stdlib in lib_dir.glob(pattern):
print(f'Copying {stdlib}')
shutil.copy(lib_path, exported_dir)
else:
print(f'Skipping {stdlib}')
shutil.copy(stdlib, exported_dir)


def export_libs(exported_dir, libs, swift_build_tree):
Expand Down Expand Up @@ -193,6 +194,7 @@ def main(opts):
os.mkdir(tmp)
llvm_build_tree = next(opts.build_tree.glob("llvm-*"))
swift_build_tree = next(opts.build_tree.glob("swift-*"))
toolchain_dir = next(opts.build_tree.glob("toolchain-*/codeql-toolchain"))
earlyswiftsyntax_build_tree = next(opts.build_tree.glob("earlyswiftsyntax-*"))
configured = configure_dummy_project(tmp, prefixes=[llvm_build_tree, swift_build_tree,
earlyswiftsyntax_build_tree / "cmake" / "modules"])
Expand All @@ -203,6 +205,7 @@ def main(opts):
export_libs(exported, libs, swift_build_tree)
export_headers(exported, opts.swift_source_tree, llvm_build_tree, swift_build_tree)
export_sdk(exported / "sdk", opts.swift_source_tree, swift_build_tree)
export_toolchain(exported / "toolchain", toolchain_dir)

zip_dir(exported, opts.output)

Expand Down
11 changes: 6 additions & 5 deletions swift-build-presets
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[preset: codeql-baseline]
llvm-cmake-options=-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64

skip-ios
skip-tvos
skip-watchos

skip-test-osx
skip-test-linux
skip-test-swiftpm
Expand All @@ -27,9 +23,11 @@ enable-experimental-string-processing
swift-enable-experimental-string-processing=1

no-assertions

reconfigure

install-swift
install-prefix=/codeql-toolchain

[preset: codeql-release]
mixin-preset=codeql-baseline
release
Expand All @@ -41,6 +39,9 @@ bootstrapping=hosttools

[preset: codeql-macOS]
mixin-preset=codeql-release
ios
tvos
watchos
bootstrapping=bootstrapping

[preset: codeql-debug]
Expand Down