Skip to content

Upgrade meta-swift-examples to support meta-raspberrypi and share downloads/sstate-cache on Swift 6.1.2 #4

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 52 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d453916
add poky
xavgru12 Jun 14, 2025
8ab2cb1
update meta swift
xavgru12 Jun 14, 2025
61f6359
copy files from nxp swift
xavgru12 Jun 14, 2025
e95ecc4
cleanup
xavgru12 Jun 14, 2025
0825539
update meta-swift
xavgru12 Jun 14, 2025
806a6b2
add readme
xavgru12 Jun 14, 2025
86c6281
update readme
xavgru12 Jun 14, 2025
cbac409
readme
xavgru12 Jun 14, 2025
1b5ea87
update meta-swift
xavgru12 Jun 14, 2025
cedba0a
update meta-swift
xavgru12 Jun 15, 2025
cf1a2c1
update readme
xavgru12 Jun 24, 2025
37c29b1
add iproute2 to dockerfile
xavgru12 Jun 24, 2025
f6bb3e8
add tun to docker run
xavgru12 Jun 24, 2025
dde7ca5
add necessary packages for qemuarm
xavgru12 Jun 24, 2025
65cdee0
runs on self hosted github runner
xavgru12 Jun 24, 2025
0e7de2e
do checkout
xavgru12 Jun 24, 2025
11eb6c4
fix file
xavgru12 Jun 24, 2025
89a997c
clean false
xavgru12 Jun 24, 2025
61127ea
actions 3
xavgru12 Jun 24, 2025
2ec1f02
execute
xavgru12 Jun 24, 2025
bd4aa98
interact on
xavgru12 Jun 24, 2025
526aeea
simplify CI
xavgru12 Jun 25, 2025
3b2dd55
workflow dispatch as trigger
xavgru12 Jun 25, 2025
a917317
improve expect script
xavgru12 Jun 25, 2025
7fa6176
build docker
xavgru12 Jun 25, 2025
00bd4fd
run
xavgru12 Jun 25, 2025
3d89dd1
runqemu
xavgru12 Jun 25, 2025
bd1643d
server run
xavgru12 Jun 25, 2025
799bcd6
permissions
xavgru12 Jun 25, 2025
dc877b7
recursive checkout
xavgru12 Jun 26, 2025
23a40ad
update meta-swift
xavgru12 Jun 26, 2025
cc40ceb
improve run docker
xavgru12 Jun 26, 2025
05254e1
build docker step added
xavgru12 Jun 26, 2025
03073c2
do same with server run docker
xavgru12 Jun 26, 2025
4dab586
update meta-swift
xavgru12 Jun 26, 2025
c134584
rename to scarthgap
xavgru12 Jun 26, 2025
d8fbd01
adjust
xavgru12 Jun 27, 2025
b22e895
set timeout to 180
xavgru12 Jun 27, 2025
53335a9
establish build.sh
xavgru12 Jun 27, 2025
0672c9d
remove unnecessary echo
xavgru12 Jun 27, 2025
b3aac29
update README
xavgru12 Jun 27, 2025
dcb7801
Update meta-swift to point to 6.1 branch from Luke
xtremekforever Jun 28, 2025
7bc369f
Add support for meta-raspberrypi
xtremekforever Jun 28, 2025
401fe46
Add shared downloads and sstate-cache directories
xtremekforever Jun 30, 2025
21e715e
Update to latest meta-swift on 6.1 PR branch
xtremekforever Jun 30, 2025
0d8f0eb
Update meta-swift to point to scarthgap branch
xtremekforever Jul 1, 2025
b946243
Add ability to add extra packages to install in image on build
xtremekforever Jul 1, 2025
7135bc4
Point to latest scarthgap branch
xtremekforever Jul 2, 2025
e499d2c
Update meta-swift again
xtremekforever Jul 3, 2025
457a490
Add meta-raspberrypi as a submodule, only add to bblayers when buildi…
xtremekforever Jul 11, 2025
d8e4300
Add README.md update to list tested machines, fix execute.exp
xtremekforever Jul 19, 2025
f4b74e9
Point to meta-swift scarthgap branch
xtremekforever Jul 19, 2025
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: scarthgap

