diff --git a/.devcontainer/build-scripts/build-base.sh b/.devcontainer/build-scripts/build-base.sh index ce7c1c4..7a79346 100755 --- a/.devcontainer/build-scripts/build-base.sh +++ b/.devcontainer/build-scripts/build-base.sh @@ -7,7 +7,10 @@ source $SWIFT_BUILDROOT/.devcontainer/build-scripts/swift-define # Build cd $WORKING_DIR +make $BUILDROOT_OPTIONS zstd-build +make $BUILDROOT_OPTIONS libedit-build make $BUILDROOT_OPTIONS libbsd-build +make $BUILDROOT_OPTIONS icu-build make $BUILDROOT_OPTIONS libxml2-build make $BUILDROOT_OPTIONS openssl-build make $BUILDROOT_OPTIONS libcurl-build diff --git a/.devcontainer/build-scripts/build-host-swift.sh b/.devcontainer/build-scripts/build-host-swift.sh index 3d35e10..e2fc7a4 100755 --- a/.devcontainer/build-scripts/build-host-swift.sh +++ b/.devcontainer/build-scripts/build-host-swift.sh @@ -21,6 +21,7 @@ do if [ ! -d "$BUILDROOT_OUTPUT_ARCH/build/host-swift-6.0.3" ]; then echo "Generating host tools symlink for $i" ln -s ../../$SWIFT_TARGET_ARCH/build/host-swift-6.0.3 ./host-swift-6.0.3 + rm $BUILDROOT_OUTPUT_ARCH/build/host-swift-6.0.3/.stamp_host_installed fi fi done \ No newline at end of file diff --git a/.devcontainer/build-scripts/build-test.sh b/.devcontainer/build-scripts/build-test.sh new file mode 100755 index 0000000..f9eb14f --- /dev/null +++ b/.devcontainer/build-scripts/build-test.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +# Configurable +SWIFT_BUILDROOT="${SWIFT_BUILDROOT:=$(pwd)}" +source $SWIFT_BUILDROOT/.devcontainer/build-scripts/swift-define + +# Build +cd $WORKING_DIR +echo "BR2_PACKAGE_SWIFT_HELLO=y" >> $BUILDROOT_CONFIG +make $BUILDROOT_OPTIONS swift-hello-build +make $BUILDROOT_OPTIONS +file $BUILDROOT_TARGET/usr/bin/swift-hello \ No newline at end of file diff --git a/.devcontainer/build-scripts/run-test.sh b/.devcontainer/build-scripts/run-test.sh new file mode 100755 index 0000000..cf3220f --- /dev/null +++ b/.devcontainer/build-scripts/run-test.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +# Configurable +SWIFT_BUILDROOT="${SWIFT_BUILDROOT:=$(pwd)}" +source $SWIFT_BUILDROOT/.devcontainer/build-scripts/swift-define + +# Build +cd $WORKING_DIR +make $BUILDROOT_OPTIONS swift-hello-build +QEMU_TEST="/usr/bin/$QEMU_BIN -L $BUILDROOT_TARGET $BUILDROOT_TARGET/usr/bin/swift-hello" +echo "$QEMU_TEST" +$QEMU_TEST \ No newline at end of file diff --git a/.devcontainer/build-scripts/swift-define b/.devcontainer/build-scripts/swift-define index 747c454..971c12c 100644 --- a/.devcontainer/build-scripts/swift-define +++ b/.devcontainer/build-scripts/swift-define @@ -12,6 +12,8 @@ BUILDROOT_DEFCONFIG=swift_${SWIFT_TARGET_ARCH}_defconfig BUILDROOT_DIR=$WORKING_DIR/buildroot BR2_EXTERNAL=$SWIFT_BUILDROOT BUILDROOT_OUTPUT=$WORKING_DIR/output/$SWIFT_TARGET_ARCH +BUILDROOT_TARGET=$BUILDROOT_OUTPUT/target +BUILDROOT_CONFIG=$BUILDROOT_OUTPUT/.config BUILDROOT_OPTIONS="O=$BUILDROOT_OUTPUT -C $BUILDROOT_DIR BR2_EXTERNAL=$BR2_EXTERNAL" HOST_SWIFT_SRCDIR=$BUILDROOT_OUTPUT/build/host-swift-6.0.3 SWIFT_LLVM_BUILD_DIR=$HOST_SWIFT_SRCDIR/swift-source/build/buildbot_linux/llvm-linux-$(uname -m) @@ -19,3 +21,14 @@ HOST_SWIFT_BUILDDIR=$HOST_SWIFT_SRCDIR/build SWIFT_NATIVE_TOOLS=$HOST_SWIFT_BUILDDIR/usr/bin SWIFT_LLVM_DIR=$HOST_SWIFT_BUILDDIR/llvm DOCKER_FILE=$SWIFT_BUILDROOT/.devcontainer/Dockerfile +if [[ "$SWIFT_TARGET_ARCH" == "arm64" ]]; then + QEMU_BIN=qemu-aarch64-static +elif [[ "$SWIFT_TARGET_ARCH" == "armv5" ]]; then + QEMU_BIN=qemu-arm-static +elif [[ "$SWIFT_TARGET_ARCH" == "armv6" ]]; then + QEMU_BIN=qemu-arm-static +elif [[ "$SWIFT_TARGET_ARCH" == "armv7" ]]; then + QEMU_BIN=qemu-arm-static +else + QEMU_BIN=qemu-$SWIFT_TARGET_ARCH-static +fi diff --git a/.github/workflows/buildroot.yml b/.github/workflows/buildroot.yml index b23f042..b251932 100644 --- a/.github/workflows/buildroot.yml +++ b/.github/workflows/buildroot.yml @@ -18,7 +18,17 @@ jobs: $SWIFT_BUILDROOT/.devcontainer/build-scripts/download-buildroot.sh $SWIFT_BUILDROOT/.devcontainer/build-scripts/build.sh - name: Archive Build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.5.0 with: name: build-${{ matrix.arch }} - path: ./output/${{ matrix.arch }}/images + path: /workspaces/buildroot-swift/output/${{ matrix.arch }}/images/rootfs.tar + - name: Build Test + run: | + export SWIFT_BUILDROOT=$GITHUB_WORKSPACE + export SWIFT_TARGET_ARCH=${{ matrix.arch }} + $SWIFT_BUILDROOT/.devcontainer/build-scripts/build-test.sh + - name: Upload test binary + uses: actions/upload-artifact@v4.5.0 + with: + name: swift-hello-${{ matrix.arch }} + path: /workspaces/buildroot-swift/output/${{ matrix.arch }}/target/usr/bin/swift-hello diff --git a/configs/swift_ppc64le_defconfig b/configs/swift_ppc64le_defconfig index 4ebc0c1..bff055c 100644 --- a/configs/swift_ppc64le_defconfig +++ b/configs/swift_ppc64le_defconfig @@ -1,5 +1,5 @@ # Architecture -BR2_powerpc64=y +BR2_powerpc64le=y BR2_powerpc_power7=y # GNU C Toolchain diff --git a/package/swift-hello/Config.in b/package/swift-hello/Config.in index 8b2472d..20e65e0 100644 --- a/package/swift-hello/Config.in +++ b/package/swift-hello/Config.in @@ -4,7 +4,6 @@ config BR2_PACKAGE_SWIFT_HELLO bool "swift-hello" depends on BR2_PACKAGE_SWIFT select BR2_PACKAGE_SWIFT_FOUNDATION - select BR2_PACKAGE_XCTEST help Demo application for Swift. diff --git a/package/swift-hello/src/Package.swift b/package/swift-hello/src/Package.swift index 4764bec..cdcb700 100644 --- a/package/swift-hello/src/Package.swift +++ b/package/swift-hello/src/Package.swift @@ -13,10 +13,6 @@ let package = Package( .executableTarget( name: "swift-hello", dependencies: [] - ), - .testTarget( - name: "swift-helloTests", - dependencies: ["swift-hello"] - ), + ) ] ) diff --git a/package/swift-hello/src/Sources/swift-hello/Hello.swift b/package/swift-hello/src/Sources/swift-hello/Hello.swift index 7b950af..c7bd773 100644 --- a/package/swift-hello/src/Sources/swift-hello/Hello.swift +++ b/package/swift-hello/src/Sources/swift-hello/Hello.swift @@ -1,4 +1,3 @@ -import Foundation #if canImport(Foundation) import Foundation #endif @@ -19,6 +18,7 @@ struct Hello { } for _ in 0 ..< 5 { print(UUID()) + print(Date()) try await Task.sleep(nanoseconds: 500_000_000) } } @@ -28,4 +28,3 @@ func errorTest() async throws { print("Will throw") throw CocoaError(.userCancelled) } - diff --git a/package/swift-hello/src/Tests/swift-helloTests/swift_helloTests.swift b/package/swift-hello/src/Tests/swift-helloTests/swift_helloTests.swift deleted file mode 100644 index f9ca48c..0000000 --- a/package/swift-hello/src/Tests/swift-helloTests/swift_helloTests.swift +++ /dev/null @@ -1,47 +0,0 @@ -import XCTest -import class Foundation.Bundle - -final class swift_helloTests: XCTestCase { - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - - // Some of the APIs that we use below are available in macOS 10.13 and above. - guard #available(macOS 10.13, *) else { - return - } - - // Mac Catalyst won't have `Process`, but it is supported for executables. - #if !targetEnvironment(macCatalyst) - - let fooBinary = productsDirectory.appendingPathComponent("swift-hello") - - let process = Process() - process.executableURL = fooBinary - - let pipe = Pipe() - process.standardOutput = pipe - - try process.run() - process.waitUntilExit() - - let data = pipe.fileHandleForReading.readDataToEndOfFile() - let output = String(data: data, encoding: .utf8) - - XCTAssertEqual(output, "Hello, world!\n") - #endif - } - - /// Returns path to the built products directory. - var productsDirectory: URL { - #if os(macOS) - for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") { - return bundle.bundleURL.deletingLastPathComponent() - } - fatalError("couldn't find the products directory") - #else - return Bundle.main.bundleURL - #endif - } -} diff --git a/package/swift-hello/swift-hello.mk b/package/swift-hello/swift-hello.mk index 5c4bd00..abdd0a1 100644 --- a/package/swift-hello/swift-hello.mk +++ b/package/swift-hello/swift-hello.mk @@ -4,7 +4,7 @@ SWIFT_HELLO_SITE = $(SWIFT_HELLO_PKGDIR)/src SWIFT_HELLO_SITE_METHOD = local SWIFT_HELLO_INSTALL_STAGING = NO SWIFT_HELLO_INSTALL_TARGET = YES -SWIFT_HELLO_DEPENDENCIES = swift swift-foundation xctest +SWIFT_HELLO_DEPENDENCIES = swift swift-foundation SWIFT_HELLO_EXECUTABLES = swift-hello $(eval $(swift-package)) diff --git a/package/swift/swift.mk b/package/swift/swift.mk index fe568a0..e154298 100644 --- a/package/swift/swift.mk +++ b/package/swift/swift.mk @@ -48,6 +48,9 @@ SWIFTC_EXTRA_FLAGS = -Xcc -msoft-float else ifeq ($(SWIFT_TARGET_ARCH),powerpc) SWIFT_EXTRA_FLAGS = -mcpu=7400 SWIFTC_EXTRA_FLAGS = -Xcc -mcpu=7400 +else ifeq ($(SWIFT_TARGET_ARCH),powerpc64le) +SWIFT_EXTRA_FLAGS = -DSWIFT_DTOA_PASS_FLOAT16_AS_FLOAT=1 +SWIFTC_EXTRA_FLAGS = -Xcc -DSWIFT_DTOA_PASS_FLOAT16_AS_FLOAT=1 else SWIFT_EXTRA_FLAGS = SWIFTC_EXTRA_FLAGS =