Skip to content

Commit 6353360

Browse files
Fix libxml2 installation and default Swift SDK selection in E2E tests
1 parent bfc8e0f commit 6353360

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

schemes/main/build/build-target-toolchain.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ build_target_toolchain() {
5050
rm -rf "$TRIPLE_DESTDIR/usr/lib/swift_static/clang/lib/$COMPILER_RT_OS_DIR"
5151
# XXX: Is this the right way to install compiler-rt?
5252
cp -R "$TARGET_BUILD_ROOT/wasi-sysroot/$CLANG_MULTIARCH_TRIPLE/lib/$COMPILER_RT_OS_DIR" "$TRIPLE_DESTDIR/usr/lib/swift_static/clang/lib/$COMPILER_RT_OS_DIR"
53+
54+
# FIXME: The following is a workaround for the issue with wrong libxml2.a path
55+
local LIBXML2_PATH_TO_FIX="$TARGET_BUILD_ROOT/wasi-sysroot/$CLANG_MULTIARCH_TRIPLE/lib/libxml2.a"
56+
if [[ -f "$LIBXML2_PATH_TO_FIX" ]]; then
57+
cp "$LIBXML2_PATH_TO_FIX" "$TRIPLE_DESTDIR/usr/lib/swift_static/wasi/libxml2.a"
58+
fi
5359
}
5460

5561
main() {

tools/build/run-e2e-test

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,37 @@ import sys
44
import argparse
55
import pathlib
66
import subprocess
7-
import os
87
from build_support.actions import derive_options_from_args, REPO_ROOT, DownloadBaseSnapshotAction
98

109

10+
def default_swift_sdk(options, swift_sdks_path: pathlib.Path):
11+
"""Return the default target triple based on the scheme."""
12+
import json
13+
for artifact_bundle in swift_sdks_path.iterdir():
14+
if not artifact_bundle.is_dir() or not artifact_bundle.name.endswith('.artifactbundle'):
15+
# Skip if not ending with .artifactbundle
16+
continue
17+
info_json = artifact_bundle / 'info.json'
18+
if not info_json.is_file():
19+
continue
20+
try:
21+
with info_json.open('r') as f:
22+
info = json.load(f)
23+
24+
sdk_ids = info.get('artifacts', {}).keys()
25+
for sdk_id in sdk_ids:
26+
if sdk_id.endswith("wasm32-unknown-wasip1") or sdk_id.endswith("wasm32-unknown-wasi"):
27+
return sdk_id
28+
except Exception as e:
29+
print(f"Error reading {info_json}: {e}", file=sys.stderr)
30+
continue
31+
32+
1133
def main():
1234
parser = argparse.ArgumentParser(
1335
description='Run e2e integration tests for Swift SDK')
14-
parser.add_argument('--swift-sdk', default='wasm32-unknown-wasip1',
15-
help='Swift SDK identifier (default: wasm32-unknown-wasi)')
36+
parser.add_argument('--swift-sdk', default=None,
37+
help='Swift SDK identifier (default: wasm32-unknown-wasip1)')
1638
parser.add_argument('args', nargs=argparse.REMAINDER,
1739
help='Extra arguments to pass to lit.py')
1840
options = derive_options_from_args(sys.argv[1:], parser)
@@ -25,11 +47,12 @@ def main():
2547
base_toolchain_path = DownloadBaseSnapshotAction.toolchain_path(options)
2648
lit_py_path = repo_path.parent / "llvm-project" / "llvm" / "utils" / "lit" / "lit.py"
2749
swift_sdks_path = repo_path.parent / "swift-sdk-generator" / "Bundles"
50+
swift_sdk = options.swift_sdk or default_swift_sdk(options, swift_sdks_path)
2851

2952
# Build lit command
3053
lit_cmd = [
3154
str(lit_py_path),
32-
"--param", f"swift-sdk={options.swift_sdk}",
55+
"--param", f"swift-sdk={swift_sdk}",
3356
"--param", f"scheme={options.scheme}",
3457
"--param", f"base-toolchain-path={base_toolchain_path}",
3558
"--param", f"swift-sdks-path={swift_sdks_path}",

0 commit comments

Comments
 (0)