Skip to content

Commit

Permalink
Merge pull request #16 from MillerTechnologyPeru/feature/swift-hello-…
Browse files Browse the repository at this point in the history
…test

Fix `swift-hello` and PPC64 support
  • Loading branch information
colemancda authored Dec 27, 2024
2 parents 10aa393 + f6235f6 commit d8b0230
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/build-scripts/build-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .devcontainer/build-scripts/build-host-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions .devcontainer/build-scripts/build-test.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .devcontainer/build-scripts/run-test.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .devcontainer/build-scripts/swift-define
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ 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)
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
14 changes: 12 additions & 2 deletions .github/workflows/buildroot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
name: swift-hello-${{ matrix.arch }}
path: /workspaces/buildroot-swift/output/${{ matrix.arch }}/target/usr/bin/swift-hello
2 changes: 1 addition & 1 deletion configs/swift_ppc64le_defconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Architecture
BR2_powerpc64=y
BR2_powerpc64le=y
BR2_powerpc_power7=y

# GNU C Toolchain
Expand Down
1 change: 0 additions & 1 deletion package/swift-hello/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 1 addition & 5 deletions package/swift-hello/src/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ let package = Package(
.executableTarget(
name: "swift-hello",
dependencies: []
),
.testTarget(
name: "swift-helloTests",
dependencies: ["swift-hello"]
),
)
]
)
3 changes: 1 addition & 2 deletions package/swift-hello/src/Sources/swift-hello/Hello.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Foundation
#if canImport(Foundation)
import Foundation
#endif
Expand All @@ -19,6 +18,7 @@ struct Hello {
}
for _ in 0 ..< 5 {
print(UUID())
print(Date())
try await Task.sleep(nanoseconds: 500_000_000)
}
}
Expand All @@ -28,4 +28,3 @@ func errorTest() async throws {
print("Will throw")
throw CocoaError(.userCancelled)
}

This file was deleted.

2 changes: 1 addition & 1 deletion package/swift-hello/swift-hello.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
3 changes: 3 additions & 0 deletions package/swift/swift.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit d8b0230

Please sign in to comment.