on:
workflow_dispatch:

jobs:
runqemu:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
clean: false
submodules: recursive
- name: build Docker
run: ./build-docker.sh
- name: build Yocto
run: ./server-run-docker.sh ./build.sh
- name: runqemu swift hello world
run: ./server-run-docker.sh ./execute.exp

110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# Ignore build directories
build*/
tmp/
sstate-cache/
cache/
deploy/
downloads/

# Ignore BitBake temporary files
bitbake.lock
*.run
*.lock
*.log
*.sigdata
*.siginfo
*.done
*.failed
*.conf.old

# Ignore editor/IDE files
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Ignore output files
*.tar.gz
*.bin
*.wic*
*.ext4
*.rootfs.*

# Ignore user-specific config
conf/local.conf
conf/site.conf
conf/bblayers.conf

# Ignore custom scripts and artifacts
*.pyc
*.pyo
*.o
*.a
*.so
*.la
*.lo
*.rej
*.orig

# Ignore Git submodule locks
.gitmodules.lock
.repo

# Shared state
downloads/
sstate-cache/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "meta-swift"]
path = meta-swift
url = git@github.com:xavgru12/meta-swift.git
[submodule "meta-raspberrypi"]
path = meta-raspberrypi
url = https://github.com/agherzan/meta-raspberrypi.git
[submodule "poky"]
path = poky
url = https://git.yoctoproject.org/poky
49 changes: 49 additions & 0 deletions Dockerfile-Ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM ubuntu:22.04

# Update system and install required packages
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y && \
apt install -y gawk wget git-core diffstat unzip texinfo \
gcc-multilib build-essential chrpath socat file cpio python3 \
python3-pip python3-pexpect xz-utils debianutils iputils-ping \
libsdl1.2-dev xterm tar locales net-tools rsync sudo vim curl zstd \
liblz4-tool libssl-dev bc lzop libgnutls28-dev efitools git-lfs \
keychain pipx make ninja-build tmux xclip xsel iproute2 \
bridge-utils iptables expect

# Install Neovim
COPY neovim-installer.sh /neovim-installer.sh
RUN chmod +x /neovim-installer.sh && \
/neovim-installer.sh && \
rm -f /neovim-installer.sh

# Set up locales
RUN locale-gen en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

# Ensure /bin/sh points to bash (Yocto requires this)
RUN ln -sf bash /bin/sh

# Install repo
ADD https://storage.googleapis.com/git-repo-downloads/repo /usr/local/bin/repo
RUN chmod 755 /usr/local/bin/repo

ARG USER
# Create the user with a home directory and set Bash as the default shell
RUN useradd -m -s /bin/bash ${USER} && \
echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \
chmod 0440 /etc/sudoers.d/${USER}


# Ensure user has the correct UID/GID for volume-mounted builds
ARG USER
RUN usermod -u $(id -u ${USER}) -g $(id -g ${USER}) ${USER}

# Set working directory
ARG DOCKER_WORKDIR
WORKDIR ${DOCKER_WORKDIR}

# Switch to the Yocto user
USER ${USER}
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# meta-swift examples

This repo provides a simple workspace to compile the [meta-swift](https://github.com/jeremy-prater/meta-swift) layer
for a sizeable set of supported Yocto machines for the purpose of evalulation and testing.

The following machines are supported and have been tested:

- `qemuarm`
- `qemuarm64`
- `qemux86-64`
- `beaglebone-yocto`
- `raspberrypi-armv7`
- `raspberrypi-armv8`

Others will likely also work, but have not been tested.

## Clone

```console
git clone git@github.com:xavgru12/meta-swift-project.git --recurse-submodules
```

## Build

It is recommended to build and run the included Docker container for a working environment for
building Yocto:

```console
./build-docker.sh
./run-docker.sh
```

Build the `core-image-minimal` for the default architecture (`qemuarm`):

```console
./build.sh
```

You may also customize the ./build.sh invocation by adding `MACHINE=` and/or `EXTRA_IMAGE_INSTALL=`:

```console
MACHINE=beaglebone-yocto EXTRA_IMAGE_INSTALL="openssh" ./build.sh
```

Builds will be found under poky/build-$MACHINE. Downloads and sstate-cache are shared between builds to keep disk size down as much as possible.

## Execution

Execute `hello-world` for the default `qemuarm` machine. This is an easy way to confirm that the meta-swift build worked correctly:

```console
./execute.exp
```

If you built for a different machine, prefix the command with `MACHINE=` like this:

```console
MACHINE=beaglebone-yocto ./build.sh
```

## Github Actions

Start runner and trigger job via Github API:

https://github.com/xavgru12/github-self-hosted-runner

28 changes: 28 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# This script creates the yocto-ready docker image.
# The --build-arg options are used to pass data about the current user.
# Also, a tag is used for easy identification of the generated image.
#

# source the common variables
. ./env.sh

if [[ $PWD != $HOME* && $(whoami) != "root" ]]; then
echo "Error: Current directory is outside $HOME"
exit 1
fi

USERNAME=$(whoami)
if [[ $USERNAME == "root" ]]; then
USERNAME=yocto
fi

docker build --tag "${DOCKER_IMAGE_TAG}" \
--build-arg "DOCKER_WORKDIR=${DOCKER_WORKDIR}" \
--build-arg "USER=$USERNAME" \
--build-arg "host_uid=$(id -u)" \
--build-arg "host_gid=$(id -g)" \
-f Dockerfile-Ubuntu-22.04 \
.

37 changes: 37 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -e

# Configuration
SRC_ROOT="${SRC_ROOT:=$(pwd)}"
POKY_DIR="${POKY_DIR:=$SRC_ROOT/poky}"
META_SWIFT_DIR="${META_SWIFT_DIR:=$SRC_ROOT/meta-swift}"
META_RASPBERRYPI_DIR=${META_RASPBERRYPI_DIR:=$SRC_ROOT/meta-raspberrypi}

MACHINE="${MACHINE:=qemuarm}"
DOWNLOADS_DIR=${DOWNLOADS_DIR:=$SRC_ROOT/downloads}
SSTATE_DIR=${SSTATE_DIR:=$SRC_ROOT/sstate-cache}

# Build Yocto Poky
cd $POKY_DIR
source oe-init-build-env build-$MACHINE
bitbake-layers add-layer $META_SWIFT_DIR
# Support for Raspberry PI devices
if [[ $MACHINE == "raspberrypi"* ]]; then
bitbake-layers add-layer $META_RASPBERRYPI_DIR
fi
# Customize build
touch conf/sanity.conf
CONF_FILE=./conf/local.conf
rm -rf $CONF_FILE
echo "# Swift for Yocto" >> $CONF_FILE
echo "MACHINE=\"${MACHINE}\"" >> $CONF_FILE
echo "DL_DIR ?= \"${DOWNLOADS_DIR}\"" >> $CONF_FILE
echo "SSTATE_DIR ?= \"${SSTATE_DIR}\"" >> $CONF_FILE
echo 'IMAGE_FEATURES += "debug-tweaks"' >> $CONF_FILE
echo "IMAGE_INSTALL:append = \" swift-hello-world ${EXTRA_IMAGE_INSTALL}\"" >> $CONF_FILE

#echo 'SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH"' >> $CONF_FILE
#echo "USER_CLASSES += \"buildstats buildstats-summary\"" >> $CONF_FILE

# build Swift
bitbake core-image-minimal
13 changes: 13 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Here are some default settings.
# Make sure DOCKER_WORKDIR is created and owned by current user.

# Docker

DOCKER_IMAGE_TAG="meta-swift-project"
DOCKER_WORKDIR="$PWD"

# Yocto

YOCTO_DIR="$PWD"

45 changes: 45 additions & 0 deletions execute.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/expect -f

# Grab machine from env
set MACHINE qemuarm
catch {set MACHINE $env(MACHINE)}

spawn bash -c "cd poky && source oe-init-build-env build-${MACHINE} && runqemu ${MACHINE} nographic"

set timeout 180

expect {
-re ".*login: " {
send "root\r"
}
timeout {
puts "ERROR: Login prompt not received"
exit 1
}
}

expect {
-re {root@.*# } {
# got shell prompt after login
}
timeout {
puts "ERROR: Timeout waiting for root shell prompt after login"
exit 1
}
}

send "hello-world\r"

expect {
-re {root@.*# } {
# got shell prompt after command
}
timeout {
puts "ERROR: Timeout waiting for shell prompt after command"
exit 1
}
}

# Optional: interact to keep session open
#interact

1 change: 1 addition & 0 deletions meta-raspberrypi
Submodule meta-raspberrypi added at 484524
2 changes: 1 addition & 1 deletion meta-swift
Submodule meta-swift updated 52 files
+0 −10 .devcontainer/Dockerfile
+0 −20 .devcontainer/devcontainer.json
+96 −21 .github/workflows/build.yml
+0 −30 .gitlab-ci.yml
+10 −9 README.md
+0 −23 build.sh
+74 −78 classes/swift-cmake-base.bbclass
+1 −1 classes/swift-cmake.bbclass
+19 −0 classes/swift-common.bbclass
+10 −0 classes/swift-target-tune.bbclass
+146 −13 classes/swift.bbclass
+1 −1 conf/layer.conf
+78 −0 recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch
+6 −0 recipes-core/glibc/glibc_%.bbappend
+46 −14 recipes-devtools/swift/libdispatch.bb
+0 −54 recipes-devtools/swift/libfoundation.bb
+0 −153 recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch
+65 −0 recipes-devtools/swift/swift-foundation-essentials.bb
+33 −0 ...-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch
+34 −0 recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch
+41 −0 recipes-devtools/swift/swift-foundation-icu.bb
+86 −0 recipes-devtools/swift/swift-foundation.bb
+44 −0 recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch
+34 −0 recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch
+0 −27 recipes-devtools/swift/swift-llvm-native.bb
+37 −28 recipes-devtools/swift/swift-native.bb
+231 −107 recipes-devtools/swift/swift-stdlib.bb
+0 −13 recipes-devtools/swift/swift-stdlib/0001-Float16.patch
+24 −0 recipes-devtools/swift/swift-stdlib/0001-add-arm-to-float16support-for-armv7.patch
+54 −0 recipes-devtools/swift/swift-stdlib/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch
+0 −104 recipes-devtools/swift/swift-stdlib/cmake-configure-swift-stdlib.sh
+0 −63 recipes-devtools/swift/swift-stdlib/fix_modulemap.sh
+45 −0 recipes-devtools/swift/swift-testing.bb
+35 −0 recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch
+50 −0 recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch
+2 −1 recipes-devtools/swift/swift-version.inc
+42 −0 recipes-devtools/swift/swift-xctest.bb
+0 −65 recipes-support/icu/icu-swift.inc
+0 −28 recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch
+0 −48 recipes-support/icu/icu-swift/fix-install-manx.patch
+0 −29 recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch
+0 −25 recipes-support/icu/icu-swift_55.1.bb
+11 −3 recipes-test/swift-hello-world/files/Package.swift
+2 −1 recipes-test/swift-hello-world/files/Sources/hello-world/main.swift
+8 −0 recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift
+21 −3 recipes-test/swift-hello-world/swift-hello-world.bb
+0 −9 recipes-test/swift/swift-build-test.bb
+0 −19 recipes-test/swift/swift-build-test/Package.swift
+0 −4 recipes-test/swift/swift-build-test/Sources/hello-world/main.swift
+0 −12 recipes-test/swift/swift-cmake-test.bb
+0 −8 recipes-test/swift/swift-cmake-test/CMakeLists.txt
+0 −4 recipes-test/swift/swift-cmake-test/main.swift
Loading