diff --git a/.github/scripts/build-matrix.rb b/.github/scripts/build-matrix.rb index ea95666e..323b14bf 100644 --- a/.github/scripts/build-matrix.rb +++ b/.github/scripts/build-matrix.rb @@ -19,7 +19,6 @@ "build_hello_wasm": true, "clean_build_dir": false, "free_disk_space": true, - "only_swift_sdk": true, }, ] diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index cd971b4d..b8e02083 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -180,26 +180,19 @@ jobs: --security-opt seccomp=unconfined \ -dit \ -e CI=$CI \ - -e ONLY_SWIFT_SDK=${{ matrix.only_swift_sdk }} \ -w /home/build-user/ \ -v ${{ github.workspace }}:/source \ -v oss-swift-package:/home/build-user \ ${{ matrix.container }} docker exec swiftwasm-ci-buildbot /bin/bash -lc 'env; cp -r /source/* /home/build-user/; ./swiftwasm-build/tools/build/ci.sh ${{ matrix.scheme }}' - - name: Extract installable archive from Docker container - if: ${{ matrix.container != null && !matrix.only_swift_sdk }} - run: | - docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-${{ matrix.target }}.tar.gz . - docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-${{ matrix.target }}.artifactbundle.zip . || true - - name: Extract installable archive from Docker container (wasm32-unknown-wasi) - if: ${{ matrix.container != null && matrix.only_swift_sdk }} + if: ${{ matrix.container != null }} run: | docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-wasm32-unknown-wasi.artifactbundle.zip . # release-6.0 doesn't have wasm32-unknown-wasip1-threads SDK support yet - name: Extract installable archive from Docker container (wasm32-unknown-wasip1-threads) - if: ${{ matrix.container != null && matrix.only_swift_sdk && matrix.scheme != 'release-6.0' }} + if: ${{ matrix.container != null && matrix.scheme != 'release-6.0' }} run: | docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-wasm32-unknown-wasip1-threads.artifactbundle.zip . @@ -228,23 +221,13 @@ jobs: name: ${{ matrix.target }}-${{ matrix.scheme }}-installable path: swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-${{ matrix.target }}.tar.gz - - name: Upload ${{ matrix.target }} SDK artifact bundle - uses: actions/upload-artifact@v4 - if: ${{ !matrix.only_swift_sdk }} - with: - name: ${{ matrix.target }}-${{ matrix.scheme }}-artifactbundle - path: swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-${{ matrix.target }}.artifactbundle.zip - if-no-files-found: ignore - - name: Upload Swift SDK artifact bundle (wasm32-unknown-wasi) uses: actions/upload-artifact@v4 - if: ${{ matrix.only_swift_sdk }} with: name: ${{ matrix.scheme }}-wasm32-unknown-wasi-artifactbundle path: swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-wasm32-unknown-wasi.artifactbundle.zip - name: Upload Swift SDK artifact bundle (wasm32-unknown-wasip1-threads) uses: actions/upload-artifact@v4 - if: ${{ matrix.only_swift_sdk }} with: name: ${{ matrix.scheme }}-wasm32-unknown-wasip1-threads-artifactbundle path: swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-wasm32-unknown-wasip1-threads.artifactbundle.zip @@ -270,11 +253,6 @@ jobs: docker exec swiftwasm-ci-buildbot /bin/bash -lc \ "./swiftwasm-build/schemes/${{ matrix.scheme }}/build/run-test.sh" - # We need this step to save disk space for the next steps when building toolchain - - name: Cleanup build directory - if: ${{ matrix.run_stdlib_test && matrix.container != null && !matrix.only_swift_sdk }} - run: docker exec swiftwasm-ci-buildbot /bin/bash -lc "rm -rf build" - - name: Run stdlib tests for wasi-wasm32 if: ${{ matrix.run_stdlib_test && matrix.container == null }} run: ./swiftwasm-build/schemes/${{ matrix.scheme }}/build/run-test.sh @@ -291,7 +269,7 @@ jobs: path: ./swift-test-results.tar.gz - name: Run integration tests (Swift SDK) - if: ${{ matrix.run_e2e_test && matrix.only_swift_sdk }} + if: ${{ matrix.run_e2e_test }} run: | docker exec swiftwasm-ci-buildbot /bin/bash -lc \ "./llvm-project/llvm/utils/lit/lit.py \ @@ -305,32 +283,3 @@ jobs: docker stop swiftwasm-ci-buildbot docker rm swiftwasm-ci-buildbot docker volume rm --force oss-swift-package - - # Run e2e test - - name: Prepare E2E test - if: ${{ !matrix.only_swift_sdk }} - run: | - INSTALL_DIR=$(mktemp -d) - tar xf swift-wasm-${{ matrix.toolchain_channel }}-SNAPSHOT-${{ matrix.target }}.tar.gz -C "$INSTALL_DIR" - echo "TOOLCHAIN=$(find "$INSTALL_DIR" -name "swift-wasm-${{ matrix.toolchain_channel }}-*" -type d | head -n1)" >> $GITHUB_ENV - - name: Build hello.wasm - shell: bash - if: ${{ matrix.build_hello_wasm && !matrix.only_swift_sdk }} - run: | - echo 'print("Hello, world!")' > hello.swift - $TOOLCHAIN/usr/bin/swiftc \ - -target wasm32-unknown-wasi \ - -sdk $TOOLCHAIN/usr/share/wasi-sysroot \ - -resource-dir $TOOLCHAIN/usr/lib/swift_static \ - hello.swift -o hello.wasm && \ - echo "Successfully linked hello.wasm" - - name: Upload hello.wasm - if: ${{ matrix.build_hello_wasm && !matrix.only_swift_sdk && matrix.scheme == 'main' }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.target }}-hello.wasm - path: hello.wasm - - - name: Run integration tests - if: ${{ matrix.run_e2e_test && !matrix.only_swift_sdk }} - run: ${{ github.workspace }}/llvm-project/llvm/utils/lit/lit.py --param package-path=$TOOLCHAIN --param scheme=${{ matrix.scheme }} ${{ github.workspace }}/swiftwasm-build/test -vv diff --git a/test/lit.cfg b/test/lit.cfg index 605abc13..e4ffa1e0 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -23,15 +23,6 @@ config.test_exec_root = lit_config.params.get( config.available_features.add("platform="+platform.system()) config.available_features.add("scheme="+lit_config.params.get("scheme", "main")) -# --param package-path=PATH -package_path = lit_config.params.get("package-path") -if package_path: - package_path = os.path.abspath(package_path) - lit_config.note(f"testing toolchain package: {package_path}") -else: - lit_config.warning("'--param package-path=PATH' is not set, skipping toolchain tests") -config.swift_package_path = package_path - # --param swift-sdk= swift_sdk = lit_config.params.get("swift-sdk") if swift_sdk: diff --git a/test/toolchain/Inputs/clang-module-example/Package.swift b/test/toolchain/Inputs/clang-module-example/Package.swift deleted file mode 100644 index 3f9e9fe3..00000000 --- a/test/toolchain/Inputs/clang-module-example/Package.swift +++ /dev/null @@ -1,11 +0,0 @@ -// swift-tools-version: 5.8 - -import PackageDescription - -let package = Package( - name: "ClangModuleExample", - targets: [ - .executableTarget(name: "Main", dependencies: ["_CModule"]), - .target(name: "_CModule"), - ] -) diff --git a/test/toolchain/Inputs/clang-module-example/Sources/Main/ClangModuleExample.swift b/test/toolchain/Inputs/clang-module-example/Sources/Main/ClangModuleExample.swift deleted file mode 100644 index ff04306d..00000000 --- a/test/toolchain/Inputs/clang-module-example/Sources/Main/ClangModuleExample.swift +++ /dev/null @@ -1 +0,0 @@ -import _CModule diff --git a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/_CModule.c b/test/toolchain/Inputs/clang-module-example/Sources/_CModule/_CModule.c deleted file mode 100644 index 1cf4ec8d..00000000 --- a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/_CModule.c +++ /dev/null @@ -1 +0,0 @@ -#include "_CModule.h" diff --git a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/_CModule.h b/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/_CModule.h deleted file mode 100644 index df556d03..00000000 --- a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/_CModule.h +++ /dev/null @@ -1,4 +0,0 @@ -#include // Clang header should be found -#if __wasi__ -# include // wasi-libc header -#endif diff --git a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/module.modulemap b/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/module.modulemap deleted file mode 100644 index 72fb2c4c..00000000 --- a/test/toolchain/Inputs/clang-module-example/Sources/_CModule/include/module.modulemap +++ /dev/null @@ -1,3 +0,0 @@ -module _CModule { - header "_CModule.h" -} diff --git a/test/toolchain/Inputs/imports.swift b/test/toolchain/Inputs/imports.swift deleted file mode 100644 index 9315ff64..00000000 --- a/test/toolchain/Inputs/imports.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Foundation -import XCTest -import WASILibc - -#if canImport(FoundationXML) - import FoundationXML -#endif -// FIXME: This should be supported on swiftwasm branch -// #if canImport(FoundationNetworking) -// #error("FoundationNetworking should not be able to import now") -// #endif - -public func main() { - _ = Date() - _ = UUID() - _ = URL(string: "https://example.com")! -} diff --git a/test/toolchain/basic.swift b/test/toolchain/basic.swift deleted file mode 100644 index 84a2353a..00000000 --- a/test/toolchain/basic.swift +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %{swiftc} -target wasm32-unknown-wasi -static-stdlib -sdk %{package_path}/usr/share/wasi-sysroot %s -o %t.wasm -// RUN: %{wasm_run} %t.wasm -print("Hello") diff --git a/test/toolchain/clang-module.swift b/test/toolchain/clang-module.swift deleted file mode 100644 index ab2c4c67..00000000 --- a/test/toolchain/clang-module.swift +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{swift} build --package-path %S/Inputs/clang-module-example --scratch-path %t.dir --triple wasm32-unknown-wasi --static-swift-stdlib - -// Skipping this test on main until we include swift-testing in the SDK -// REQUIRES: GH-5587 diff --git a/test/toolchain/foundation/Bundle.swift b/test/toolchain/foundation/Bundle.swift deleted file mode 100644 index c444944f..00000000 --- a/test/toolchain/foundation/Bundle.swift +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{swiftc} -target wasm32-wasi -o %t.dir/check.wasm %s -resource-dir %{package_path}/usr/lib/swift_static -sdk %{package_path}/usr/share/wasi-sysroot -// RUN: %{wasm_run} --dir %t.dir::/tmp --dir %t.dir::/tmp2 %t.dir/check.wasm | %{FileCheck} %s -// REQUIRES: FileCheck && scheme=main - -import Foundation - -// Bundle.main is derived from the path of the executable and cwd -// CHECK: bundlePath: /tmp -chdir("/tmp") -print("bundlePath:", Bundle.main.bundlePath) - -// CHECK: Bundle(path:).bundlePath: /tmp2 -print("Bundle(path:).bundlePath:", Bundle(path: "/tmp2")?.bundlePath ?? "nil") diff --git a/test/toolchain/foundation/FileManager.swift b/test/toolchain/foundation/FileManager.swift deleted file mode 100644 index 4b480a7d..00000000 --- a/test/toolchain/foundation/FileManager.swift +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %{swiftc} -target wasm32-wasi -o %t.wasm %s -resource-dir %{package_path}/usr/lib/swift_static -sdk %{package_path}/usr/share/wasi-sysroot -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{wasm_run} --dir %t.dir::/tmp --dir %S/Inputs::/Inputs %t.wasm | %{FileCheck} %s -// REQUIRES: FileCheck && scheme=main - -import Foundation - -// CHECK: cwd: / -print("cwd: \(FileManager.default.currentDirectoryPath)") -// CHECK: chdir: true -let chdirResult = FileManager.default.changeCurrentDirectoryPath("/tmp") -print("chdir: \(chdirResult)") -// CHECK: cwd: /tmp -print("cwd: \(FileManager.default.currentDirectoryPath)") - -// CHECK: homeDirectory: nil -print("homeDirectory: \(FileManager.default.homeDirectory(forUser: "nobody")?.absoluteString ?? "nil")") - -// CHECK: temporaryDirectory: file:///tmp/ -print("temporaryDirectory: \(FileManager.default.temporaryDirectory)") - -// CHECK: contentsOfDirectory(/Inputs): ["check.dir", "empty.txt", "hello.txt"] -print("contentsOfDirectory(/Inputs): \(try! FileManager.default.contentsOfDirectory(atPath: "/Inputs").sorted())") -// CHECK: contentsOfDirectory(/Inputs/check.dir): ["check0.txt", "check1.txt"] -print("contentsOfDirectory(/Inputs/check.dir): \(try! FileManager.default.contentsOfDirectory(atPath: "/Inputs/check.dir").sorted())") - -// CHECK: Data(contentsOf: /Inputs/hello.txt): 6 bytes -print("Data(contentsOf: /Inputs/hello.txt): \(try! Data(contentsOf: URL(fileURLWithPath: "/Inputs/hello.txt")))") -// CHECK: String(contentsOf: /Inputs/hello.txt): world -print("String(contentsOf: /Inputs/hello.txt): \(try! String(contentsOf: URL(fileURLWithPath: "/Inputs/hello.txt")))") - -// CHECK: mountedVolumeURLs: ["/Inputs", "/tmp"] -print("mountedVolumeURLs: \(FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys:[], options: [])?.map { $0.path }.sorted() ?? [])") diff --git a/test/toolchain/foundation/Inputs/check.dir/check0.txt b/test/toolchain/foundation/Inputs/check.dir/check0.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/test/toolchain/foundation/Inputs/check.dir/check1.txt b/test/toolchain/foundation/Inputs/check.dir/check1.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/test/toolchain/foundation/Inputs/empty.txt b/test/toolchain/foundation/Inputs/empty.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/test/toolchain/foundation/Inputs/hello.txt b/test/toolchain/foundation/Inputs/hello.txt deleted file mode 100644 index cc628ccd..00000000 --- a/test/toolchain/foundation/Inputs/hello.txt +++ /dev/null @@ -1 +0,0 @@ -world diff --git a/test/toolchain/foundation/ProcessInfo.swift b/test/toolchain/foundation/ProcessInfo.swift deleted file mode 100644 index 8eeca6ee..00000000 --- a/test/toolchain/foundation/ProcessInfo.swift +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{swiftc} -target wasm32-wasi -o %t.dir/check.wasm %s -resource-dir %{package_path}/usr/lib/swift_static -sdk %{package_path}/usr/share/wasi-sysroot -// RUN: %{wasm_run} --dir %t.dir::/tmp %t.dir/check.wasm | %{FileCheck} %s -// REQUIRES: FileCheck && scheme=main - -import Foundation - -// CHECK: processName: check.wasm -print("processName: " + ProcessInfo.processInfo.processName) - -// CHECK: hostname: localhost -print("hostname: " + ProcessInfo.processInfo.hostName) diff --git a/test/toolchain/foundation/XML.swift b/test/toolchain/foundation/XML.swift deleted file mode 100644 index b9cede11..00000000 --- a/test/toolchain/foundation/XML.swift +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{swiftc} -target wasm32-wasi -o %t.dir/check.wasm %s -resource-dir %{package_path}/usr/lib/swift_static -sdk %{package_path}/usr/share/wasi-sysroot -// RUN: %{wasm_run} %t.dir/check.wasm | %{FileCheck} %s -// REQUIRES: FileCheck - -import FoundationXML - -let xml = """ - - Tove - Jani - Reminder - Don't forget me this weekend! - -""" - -let xmlData = xml.data(using: .utf8)! -let document = try XMLDocument(data: xmlData) - -let to = try document.nodes(forXPath: "/note/to").first?.stringValue -// CHECK: to: Tove -print("to: \(to!)") diff --git a/test/toolchain/import-system-modules.swift b/test/toolchain/import-system-modules.swift deleted file mode 100644 index 7163fe96..00000000 --- a/test/toolchain/import-system-modules.swift +++ /dev/null @@ -1,2 +0,0 @@ -// RUN: %{swiftc} -resource-dir %{package_path}/usr/lib/swift_static -target wasm32-wasi %S/Inputs/imports.swift -sdk %{package_path}/usr/share/wasi-sysroot -static-stdlib -o %t.wasm -// RUN: %{wasm_run} %t.wasm diff --git a/test/toolchain/lit.local.cfg b/test/toolchain/lit.local.cfg deleted file mode 100644 index 4e97f498..00000000 --- a/test/toolchain/lit.local.cfg +++ /dev/null @@ -1,11 +0,0 @@ -import os - -if not config.root.swift_package_path: - config.unsupported = True -else: - bin_path = os.path.join(config.root.swift_package_path, "usr", "bin") - - for tool in ["swift", "swiftc"]: - config.substitutions.append(("%{" + tool + "}", os.path.join(bin_path, tool))) - - config.substitutions.append(("%{package_path}", config.root.swift_package_path)) diff --git a/test/toolchain/swiftpm-build.swift b/test/toolchain/swiftpm-build.swift deleted file mode 100755 index ce5d1360..00000000 --- a/test/toolchain/swiftpm-build.swift +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t.dir -// RUN: mkdir -p %t.dir -// RUN: %{swift} package init --package-path %t.dir --name Example -// RUN: cp %S/Inputs/imports.swift %t.dir/Sources/Example/Imports.swift -// RUN: %{swift} build --package-path %t.dir --triple wasm32-unknown-wasi -Xswiftc -static-stdlib -Xswiftc -resource-dir -Xswiftc %{package_path}/usr/lib/swift_static diff --git a/test/toolchain/swiftpm-test.test b/test/toolchain/swiftpm-test.test deleted file mode 100644 index d40e8346..00000000 --- a/test/toolchain/swiftpm-test.test +++ /dev/null @@ -1,12 +0,0 @@ -REQUIRES: FileCheck -# Skipping this test on main until we include swift-testing in the SDK -REQUIRES: GH-5587 - -RUN: rm -rf %t.dir -RUN: mkdir -p %t.dir -RUN: %{swift} package init --package-path %t.dir --name Example -RUN: %{swift} build --package-path %t.dir --triple wasm32-unknown-wasi --build-tests -Xswiftc -resource-dir -Xswiftc %{package_path}/usr/lib/swift_static -RUN: %{wasm_run} --dir . %t.dir/.build/debug/ExamplePackageTests.wasm | %{FileCheck} %s - -CHECK: Test Suite 'All tests' passed at -CHECK: Executed 1 test, with 0 failures (0 unexpected) in diff --git a/tools/build/ci.sh b/tools/build/ci.sh index 78f2673a..f75c44d9 100755 --- a/tools/build/ci.sh +++ b/tools/build/ci.sh @@ -36,8 +36,4 @@ export PATH="$SCCACHE_INSTALL_PATH:$PATH" $TOOLS_BUILD_PATH/build-toolchain.sh "$SCHEME" -if [ "$ONLY_SWIFT_SDK" = "true" ]; then - $TOOLS_BUILD_PATH/package-toolchain --scheme "$SCHEME" --daily-snapshot --only-swift-sdk -else - $TOOLS_BUILD_PATH/package-toolchain --scheme "$SCHEME" --daily-snapshot -fi +$TOOLS_BUILD_PATH/package-toolchain --scheme "$SCHEME" --daily-snapshot diff --git a/tools/build/package-toolchain b/tools/build/package-toolchain index adb32013..6feb7a5d 100755 --- a/tools/build/package-toolchain +++ b/tools/build/package-toolchain @@ -9,7 +9,6 @@ import re from typing import Optional from build_support.actions import Action, ActionRunner, DownloadBaseSnapshotAction, derive_options_from_args from build_support.platform import PlatformInfo -from build_support.llvm_tools import WASM_SPECIFIC_TOOLS_TO_INSTALL class SnapshotInfo: @@ -77,127 +76,6 @@ def copy_libxml2_libs(build_sdk_path, dist_toolchain_path, target_triple): shutil.copy(os.path.join(lib_dir, lib), dest_path) -class PackageAction(Action): - def __init__(self, options, snapshot_info: SnapshotInfo): - super().__init__(options) - self.snapshot_info = snapshot_info - self.target_triple = "wasm32-unknown-wasi" - - def run(self): - import shutil - print('=====> Packaging toolchain {}'.format(self.snapshot_info.toolchain_name)) - packaging_dir = os.path.join('..', 'build', 'Packaging') - base_toolchain_path = os.path.join(packaging_dir, 'base-snapshot') - target_toolchain_path = os.path.join( - packaging_dir, 'target-toolchain', self.target_triple) - dist_toolchain_path = os.path.join(packaging_dir, 'dist-toolchain', self.snapshot_info.toolchain_name) - llvm_toolchain_path = os.path.join(packaging_dir, 'llvm-toolchain') - llvm_tools_path = os.path.join('..', 'build', 'llvm-tools') - build_sdk_path = os.path.join('..', 'build-sdk') - - shutil.rmtree(os.path.dirname(dist_toolchain_path), ignore_errors=True) - os.makedirs(dist_toolchain_path, exist_ok=True) - print(f"=====> Copying base snapshot {base_toolchain_path} to {dist_toolchain_path}") - self.rsync("-a", base_toolchain_path + "/", dist_toolchain_path) - - copy_icu_libs(self.options.scheme, build_sdk_path, target_toolchain_path, self.target_triple) - copy_libxml2_libs(build_sdk_path, target_toolchain_path, self.target_triple) - # Copying target stdlib to dist toolchain, and cross compiler if - # host compiler is built with patches by ourselves. - print(f"=====> Copying target toolchain {target_toolchain_path} to {dist_toolchain_path}") - self.rsync("-a", target_toolchain_path + "/", dist_toolchain_path) - - self.install_extra_llvm_tools(llvm_tools_path, base_toolchain_path, dist_toolchain_path) - - # FIXME: We now support only legacy driver because the new swift-driver doesn't have hacks for default - # -sdk and forcing -use-static-resource-dir (-static-executable). - # e.g. - # The canonical way to build a static executable is to use -static-executable and specify -sdk because - # we don't have good concensus for the wasi-sysroot layout and the driver should not assume the SDK path. - # $ echo | ./usr/bin/swiftc -target wasm32-unknown-wasi -o /dev/null - -static-executable -sdk ./usr/share/wasi-sysroot - # But we don't want to force users to specify -sdk, so we have a hack in the legacy driver to assume - # the SDK path and pass -static-executable (effectively -use-static-resource-dir). - # $ echo | ./usr/bin/swiftc -target wasm32-unknown-wasi -o /dev/null - - # The new swift-driver doesn't have this hack, so we remove swift-driver from the toolchain for now. - swift_driver_path = os.path.join(dist_toolchain_path, 'usr', 'bin', 'swift-driver') - if os.path.exists(swift_driver_path) and \ - (self.options.scheme == 'release-5.9' or \ - self.options.scheme == 'release-5.10'): - os.remove(swift_driver_path) - - # Select wasi-sysroot - wasi_sysroot_path = derive_wasi_sysroot(self.options, packaging_dir, 'wasm32-wasi') - print("=====> Using wasi-sysroot from {}".format(wasi_sysroot_path)) - - # Now dist toolchain always has cross compiler regardless of whether - # host compiler is built by ourselves or just downloaded from swift.org - if self.options.scheme in ['release-5.9', 'release-5.10']: - # We still need to distribute custom built cross compiler tools - # for 5.9 and 5.10. - self.make_swift_sdk( - base_toolchain_path, - dist_toolchain_path, - target_toolchain_path, - wasi_sysroot_path, - self.snapshot_info.swift_sdk_name) - - shutil.copytree(wasi_sysroot_path, os.path.join(dist_toolchain_path, 'usr', 'share', 'wasi-sysroot')) - - def rsync(self, *args): - import subprocess - args = ['rsync'] + list(args) - if self.options.dry_run: - print(' '.join(args)) - return - subprocess.check_call(args) - - def install_extra_llvm_tools(self, llvm_tools_path, base_toolchain_path, dist_toolchain_path): - import shutil - print(f"=====> Installing extra LLVM tools") - llvm_tools_bin_dir = os.path.join(llvm_tools_path, 'bin') - install_bin_dir = os.path.join(dist_toolchain_path, 'usr', 'bin') - os.makedirs(install_bin_dir, exist_ok=True) - for tool_name in WASM_SPECIFIC_TOOLS_TO_INSTALL: - # Skip installing if the tool already exists - if os.path.exists(os.path.join(base_toolchain_path, 'usr', 'bin', tool_name)): - continue - - tool_path = os.path.join(llvm_tools_bin_dir, tool_name) - if os.path.islink(tool_path) and \ - os.path.dirname(os.readlink(tool_path)) != "": - # Copy the tool with following the symlink if it points to a file - # that does not beside the symlink - print(f"Copying {tool_path} to {install_bin_dir} (following symlink)") - shutil.copy(tool_path, install_bin_dir, follow_symlinks=True) - else: - # Copy the tool while preserving the symlink - print(f"Copying {tool_path} to {install_bin_dir}") - shutil.copy(tool_path, install_bin_dir, follow_symlinks=False) - - # If it's a symlink, copy the direct symlink target too - if os.path.islink(tool_path): - target = os.readlink(tool_path) - if os.path.exists(os.path.join(install_bin_dir, target)): - continue - target_path = os.path.join(llvm_tools_bin_dir, target) - print(f"Copying {target_path} to {install_bin_dir} (target of {tool_path})") - shutil.copy(target_path, install_bin_dir, follow_symlinks=False) - - def make_swift_sdk( - self, - base_toolchain_path: str, - host_toolchain_path: Optional[str], - target_toolchain_path: str, - wasi_sysroot_path: str, - swift_sdk_name: str, - ): - underlying = PackageSwiftSDKAction( - self.options, self.snapshot_info, base_toolchain_path, - host_toolchain_path, target_toolchain_path, wasi_sysroot_path, - swift_sdk_name, self.target_triple) - underlying.run() - - class PackageSwiftSDKAction(Action): def __init__( self, options, snapshot_info: SnapshotInfo, @@ -316,64 +194,6 @@ class PackageSwiftSDKAction(Action): return info["target"]["triple"] -class DarwinInfoPlistAction(Action): - - def __init__(self, options, snapshot_info: SnapshotInfo): - super().__init__(options) - self.snapshot_info = snapshot_info - - def run(self): - print('=====> Creating Info.plist') - - bundle_prefix="org.swiftwasm" - swift_version = self.swift_version() - darwin_toolchain_display_name_short="Swift for WebAssembly Snapshot" - - year, month, day = self.snapshot_info.year, self.snapshot_info.month, self.snapshot_info.day - if self.snapshot_info.daily_snapshot: - darwin_toolchain_version=f"{swift_version}.{year}{month}{day}" - darwin_toolchain_bundle_identifier=f"{bundle_prefix}.{year}{month}{day}" - darwin_toolchain_display_name=f"{darwin_toolchain_display_name_short} {year}-{month}-{day} (a)" - else: - darwin_toolchain_version=f"{swift_version}.9999" - darwin_toolchain_bundle_identifier=f"{bundle_prefix}.dev" - darwin_toolchain_display_name=f"{darwin_toolchain_display_name_short} Development" - - darwin_toolchain_alias="swiftwasm" - darwin_toolchain_report_url="https://github.com/swiftwasm/swift/issues" - - plist_path = f"../build/Packaging/dist-toolchain/{self.snapshot_info.toolchain_name}/Info.plist" - self.plistbuddy("-c", f"Set DisplayName {darwin_toolchain_display_name}", plist_path) - self.plistbuddy("-c", f"Set ShortDisplayName {darwin_toolchain_display_name_short}", plist_path) - self.plistbuddy("-c", f"Set Version {darwin_toolchain_version}", plist_path) - self.plistbuddy("-c", f"Set CFBundleIdentifier {darwin_toolchain_bundle_identifier}", plist_path) - self.plistbuddy("-c", f"Set ReportProblemURL {darwin_toolchain_report_url}", plist_path) - self.plistbuddy("-c", f"Set Aliases:0 {darwin_toolchain_alias}", plist_path) - - def plistbuddy(self, *args): - import subprocess - return subprocess.check_output(['/usr/libexec/PlistBuddy'] + list(args)) - - def swift_version(self): - version = self.plistbuddy("-c", "Print Version", os.path.join("..", "build", "Packaging", "base-snapshot", "Info.plist")) - version = version.decode("utf-8").strip() - # Get only the major and minor version - return ".".join(version.split(".")[:2]) - -class ArchiveTarballAction(Action): - - def __init__(self, options, snapshot_info: SnapshotInfo): - super().__init__(options) - self.snapshot_info = snapshot_info - - def run(self): - tarball_path = os.path.join("..", self.snapshot_info.tarball_name) - print(f"=====> Creating tarball at {tarball_path}") - - dist_toolchain_dir = os.path.join("..", "build", "Packaging", "dist-toolchain") - self.system("tar", "-C", dist_toolchain_dir, "-czf", tarball_path, self.snapshot_info.toolchain_name) - - class CleanBuildArtifactAction(Action): def run(self): import shutil @@ -444,7 +264,6 @@ def derive_date_suffix_from_base_tag(tag: str) -> datetime.datetime: def main(): parser = argparse.ArgumentParser(description='A script to create a workspace for a Swift project applying patches') parser.add_argument("--daily-snapshot", action="store_true", help="Create a daily snapshot") - parser.add_argument("--only-swift-sdk", action="store_true", help="Create only Swift SDK") options = derive_options_from_args(sys.argv[1:], parser) now = derive_date_suffix_from_base_tag(options.tag) actions = [] @@ -453,44 +272,37 @@ def main(): actions.append(DownloadBaseSnapshotAction(options)) - if not options.only_swift_sdk: - snapshot_info = derive_snapshot_info(options.daily_snapshot, options.scheme, now) - actions.append(PackageAction(options, snapshot_info)) + packaging_dir = os.path.join( + os.path.dirname(__file__), '..', '..', '..', 'build', 'Packaging') - if os.uname().sysname == "Darwin": - actions.append(DarwinInfoPlistAction(options, snapshot_info)) - actions.append(ArchiveTarballAction(options, snapshot_info)) - else: - packaging_dir = os.path.join( - os.path.dirname(__file__), '..', '..', '..', 'build', 'Packaging') - - toolchain_channel = derive_toolchain_channel(options.scheme) - triples = [ - ["wasm32-unknown-wasi", "wasm32-wasi"], + toolchain_channel = derive_toolchain_channel(options.scheme) + triples = [ + ["wasm32-unknown-wasi", "wasm32-wasi"], + ] + if options.scheme not in ["release-6.0"]: + triples += [ + ["wasm32-unknown-wasip1-threads", "wasm32-wasip1-threads"] ] - if options.scheme not in ["release-6.0"]: - triples += [ - ["wasm32-unknown-wasip1-threads", "wasm32-wasip1-threads"] - ] - for target_triple, short_triple in triples: - snapshot_info = SnapshotInfo( - now.year, now.month, now.day, - swift_version=derive_swift_version( - options.daily_snapshot, toolchain_channel, now), - artifact_name=f"swift-wasm-{toolchain_channel}-SNAPSHOT-{target_triple}", - daily_snapshot=options.daily_snapshot - ) - actions.append(PackageSwiftSDKAction( - options, snapshot_info, - base_toolchain_path=os.path.join(packaging_dir, 'base-snapshot'), - host_toolchain_path=None, - target_toolchain_path=os.path.join(packaging_dir, 'target-toolchain', target_triple), - wasi_sysroot_path=derive_wasi_sysroot(options, packaging_dir, short_triple), - swift_sdk_name=f"{snapshot_info.swift_version}-{target_triple}", - target_triple=target_triple, - )) + for target_triple, short_triple in triples: + snapshot_info = SnapshotInfo( + now.year, now.month, now.day, + swift_version=derive_swift_version( + options.daily_snapshot, toolchain_channel, now), + artifact_name=f"swift-wasm-{toolchain_channel}-SNAPSHOT-{target_triple}", + daily_snapshot=options.daily_snapshot + ) + actions.append(PackageSwiftSDKAction( + options, snapshot_info, + base_toolchain_path=os.path.join(packaging_dir, 'base-snapshot'), + host_toolchain_path=None, + target_toolchain_path=os.path.join(packaging_dir, 'target-toolchain', target_triple), + wasi_sysroot_path=derive_wasi_sysroot(options, packaging_dir, short_triple), + swift_sdk_name=f"{snapshot_info.swift_version}-{target_triple}", + target_triple=target_triple, + )) ActionRunner(actions).run() + if __name__ == '__main__': main() diff --git a/tools/gh-distribute-toolchain b/tools/gh-distribute-toolchain index 2c6dd07a..5f8d42f9 100755 --- a/tools/gh-distribute-toolchain +++ b/tools/gh-distribute-toolchain @@ -8,7 +8,6 @@ import os import sys import subprocess -import tarfile import asyncio import json from dataclasses import dataclass @@ -21,11 +20,6 @@ USER_AGENT = "gh-distribute-toolchain by swiftwasm/swiftwasm-build" @dataclass class Secrets: - DARWIN_TOOLCHAIN_APPLICATION_CERT: str - DARWIN_TOOLCHAIN_INSTALLER_CERT: str - DARWIN_TOOLCHAIN_NOTARIZE_EMAIL: str - DARWIN_TOOLCHAIN_NOTARIZE_TEAM_ID: str - DARWIN_TOOLCHAIN_NOTARIZE_PASSWORD: str GITHUB_TOKEN: str @staticmethod @@ -40,16 +34,6 @@ class Secrets: github_token = result.stdout.decode("utf-8").strip() return Secrets( - DARWIN_TOOLCHAIN_APPLICATION_CERT=Secrets.env_value( - "DARWIN_TOOLCHAIN_APPLICATION_CERT"), - DARWIN_TOOLCHAIN_INSTALLER_CERT=Secrets.env_value( - "DARWIN_TOOLCHAIN_INSTALLER_CERT"), - DARWIN_TOOLCHAIN_NOTARIZE_EMAIL=Secrets.env_value( - "DARWIN_TOOLCHAIN_NOTARIZE_EMAIL"), - DARWIN_TOOLCHAIN_NOTARIZE_TEAM_ID=Secrets.env_value( - "DARWIN_TOOLCHAIN_NOTARIZE_TEAM_ID"), - DARWIN_TOOLCHAIN_NOTARIZE_PASSWORD=Secrets.env_value( - "DARWIN_TOOLCHAIN_NOTARIZE_PASSWORD"), GITHUB_TOKEN=github_token, ) @@ -58,130 +42,6 @@ class Secrets: return os.environ.get(key) -class DarwinToolchainPackaging: - def __init__(self, secrets: Secrets, - dry_run: bool = False, verbose: bool = False): - self.secrets = secrets - self.dry_run = dry_run - self.verbose = verbose - - async def package(self, toolchain_dir: str, tag_name: str, pkg_path: str, - swift_source_dir: str): - self.update_info_plist(toolchain_dir) - self.sign_darwin_toolchain(toolchain_dir) - await self.create_installer(toolchain_dir, pkg_path, tag_name, swift_source_dir) - - def update_info_plist(self, toolchain_dir: str): - display_name = os.environ.get("DARWIN_TOOLCHAIN_DISPLAY_NAME") - info_plist = f"{toolchain_dir}/Info.plist" - if display_name: - subprocess.check_output([ - "/usr/libexec/PlistBuddy", - "-c", f"Set DisplayName {display_name}", info_plist - ]) - - display_name_short = os.environ.get( - "DARWIN_TOOLCHAIN_DISPLAY_NAME_SHORT") - if display_name_short: - subprocess.check_output([ - "/usr/libexec/PlistBuddy", - "-c", f"Set ShortDisplayName {display_name_short}", info_plist - ]) - - def sign_darwin_toolchain(self, toolchain_dir: str): - if self.secrets.DARWIN_TOOLCHAIN_APPLICATION_CERT is None: - raise Exception("Missing DARWIN_TOOLCHAIN_APPLICATION_CERT") - - codesign_args = [ - "/usr/bin/codesign", - "--force", "--verify", "--verbose", "--deep", - "--options", "runtime", "--timestamp", - "--sign", self.secrets.DARWIN_TOOLCHAIN_APPLICATION_CERT - ] - - for root, dirs, files in os.walk(toolchain_dir): - for file in files: - path = os.path.join(root, file) - if not self.is_macho_binary(path): - continue - self.subprocess_run(codesign_args + [path], check=True) - - self.subprocess_run(codesign_args + [toolchain_dir], check=True) - - async def create_installer(self, toolchain_dir: str, pkg_path: str, - tag_name: str, swift_source_dir: str): - toolchain_name = tag_name - toolchain_installer_package = pkg_path - toolchain_install_location = ( - f"/Library/Developer/Toolchains/{toolchain_name}.xctoolchain") - toolchain_version = subprocess.check_output([ - "/usr/libexec/PlistBuddy", - "-c", "Print Version string", - f"{toolchain_dir}/Info.plist" - ]).decode("utf-8") - toolchain_bundle_identifier = subprocess.check_output([ - "/usr/libexec/PlistBuddy", - "-c", "Print CFBundleIdentifier string", - f"{toolchain_dir}/Info.plist" - ]).decode("utf-8") - - self.subprocess_run([ - f"{swift_source_dir}/utils/toolchain-installer", toolchain_dir, - toolchain_bundle_identifier, - self.secrets.DARWIN_TOOLCHAIN_INSTALLER_CERT, - toolchain_installer_package, - toolchain_install_location, - toolchain_version, - f"{swift_source_dir}/utils/darwin-installer-scripts" - ], check=True) - - await self.check_async_subprocess( - "xcrun", "notarytool", "submit", - toolchain_installer_package, - "--wait", - "--apple-id", self.secrets.DARWIN_TOOLCHAIN_NOTARIZE_EMAIL, - "--team-id", self.secrets.DARWIN_TOOLCHAIN_NOTARIZE_TEAM_ID, - "--password", self.secrets.DARWIN_TOOLCHAIN_NOTARIZE_PASSWORD) - - self.subprocess_run(["xcrun", "stapler", "staple", - toolchain_installer_package], check=True) - - def subprocess_run(self, args, **kwargs): - """ - Run a non-mutating subprocess and print the command if - verbose or dry_run is True. - """ - if self.verbose or self.dry_run: - print(" ".join(args)) - return subprocess.run(args, **kwargs) - - async def check_async_subprocess(self, program, *args): - if self.verbose or self.dry_run: - print(f"[async] {program} {' '.join(args)}") - if self.dry_run: - return - proc = await asyncio.subprocess.create_subprocess_exec(program, *args) - retcode = await proc.wait() - if retcode != 0: - raise Exception(f"Failed to execute: {' '.join(args)}") - - def is_macho_binary(self, file_path): - if not os.path.exists(file_path): - return False - magic_bytes = None - with open(file_path, mode="rb") as f: - magic_bytes = f.read(4) - macho_bytes = [ - [0xca, 0xfe, 0xba, 0xbe], # Mach-O Fat Binary - [0xcf, 0xfa, 0xed, 0xfe], # Mach-O 64-bit executable - [0xce, 0xfa, 0xed, 0xfe], # Mach-O 32-bit executable - ] - for b in macho_bytes: - if magic_bytes == bytes(b): - return True - return False - - class GitHub: def __init__(self, token: str, repo: str = "swiftwasm/swiftwasm-build"): self.token = token @@ -348,13 +208,14 @@ class Distribution: async def run(self, options): downloads = [] for artifact in self.toolchain_artifacts(options): - if options.only_swift_sdk: - if not artifact["name"].endswith("-artifactbundle"): - print(f"Skipping {artifact['name']} because it's not an" - " artifactbundle for --only-swift-sdk") - continue + if not artifact["name"].endswith("-artifactbundle"): + print(f"Skipping {artifact['name']} because it's not an" + " artifactbundle for --only-swift-sdk") + continue + _, scheme, _ = derive_platform_suffix_and_scheme( artifact["name"], options.scheme) + if options.scheme != scheme: print(f"Skipping {artifact['name']} because it's not scheme {options.scheme}") # Skip unrelated artifact @@ -388,22 +249,16 @@ class Distribution: # Create tag and release on GitHub if not tag_name: for artifact, artifact_path in downloaded_paths: - if artifact["name"].endswith("-installable"): - artifact_path = self.unpack_toolchain(artifact_path) - tag_name = self.guess_tag_name(artifact_path) - break - elif artifact["name"].endswith("-artifactbundle"): - platform_suffix, _, target_triple = derive_platform_suffix_and_scheme( - artifact["name"], options.scheme) - bundle_path = await self.unpack_artifactbundle(artifact_path) - dirents = os.listdir(bundle_path) - dirents.remove("info.json") - sdk_artifact_id = dirents[0] - if not platform_suffix: - tag_name = "swift-wasm-" + sdk_artifact_id.removesuffix("-" + target_triple) - else: - tag_name = "swift-wasm-" + sdk_artifact_id.removesuffix("-wasm") - break + if not artifact["name"].endswith("-artifactbundle"): + continue + platform_suffix, _, target_triple = derive_platform_suffix_and_scheme( + artifact["name"], options.scheme) + bundle_path = await self.unpack_artifactbundle(artifact_path) + dirents = os.listdir(bundle_path) + dirents.remove("info.json") + sdk_artifact_id = dirents[0] + tag_name = "swift-wasm-" + sdk_artifact_id.removesuffix("-" + target_triple) + break if not tag_name: raise Exception("Could not determine tag name") @@ -425,10 +280,7 @@ class Distribution: artifact, artifact_path = downloaded platform_suffix, scheme, target_triple = derive_platform_suffix_and_scheme( artifact["name"], options.scheme) - if not platform_suffix: - artifact_format = SDKArtifactFormatV3(target_triple) - else: - artifact_format = SDKArtifactFormatV2(platform_suffix) + artifact_format = SDKArtifactFormatV3(target_triple) bundle_path = await self.unpack_artifactbundle(artifact_path) package = await self.package_artifactbundle( bundle_path, tag_name, artifact_format) @@ -462,73 +314,6 @@ class Distribution: self.update_release_notes_with_checksums( release, swift_version, swiftwasm_build_version) - if options.only_swift_sdk: - return - - # Package and upload toolchains - for artifact, artifact_path in downloaded_paths: - import shutil - if not artifact["name"].endswith("-installable"): - continue - - platform_suffix, _, _ = derive_platform_suffix_and_scheme( - artifact["name"], options.scheme) - artifact_path = self.unpack_toolchain(artifact_path) - package, artifact_path = await self.package_toolchain( - artifact_path, tag_name, platform_suffix) - if options.dry_run: - print(f"Skip uploading actual artifact \"{package}\"") - continue - self.upload_to_release(package, release) - if options.optimize_disk_footprint: - print(f"Removing {artifact_path} to optimize disk footprint") - shutil.rmtree(artifact_path) - - def guess_tag_name(self, path): - return os.path.basename(path) - - async def package_toolchain(self, artifact_path: str, tag_name: str, - platform_suffix: str): - print(f"Packaging {artifact_path}") - import shutil - dest_dir = os.path.dirname(artifact_path) - artifacts_path = os.path.dirname(dest_dir) - - if os.path.basename(artifact_path) != tag_name: - # e.g. - # dest_dir: - # /swift-wasm-DEVELOPMENT-SNAPSHOT-amazonlinux2_x86_64 - # artifact_path: - # /swift-wasm-DEVELOPMENT-SNAPSHOT-2023-6-25-a - # dest_path: - # /swift-wasm-DEVELOPMENT-SNAPSHOT-2023-6-25-b - print(f"Re-package {artifact_path} as {tag_name}") - dest_path = os.path.join(dest_dir, tag_name) - shutil.rmtree(dest_path, ignore_errors=True) - shutil.move(artifact_path, dest_path) - artifact_path = dest_path - - if platform_suffix.startswith("macos_"): - pkg_path = os.path.join( - artifacts_path, f"{tag_name}-{platform_suffix}.pkg") - if os.path.exists(pkg_path): - return [pkg_path, artifact_path] - swift_source_dir = os.path.join(self.checkout_dir, "swift") - await DarwinToolchainPackaging( - self.secrets, self.dry_run, self.verbose - ).package(artifact_path, tag_name, pkg_path, swift_source_dir) - return [pkg_path, artifact_path] - else: - tarball_path = os.path.join( - artifacts_path, f"{tag_name}-{platform_suffix}.tar.gz") - if os.path.exists(tarball_path): - return [tarball_path, artifact_path] - tar_args = ["tar", "cfz", tarball_path, - "-C", os.path.dirname(artifact_path), - os.path.basename(artifact_path)] - self.subprocess_run(tar_args, check=True) - return [tarball_path, artifact_path] - async def package_artifactbundle( self, artifact_path: str, tag_name: str, artifact_format: SDKArtifactFormat @@ -624,29 +409,6 @@ class Distribution: "unzip", "-q", bundlezip_path, "-d", os.path.dirname(bundle_path)) return bundle_path - def unpack_toolchain(self, zip_tarball): - tarball_name, tarball_path = self.unzip_artifact(zip_tarball) - - # Remove the .tar.gz extension - tarball_basename = os.path.splitext( - os.path.splitext(tarball_name)[0])[0] - tarball_output_dir = os.path.join( - os.path.dirname(tarball_path), tarball_basename) - if not os.path.exists(tarball_output_dir): - os.makedirs(tarball_output_dir, exist_ok=True) - print(f"Extracting {tarball_path}...") - with tarfile.open(tarball_path, "r:gz") as tar: - tar.extractall(tarball_output_dir) - else: - print(f"Tarball already extracted at {tarball_output_dir}") - - dirents = os.listdir(tarball_output_dir) - if len(dirents) != 1: - raise Exception(( - f"Unexpected number of files in {tarball_output_dir}:" - f" {len(dirents)} (expected 1)")) - return os.path.join(tarball_output_dir, dirents[0]) - async def download_artifact(self, artifact): if not os.path.exists(self.artifacts_dir): os.makedirs(self.artifacts_dir, exist_ok=True) @@ -785,8 +547,7 @@ You can install Swift SDKs for WebAssembly using the following commands: artifacts = self.github.list_artifacts(self.run_id) for artifact in artifacts: artifact_name = artifact["name"] - should_yield = artifact_name.endswith("-artifactbundle") or \ - artifact_name.endswith("-installable") + should_yield = artifact_name.endswith("-artifactbundle") if should_yield: yield artifact @@ -830,18 +591,12 @@ def derive_platform_suffix_and_scheme( e.g. "main-wasm32-unknown-wasi-artifactbundle", scheme="main" -> [None, "main", "wasm32-unknown-wasi"] - "macos_x86_64-main-artifactbundle", scheme="main" - -> ["macos_x86_64", "main", "wasm32-unknown-wasi"] - "ubuntu22.04_x86_64-installable", scheme="main" - -> ["ubuntu22.04_x86_64", "main", "wasm32-unknown-wasi"] """ # v3 artifact name: --artifactbundle - # v2 artifact name: --(installable|artifactbundle) - # v1 artifact name: -installable # Note that can contain '-'. name: str = artifact_name - artifact_suffixes = ("-installable", "-artifactbundle") + artifact_suffixes = ("-artifactbundle") if not name.endswith(artifact_suffixes): raise Exception((f"Unexpected artifact name {name}" f", expected to have one of \"{artifact_suffixes}\"" @@ -857,14 +612,6 @@ def derive_platform_suffix_and_scheme( target_triple = rest[:-len("-artifactbundle")] return [None, target_scheme, target_triple] - components = name.split("-") - if len(components) >= 3: - scheme = "-".join(components[1:-1]) - return [components[0], scheme, "wasm32-unknown-wasi"] - else: - # Assume legacy representation only used for the main scheme - return [components[0], "main", "wasm32-unknown-wasi"] - def latest_success_run_id(gh: GitHub, workflow_name: str, branch: str, scheme: str): """ @@ -879,7 +626,7 @@ def latest_success_run_id(gh: GitHub, workflow_name: str, branch: str, scheme: s artifacts = gh.list_artifacts(run["id"]) for artifact in artifacts: artifact_name = artifact["name"] - if not artifact_name.endswith("-installable") and not artifact_name.endswith("-artifactbundle"): + if not artifact_name.endswith("-artifactbundle"): continue _, artifact_scheme, _ = derive_platform_suffix_and_scheme(artifact_name, scheme) if artifact_scheme == scheme: