diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index b97f157..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu/.devcontainer/base.Dockerfile - -# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 -ARG VARIANT="ubuntu-20.04" -FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} - -# Install BitBake dependencies -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev xterm python3-subunit mesa-common-dev zstd liblz4-tool file - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index aa27be3..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu -{ - "name": "Ubuntu", - "build": { - "dockerfile": "Dockerfile", - // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 - // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. - "args": { "VARIANT": "ubuntu-20.04" } - }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "uname -a", - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfead9f..1b8f781 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,100 @@ -name: Build +name: build -on: [push] +on: + push: + pull_request: + workflow_dispatch: jobs: + yocto-aarch64: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemuarm64"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world - build: - name: Build - runs-on: ubuntu-latest - container: colemancda/meta-swift - strategy: - matrix: - machine: [beaglebone-yocto, qemuarm64] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Build - run: | - export SRC_ROOT=$GITHUB_WORKSPACE - export POKY_DIR=/tmp/poky - export MACHINE=${{ matrix.machine }} - cd /tmp/ - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - cd $SRC_ROOT - ./build.sh + yocto-armv7: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemuarm"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world + + yocto-x86_64: + runs-on: ubuntu-24.04 + container: + steps: + - name: Packages + run: | + sudo apt-get update + sudo apt install -y build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd + echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns + - name: Checkout Poky + uses: actions/checkout@v4 + with: + repository: yoctoproject/poky + path: poky + ref: scarthgap + fetch_depth: 0 + - name: Checkout Swift layer + uses: actions/checkout@v4 + with: + path: poky/meta-swift + fetch_depth: 0 + - name: Build + run: | + cd $GITHUB_WORKSPACE/poky + source oe-init-build-env + bitbake-layers add-layer ../meta-swift + rm -f conf/local.conf + echo 'MACHINE = "qemux86-64"' > conf/local.conf + echo 'INHERIT += "rm_work"' >> conf/local.conf + bitbake swift-hello-world diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index e7ba095..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,30 +0,0 @@ -stages: - - build - -build-armv7: - image: colemancda/meta-swift - stage: build - script: - - export SRC_ROOT=$(pwd) - - export MACHINE=beaglebone-yocto - - export POKY_DIR=/tmp/poky - - cd /tmp/ - - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - - cd $SRC_ROOT - - ./build.sh - tags: - - bastion-c5d.9xl - -build-arm64: - image: colemancda/meta-swift - stage: build - script: - - export SRC_ROOT=$(pwd) - - export MACHINE=qemuarm64 - - export POKY_DIR=/tmp/poky - - cd /tmp/ - - git clone --branch dunfell-23.0.20-cmake-3.22.3 https://github.com/MillerTechnologyPeru/poky.git - - cd $SRC_ROOT - - ./build.sh - tags: - - bastion-c5d.9xl diff --git a/README.md b/README.md index 76a3c1f..3a1c57c 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # meta-swift -Yocto meta-layer for swift-on-arm (Swift 5.7.1) + +Yocto layer for the Swift programming language. # Usage -Add this meta layer to your project (refer to yocto user manual) +Add this layer to your project (refer to Yocto user manual, or use `bitbake-layers add-layer`). -Create a new swift application and include it in your yocto build as follows... +Create a new Swift application and include it in your build as follows: ``` -DESCRIPTION = "My swift 5.7.1 app" +DESCRIPTION = "My Swift app" LICENSE = "CLOSED" SRC_URI = "file://Sources/hello-world/main.swift \ @@ -18,14 +19,14 @@ SRC_URI = "file://Sources/hello-world/main.swift \ inherit swift ``` -This does a few things, when you `inherit swift` meta-layer class, it will does the following... +When you `inherit swift` class, it does the following: -- Automatically download the x86_64 and ARMv7 swift 5.7.1 binaries and create a cross-compiling sys-root -- Add an RDEPENDS_${PN} for `swift` which is the Armv7 runtime +- Automatically download the x86\_64 SDK binaries and create a cross-compiling sysroot +- Add an RDEPENDS:${PN} for `swift` - Performs the required build steps # Deployment -The user of this meta-layer must provide their own `do_install` function. +The user of this layer must provide their own `do_install` function. -The finished binaries are located in ${WORKDIR}/.build/release/* \ No newline at end of file +The finished binaries are located in ${BUILD\_DIR}. diff --git a/build.sh b/build.sh deleted file mode 100755 index 7b96afd..0000000 --- a/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -e - -# Configuration -SRC_ROOT="${SRC_ROOT:=$(pwd)}" -POKY_DIR="${POKY_DIR:=$SRC_ROOT/../poky}" -MACHINE="${MACHINE:=beaglebone-yocto}" - -# Build Yocto Poky -cd $POKY_DIR -source oe-init-build-env -bitbake-layers add-layer $SRC_ROOT -# 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 'SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH"' >> $CONF_FILE -#echo "USER_CLASSES += \"buildstats buildstats-summary\"" >> $CONF_FILE - -# build Swift -bitbake swift-hello-world diff --git a/classes/swift-cmake-base.bbclass b/classes/swift-cmake-base.bbclass index 1b59da2..856dc55 100644 --- a/classes/swift-cmake-base.bbclass +++ b/classes/swift-cmake-base.bbclass @@ -1,26 +1,55 @@ inherit cmake +inherit swift-common -DEPENDS_append += " swift-native libgcc gcc glibc " +python () { + # Determine SWIFT_GCC_VERSION by examining bitbake's context dictionary key + # RECIPE_MAINTAINER:pn-gcc-source- + import shlex -SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', 'aarch64', d)}" -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" -TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', 'aarch64', d)}" + gcc_src_maint_pkg = [x for x in d if x.startswith("RECIPE_MAINTAINER:pn-gcc-source-")][0] + gcc_ver = gcc_src_maint_pkg.rpartition("-")[2] -HOST_CC_ARCH_prepend = "-target ${SWIFT_TARGET_NAME}" + d.setVar("SWIFT_GCC_VERSION", gcc_ver) + + def expand_swiftc_cc_flags(flags): + flags = [['-Xcc', flag] for flag in flags] + return sum(flags, []) + + def concat_flags(flags): + return " ".join(flags) + + # ensure target-specific tune CC flags are propagated to clang and swiftc. + # Note we are not doing this at present for LD flags, as there are none in + # the architectures we support (and it would make the string expansion more + # complicated). + target_cc_arch = shlex.split(d.getVar("TARGET_CC_ARCH")) + + d.setVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS", concat_flags(expand_swiftc_cc_flags(target_cc_arch))) +} + +EXTRA_INCLUDE_FLAGS ?= "\ + -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} \ + -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} \ + -I${STAGING_DIR_TARGET}" + +# not supported by clang +DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map" + +HOST_CC_ARCH:prepend = "-target ${SWIFT_TARGET_NAME} " ################################################################################ # NOTE: The host running bitbake must have lld available and the following # # must be added to the local.conf file: # # # -# HOSTTOOLS += "ld.lld" # +# HOSTTOOLS:append = " ld.lld" # # # ################################################################################ # Use lld (see note above) -TARGET_LDFLAGS += "-fuse-ld=lld" +TARGET_LDFLAGS:append = " -fuse-ld=lld" # Add build-id to generated binaries -TARGET_LDFLAGS += "-Xlinker --build-id=sha1" +TARGET_LDFLAGS:append = " -Xlinker --build-id=sha1" # Use Apple's provided clang (it understands Apple's custom compiler flags) # Made available via swift-native package. @@ -28,80 +57,42 @@ OECMAKE_C_COMPILER = "clang" OECMAKE_CXX_COMPILER = "clang++" # Point clang to where the C++ runtime is for our target arch -RUNTIME_FLAGS = "-w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" -TARGET_LDFLAGS += "-w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" +RUNTIME_FLAGS = "${TARGET_CC_ARCH} -w -fuse-ld=lld -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" +TARGET_LDFLAGS:append = " ${TARGET_LD_ARCH} -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" + +OECMAKE_C_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +OECMAKE_CXX_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +OECMAKE_ASM_FLAGS:append = " ${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -EXTRA_INCLUDE_FLAGS ?= "" -OECMAKE_C_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -OECMAKE_CXX_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -OECMAKE_ASM_FLAGS += "${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" +SWIFTC_BIN = "${STAGING_DIR_NATIVE}/usr/bin/swiftc" -BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" +EXTRA_OECMAKE:append = " -DCMAKE_Swift_COMPILER=${SWIFTC_BIN}" +EXTRA_OECMAKE:append = " -DCMAKE_SWIFT_COMPILER=${SWIFTC_BIN}" +EXTRA_OECMAKE:append = ' -DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' +EXTRA_OECMAKE:append = " -DSWIFT_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_USE_LINKER=lld" +EXTRA_OECMAKE:append = " -DLLVM_DIR=${HOST_LLVM_PATH}/cmake/llvm" +EXTRA_OECMAKE:append = " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" # Additional parameters to pass to swiftc EXTRA_SWIFTC_FLAGS ??= "" SWIFT_FLAGS = "-target ${SWIFT_TARGET_NAME} -use-ld=lld \ --resource-dir ${STAGING_DIR_TARGET}/usr/lib/swift \ --module-cache-path ${B}/${BUILD_MODE}/ModuleCache \ --Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ --Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib \ --Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current/include \ --Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current/include-fixed \ --L${STAGING_DIR_TARGET} \ --L${STAGING_DIR_TARGET}/lib \ --L${STAGING_DIR_TARGET}/usr/lib \ --L${STAGING_DIR_TARGET}/usr/lib/swift \ --L${STAGING_DIR_TARGET}/usr/lib/swift/linux \ --L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ --sdk ${STAGING_DIR_TARGET} \ -${EXTRA_SWIFTC_FLAGS} \ + -resource-dir ${STAGING_DIR_TARGET}/usr/lib/swift \ + -module-cache-path ${B}/${BUILD_MODE}/ModuleCache \ + -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib \ + -Xclang-linker -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} \ + ${SWIFT_EXTRA_SWIFTC_CC_FLAGS} \ + -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include \ + -Xcc -I${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION}/include-fixed \ + -L${STAGING_DIR_TARGET} \ + -L${STAGING_DIR_TARGET}/lib \ + -L${STAGING_DIR_TARGET}/usr/lib \ + -L${STAGING_DIR_TARGET}/usr/lib/swift \ + -L${STAGING_DIR_TARGET}/usr/lib/swift/linux \ + -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} \ + -sdk ${STAGING_DIR_TARGET} \ + ${EXTRA_SWIFTC_FLAGS} \ " -HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/opt/usr/lib/llvm-swift" -EXTRA_OECMAKE += '-DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' -EXTRA_OECMAKE += " -DSWIFT_USE_LINKER=lld" -EXTRA_OECMAKE += " -DLLVM_USE_LINKER=lld" -EXTRA_OECMAKE += " -DLLVM_DIR=${HOST_LLVM_PATH}/lib/cmake/llvm" -EXTRA_OECMAKE += " -DLLVM_BUILD_LIBRARY_DIR=${HOST_LLVM_PATH}" - -EXTRANATIVEPATH += "swift-tools" - -################################################################################ -# Create symlinks to the directories containing the gcc version specific # -# headers, objects and libraries we need. # -# # -# We can't just use ${GCC_VERSION} in the path variables in the recipe # -# because bitbake parses and expands variables before GCC_VERSION is # -# defined. GCC_VERSION cannot be defined until the sysroot is populated # -# because we inspect the sysroot to determine the GCC version number string. # -# If there was an env or bitbake var with the GCC version, we could use that # -# and avoid all of this but the closest thing we have access to is # -# ${GCCVERSION} which yields and incomplete version number (ex: "9.%"). # -# # -# Also there is some suspicion that these path variables and these symlinks # -# may not be necessary if the --gcc-toolchain clang flag was used. But that # -# is an unproven theory. # -################################################################################ - -do_create_gcc_version_symlinks() { - GCC_VERSION=`basename ${STAGING_DIR_TARGET}/usr/include/c++/*` - - if [ ! -L "${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" ]; then - cd ${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS} - ln -s -r ${GCC_VERSION} current - fi - - if [ ! -L "${STAGING_DIR_TARGET}/usr/include/c++/current" ]; then - cd ${STAGING_DIR_TARGET}/usr/include/c++ - ln -s -r ${GCC_VERSION} current - fi - - if [ ! -L "${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS}/current" ]; then - cd ${STAGING_DIR_NATIVE}/usr/lib/${TARGET_SYS}/gcc/${TARGET_SYS} - ln -s -r ${GCC_VERSION} current - fi -} - -addtask do_create_gcc_version_symlinks after do_prepare_recipe_sysroot before do_configure - +HOST_LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/lib" diff --git a/classes/swift-cmake.bbclass b/classes/swift-cmake.bbclass index 211c33d..c508fab 100644 --- a/classes/swift-cmake.bbclass +++ b/classes/swift-cmake.bbclass @@ -1,5 +1,5 @@ inherit swift-cmake-base -DEPENDS_append += " swift-stdlib libdispatch libfoundation " +DEPENDS:append = " swift-stdlib libdispatch swift-foundation" TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" diff --git a/classes/swift-common.bbclass b/classes/swift-common.bbclass new file mode 100644 index 0000000..bd5d1c1 --- /dev/null +++ b/classes/swift-common.bbclass @@ -0,0 +1,13 @@ +# avoid conflicts with meta-clang +TOOLCHAIN = "gcc" + +DEPENDS:append = " swift-native glibc gcc libgcc" +EXTRANATIVEPATH:append = " swift-tools" + +SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', '${TARGET_ARCH}-unknown-linux-gnu', d)}" +SWIFT_TARGET_ARCH = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7', '${TARGET_ARCH}', d)}" +TARGET_CPU_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-a', '${TARGET_ARCH}', d)}" + +BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" + +inherit swift-target-tune diff --git a/classes/swift-target-tune.bbclass b/classes/swift-target-tune.bbclass new file mode 100644 index 0000000..451b4a7 --- /dev/null +++ b/classes/swift-target-tune.bbclass @@ -0,0 +1,15 @@ +# force disable GLIBC_64BIT_TIME_FLAGS until SwiftNIO and other common packages +# are updated to support 64-bit time_t on 32-bit systems. ABI incompatibility +# may cause your program to crash; you have been warned. +TARGET_CC_ARCH:remove:arm = "${GLIBC_64BIT_TIME_FLAGS}" + +# appears to cause segfault +TARGET_CC_ARCH:remove:aarch64 = "-mbranch-protection=standard" + +# workaround for building on x86_64: SSE appears to cause cyclic header +# dependency when building C++ std module. This needs investigation and an +# upstream fix +TARGET_CC_ARCH:remove:x86-64 = "-march=core2" +TARGET_CC_ARCH:remove:x86-64 = "-mtune=core2" +TARGET_CC_ARCH:remove:x86-64 = "-msse3" +TARGET_CC_ARCH:remove:x86-64 = "-mfpmath=sse" diff --git a/classes/swift.bbclass b/classes/swift.bbclass index faf8a74..ecefb81 100644 --- a/classes/swift.bbclass +++ b/classes/swift.bbclass @@ -1,5 +1,9 @@ +inherit swift-common -DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch libfoundation" +SWIFT_BUILD_TESTS ?= "${DEBUG_BUILD}" + +DEPENDS:append = " swift-stdlib libdispatch swift-foundation" +DEPENDS:append = " ${@oe.utils.conditional('SWIFT_BUILD_TESTS', '1', ' swift-xctest swift-testing', '', d)}" # Default build directory for SPM is "./.build" # (see 'swift [build|package|run|test] --help') @@ -9,12 +13,18 @@ DEPENDS += "swift-native glibc gcc libgcc swift-stdlib libdispatch libfoundation B ?= "${S}/.build" EXTERNALSRC_BUILD ?= "${EXTERNALSRC}/.build" -BUILD_MODE = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" +BUILD_DIR = "${B}/${BUILD_MODE}" # Additional parameters to pass to SPM EXTRA_OESWIFT ?= "" -SWIFT_TARGET_NAME = "${@oe.utils.conditional('TARGET_ARCH', 'arm', 'armv7-unknown-linux-gnueabihf', 'aarch64-unknown-linux-gnu', d)}" +do_fix_gcc_install_dir() { + # symbolic links do not work, will not be found by Swift clang driver + # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop + (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS} gcc) +} + +addtask fix_gcc_install_dir before do_configure after do_prepare_recipe_sysroot # Workaround complex macros that cannot be automatically imported by Swift. # https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/using_imported_c_macros_in_swift @@ -39,11 +49,44 @@ def fix_socket_header(filename): else: f.write(line) +# Support for SwiftPM fetching packages and their GitHub submodules +swift_do_package_resolve[depends] += "unzip-native:do_populate_sysroot swift-native:do_populate_sysroot" +swift_do_package_resolve[network] = "1" +swift_do_package_resolve[vardepsexclude] = "BB_ORIGENV" + +python swift_do_package_resolve() { + import subprocess + import os + + s = d.getVar('S') + b = d.getVar('B') + recipe_sysroot_native = d.getVar("STAGING_DIR_NATIVE", True) + + env = os.environ.copy() + + ssh_auth_sock = d.getVar('BB_ORIGENV').get('SSH_AUTH_SOCK') + if ssh_auth_sock: + env['SSH_AUTH_SOCK'] = ssh_auth_sock + + ret = subprocess.call([f'{recipe_sysroot_native}/usr/bin/swift', 'package', 'resolve', '--package-path', s, '--build-path', b], env=env) + if ret != 0: + bb.fatal('swift package resolve failed') + + # note: --depth 1 requires git version 2.43.0 or later + for package in os.listdir(path=f'{b}/checkouts'): + package_dir = f'{b}/checkouts/{package}' + ret = subprocess.call(['git', 'submodule', 'update', '--init', '--recursive', '--depth', '1'], cwd=package_dir, env=env) + if ret != 0: + bb.fatal('git submodule update failed') +} + +addtask do_package_resolve after do_unpack before do_compile python swift_do_configure() { import os import os.path import shutil + import shlex workdir = d.getVar("WORKDIR", True) recipe_sysroot = d.getVar("STAGING_DIR_TARGET", True) @@ -60,31 +103,54 @@ python swift_do_configure() { # This is used to determine necessary include paths cxx_include_base = recipe_sysroot + "/usr/include/c++" cxx_include_list = os.listdir(cxx_include_base) + if 'current' in cxx_include_list: + cxx_include_list.remove('current') if len(cxx_include_list) != 1: bb.fatal("swift bbclass detected more than one c++ runtime, unable to determine which one to use") cxx_version = cxx_include_list[0] d.setVar('SWIFT_CXX_VERSION', cxx_version) + def expand_swiftc_cc_flags(flags): + flags = [['-Xcc', flag] for flag in flags] + return sum(flags, []) + + def concat_flags(flags): + flags = [f'"{flag}"' for flag in flags] + return ", ".join(flags) + + # ensure target-specific tune CC flags are propagated to clang and swiftc. + # Note we are not doing this at present for LD flags, as there are none in + # the architectures we support (and it would make the string expansion more + # complicated). + target_cc_arch = shlex.split(d.getVar("TARGET_CC_ARCH")) + + d.setVar("SWIFT_EXTRA_CC_FLAGS", concat_flags(target_cc_arch)) + d.setVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS", concat_flags(expand_swiftc_cc_flags(target_cc_arch))) + swift_destination_template = """{ "version":1, "sdk":"${STAGING_DIR_TARGET}/", - "toolchain-bin-dir":"${STAGING_DIR_NATIVE}/opt/usr/bin", + "toolchain-bin-dir":"${STAGING_DIR_NATIVE}/usr/bin", "target":"${SWIFT_TARGET_NAME}", "dynamic-library-extension":"so", "extra-cc-flags":[ + ${SWIFT_EXTRA_CC_FLAGS}, "-fPIC", + "-I${STAGING_INCDIR}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}/${TARGET_SYS}", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include-fixed" + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include-fixed" ], "extra-swiftc-flags":[ "-target", "${SWIFT_TARGET_NAME}", "-use-ld=lld", "-tools-directory", - "${STAGING_DIR_NATIVE}/opt/usr/bin", + "${STAGING_DIR_NATIVE}/usr/bin", + + "-enforce-exclusivity=unchecked", "-Xlinker", "-rpath", "-Xlinker", "/usr/lib/swift/linux", @@ -109,14 +175,18 @@ python swift_do_configure() { "-I${STAGING_INCDIR}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}", "-I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_CXX_VERSION}/${TARGET_SYS}", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include", - "-I${STAGING_DIR_NATIVE}/opt/usr/lib/clang/13.0.0/include-fixed", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include", + "-I${STAGING_DIR_NATIVE}/usr/lib/clang/17/include-fixed", "-resource-dir", "${STAGING_DIR_TARGET}/usr/lib/swift", "-module-cache-path", "${B}/${BUILD_MODE}/ModuleCache", + "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_CXX_VERSION}", "-Xclang-linker", "-B${STAGING_DIR_TARGET}/usr/lib", + ${SWIFT_EXTRA_SWIFTC_CC_FLAGS}, + "-Xcc", "--gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_CXX_VERSION}", + "-sdk", "${STAGING_DIR_TARGET}" ], "extra-cpp-flags":[ @@ -128,15 +198,74 @@ python swift_do_configure() { d.delVar("SWIFT_CXX_VERSION") + d.delVar("SWIFT_EXTRA_CC_FLAGS") + d.delVar("SWIFT_EXTRA_SWIFTC_CC_FLAGS") + configJSON = open(workdir + "/destination.json", "w") configJSON.write(swift_destination) configJSON.close() } -swift_do_compile() { - swift build --package-path ${S} --build-path ${B} --skip-update -c ${BUILD_MODE} --destination ${WORKDIR}/destination.json ${EXTRA_OESWIFT} +# ideally this should be handled by swift_do_package_resolve but doesn't always appear to be the case +do_compile[network] = "1" +swift_do_compile[vardepsexclude] = "BB_ORIGENV" + +python swift_do_compile() { + import subprocess + import os + import shlex + + s = d.getVar('S') + b = d.getVar('B') + build_mode = d.getVar('BUILD_MODE') + workdir = d.getVar("WORKDIR", True) + destination_json = workdir + '/destination.json' + extra_oeswift = shlex.split(d.getVar('EXTRA_OESWIFT')) + ssh_auth_sock = d.getVar('BB_ORIGENV').get('SSH_AUTH_SOCK') + recipe_sysroot = d.getVar("STAGING_DIR_TARGET", True) + recipe_sysroot_native = d.getVar("STAGING_DIR_NATIVE", True) + + env = os.environ.copy() + if ssh_auth_sock: + env['SSH_AUTH_SOCK'] = ssh_auth_sock + env['SYSROOT'] = recipe_sysroot + + args = [f'{recipe_sysroot_native}/usr/bin/swift', 'build', '--package-path', s, '--build-path', b, '-c', build_mode, '--destination', destination_json] + extra_oeswift + + ret = subprocess.call(args, env=env, cwd=s) + if ret != 0: + bb.fatal('swift build failed') + + if d.getVar('SWIFT_BUILD_TESTS') == '1': + if d.getVar('DEBUG_BUILD') != '1': + bb.warn('building Swift tests with release build, @testable imports may fail') + + # FIXME: why do we need to specify -lXCTest and -lTesting explicitly + test_args = ['--build-tests', '-Xlinker', '-lXCTest', '-Xlinker', '-lTesting'] + ret = subprocess.call(args + test_args + extra_oeswift, env=env, cwd=s) + if ret != 0: + bb.fatal('swift build --build-tests failed') } -EXPORT_FUNCTIONS do_configure do_compile +do_package_update() { + cd ${S} + swift package update + + # Iterate over the search dirs for this recipes' files + # The first one that has a Package.resolved is the one bitbake got the file + # from in the first places + RESOLVED_PATH="" + for i in $(echo "${FILESPATH}" | tr ':' '\n'); do + if [ -r "${i}"/Package.resolved ]; then + RESOLVED_PATH="${i}/Package.resolved" + cp Package.resolved "${RESOLVED_PATH}" + bbwarn "Replaced ${RESOLVED_PATH} with updated Package.resolved." + break + fi + done + [ -z "${RESOLVED_PATH}" ] && bbwarn "Updated Package.resolved located at ${S}/Package.resolved" || : +} +do_package_update[network] = "1" +addtask do_package_update after do_configure -EXTRANATIVEPATH += "swift-tools" +EXPORT_FUNCTIONS do_package_resolve do_configure do_compile do_package_update diff --git a/conf/layer.conf b/conf/layer.conf index afa9241..0273513 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -9,4 +9,4 @@ BBFILE_COLLECTIONS += "swift-layer" BBFILE_PATTERN_swift-layer := "^${LAYERDIR}/" BBFILE_PRIORITY_swift-layer = "7" -LAYERSERIES_COMPAT_swift-layer = "dunfell" +LAYERSERIES_COMPAT_swift-layer = "scarthgap" diff --git a/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch b/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch new file mode 100644 index 0000000..aae1ca8 --- /dev/null +++ b/recipes-core/glibc/glibc/0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch @@ -0,0 +1,78 @@ +From: Khem Raj +Date: Thu, 26 Dec 2024 18:59:26 -0800 + +Upstream-Status: Pending +Signed-off-by: Luke Howard + +diff --git a/sysdeps/x86/bits/floatn.h b/sysdeps/x86/bits/floatn.h +--- b/sysdeps/x86/bits/floatn.h ++++ a/sysdeps/x86/bits/floatn.h +@@ -28,7 +28,8 @@ + support, for x86_64 and x86. */ + #if (defined __x86_64__ \ + ? __GNUC_PREREQ (4, 3) \ ++ : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \ ++ || __glibc_clang_prereq (3, 4) +- : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) + # define __HAVE_FLOAT128 1 + #else + # define __HAVE_FLOAT128 0 +@@ -58,7 +59,9 @@ + /* Defined to concatenate the literal suffix to be used with _Float128 + types, if __HAVE_FLOAT128 is 1. */ + # if __HAVE_FLOAT128 ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || defined __clang__ +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + /* The literal suffix f128 exists only since GCC 7.0. */ + # define __f128(x) x##q + # else +@@ -68,7 +71,9 @@ + + /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ + # if __HAVE_FLOAT128 ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || defined __clang__ +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + /* Add a typedef for older GCC compilers which don't natively support + _Complex _Float128. */ + typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__))); +@@ -82,12 +87,14 @@ + # if __HAVE_FLOAT128 + + /* The type _Float128 exists only since GCC 7.0. */ ++# if !__GNUC_PREREQ (7, 0) \ ++ || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) \ ++ || __glibc_clang_prereq (3, 4) +-# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) + typedef __float128 _Float128; + # endif + ++/* __builtin_huge_valf128 doesn't exist before GCC 7.0 nor Clang 7.0. */ ++# if !__GNUC_PREREQ (7, 0) && !__glibc_clang_prereq (7, 0) +-/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */ +-# if !__GNUC_PREREQ (7, 0) + # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ()) + # endif + +@@ -96,7 +103,7 @@ + Converting a narrower sNaN to _Float128 produces a quiet NaN, so + attempts to use _Float128 sNaNs will not work properly with older + compilers. */ ++# if !__GNUC_PREREQ (7, 0) && !defined __clang__ +-# if !__GNUC_PREREQ (7, 0) + # define __builtin_copysignf128 __builtin_copysignq + # define __builtin_fabsf128 __builtin_fabsq + # define __builtin_inff128() ((_Float128) __builtin_inf ()) +@@ -107,7 +114,8 @@ + /* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*, + e.g.: __builtin_signbitf128, before GCC 6. However, there has never + been a __builtin_signbitf128 in GCC and the type-generic builtin is ++ only available since GCC 6. signbit is expanded to __builtin_signbit ++ after Clang 3.3. */ +- only available since GCC 6. */ + # if !__GNUC_PREREQ (6, 0) + # define __builtin_signbitf128 __signbitf128 + # endif diff --git a/recipes-core/glibc/glibc_%.bbappend b/recipes-core/glibc/glibc_%.bbappend new file mode 100644 index 0000000..aeb47e2 --- /dev/null +++ b/recipes-core/glibc/glibc_%.bbappend @@ -0,0 +1,6 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += "\ + file://0001-x86-Define-__HAVE_FLOAT128-for-Clang.patch \ + " + diff --git a/recipes-devtools/swift/libdispatch.bb b/recipes-devtools/swift/libdispatch.bb index 446453a..5d7e0c5 100644 --- a/recipes-devtools/swift/libdispatch.bb +++ b/recipes-devtools/swift/libdispatch.bb @@ -1,18 +1,19 @@ - -SUMMARY = "Libdispatch" -HOMEPAGE = "https://github.com/apple/swift-corelibs-libdispatch" +SUMMARY = "libdispatch" +DESCRIPTION = "The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware" +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-libdispatch" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" require swift-version.inc -PV = "${SWIFT_VERSION}" +PV = "${SWIFT_VERSION}+git${SRCPV}" -SRC_URI = "git://github.com/apple/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1" +DEPENDS = "swift-stdlib" -DEPENDS = "swift-stdlib ncurses" +SRC_URI = "git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" S = "${WORKDIR}/git" +LIBDISPATCH_BUILDDIR = "${WORKDIR}/build" inherit swift-cmake-base @@ -22,15 +23,45 @@ TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" # Ensure the right CPU is targeted -cmake_do_generate_toolchain_file_append() { +cmake_do_generate_toolchain_file:append() { sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake } -do_install_append() { - # Copy cmake build modules - mkdir -p ${D}${libdir}/swift/dispatch/cmake - cp -rf ${WORKDIR}/build/cmake/modules/* ${D}${libdir}/swift/dispatch/cmake/ +do_install:append() { + # move the header files out of /usr/lib/swift and into /usr/include, + # because we want Swift C shims to be able to pick them up without fancy + # SwiftPM magic + install -d ${D}${includedir} + (cd ${D}${libdir}/swift; mv Block os dispatch ${D}${includedir}) + + # don't install CMake modules as they have absolute paths in them +# install -d ${D}${libdir}/cmake/dispatch +# install -m 0644 ${LIBDISPATCH_BUILDDIR}/cmake/modules/dispatchConfig.cmake ${D}${libdir}/cmake/dispatch/ +# install -m 0644 ${LIBDISPATCH_BUILDDIR}/cmake/modules/dispatchExports.cmake ${D}${libdir}/cmake/dispatch/ } -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" +FILES:${PN} = "\ + ${libdir}/swift/linux/libdispatch.so \ + ${libdir}/swift/linux/libswiftDispatch.so \ + ${libdir}/swift/linux/libBlocksRuntime.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftdoc \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftmodule \ + ${includedir}/Block \ + ${includedir}/os \ + ${includedir}/dispatch \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift_static/linux/libdispatch.a \ + ${libdir}/swift_static/linux/libswiftDispatch.a \ + ${libdir}/swift_static/linux/libBlocksRuntime.a \ + ${libdir}/swift_static/linux/libDispatchStubs.a \ + ${libdir}/swift_static/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftdoc \ + ${libdir}/swift_static/linux/${SWIFT_TARGET_ARCH}/Dispatch.swiftmodule \ + ${libdir}/swift_static/linux/dispatch \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/libfoundation.bb b/recipes-devtools/swift/libfoundation.bb deleted file mode 100644 index a740c13..0000000 --- a/recipes-devtools/swift/libfoundation.bb +++ /dev/null @@ -1,54 +0,0 @@ -SUMMARY = "The Foundation framework defines a base layer of functionality that is required for almost all applications." -HOMEPAGE = "https://github.com/apple/swift-corelibs-foundation" - -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" - -require swift-version.inc -PV = "${SWIFT_VERSION}" - -SRC_URI = "git://github.com/apple/swift-corelibs-foundation.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1" - -S = "${WORKDIR}/git" - -DEPENDS = "swift-stdlib libdispatch ncurses libxml2 icu curl" -RDEPENDS_${PN} += "swift-stdlib libdispatch" - -inherit swift-cmake-base - -TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" - -# Enable Swift parts -EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" -EXTRA_OECMAKE += '-DCMAKE_Swift_FLAGS="${SWIFT_FLAGS}"' -EXTRA_OECMAKE += '-DCMAKE_VERBOSE_MAKEFILE=ON' -EXTRA_OECMAKE += '-DCF_DEPLOYMENT_SWIFT=ON' -lcl_maybe_fortify="-D_FORTIFY_SOURCE=0" - -EXTRA_OECMAKE+= "-Ddispatch_DIR=${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/cmake" - -# Ensure the right CPU is targeted -cmake_do_generate_toolchain_file_append() { - sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake -} - -do_configure_append() { - # Workaround Dispatch defined with cmake and module - mkdir -p /tmp/dispatch - cp -rf ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap /tmp/dispatch/module.modulemap - rm -rf ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap -} - -do_install_append() { - # No need to install the plutil onto the target, so remove it for now - rm ${D}${bindir}/plutil - - # Since plutil was the only thing in the bindir, remove the bindir as well - rmdir ${D}${bindir} - - # Restore Dispatch - cp -rf /tmp/dispatch/module.modulemap ${STAGING_DIR_TARGET}/usr/lib/swift/dispatch/module.modulemap -} - -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch b/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch deleted file mode 100644 index 6d812d8..0000000 --- a/recipes-devtools/swift/libfoundation/0001-Make-FoundationConfig.cmake-not-depend-on-build-dir.patch +++ /dev/null @@ -1,153 +0,0 @@ -From dd935a79df0f931ec476b9df94598e923e3799f3 Mon Sep 17 00:00:00 2001 -From: Kevin Peizner -Date: Wed, 28 Oct 2020 14:24:16 -0700 -Subject: [PATCH] Make FoundationConfig.cmake not depend on build dir - -The default FoundationConfig.cmake generated file depends on the -generated FoundationExports.cmake file via a build dir specific path. - -Furthermore, the original FoundationExports.cmake contains build dir -specific paths. - -This breaks inclusion in other projects unless said project has access -to the build & src tree of libfoundation. - -This commit changes the FoundationConfig.cmake & FoundationExports.cmake -files so that the paths within them are based relative to the -installation of libfoundation. ---- - Sources/Foundation/CMakeLists.txt | 8 ++++--- - Sources/FoundationNetworking/CMakeLists.txt | 8 ++++--- - Sources/FoundationXML/CMakeLists.txt | 8 ++++--- - cmake/modules/CMakeLists.txt | 25 ++++++++++++++++----- - cmake/modules/FoundationConfig.cmake.in | 10 ++++++++- - 5 files changed, 44 insertions(+), 15 deletions(-) - -diff --git a/Sources/Foundation/CMakeLists.txt b/Sources/Foundation/CMakeLists.txt -index 5628fdae..103ab258 100644 ---- a/Sources/Foundation/CMakeLists.txt -+++ b/Sources/Foundation/CMakeLists.txt -@@ -149,8 +149,10 @@ target_link_libraries(Foundation - set_target_properties(Foundation PROPERTIES - INSTALL_RPATH "$ORIGIN" - BUILD_RPATH "$" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(Foundation INTERFACE -+ $ -+ $) - - if(CMAKE_SYSTEM_NAME STREQUAL Windows) - # NOTE: workaround for CMake which doesn't link in OBJECT libraries properly -@@ -163,7 +165,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation) --install(TARGETS Foundation -+install(TARGETS Foundation EXPORT FoundationExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/Sources/FoundationNetworking/CMakeLists.txt b/Sources/FoundationNetworking/CMakeLists.txt -index 2ea3924c..8c31a0ce 100644 ---- a/Sources/FoundationNetworking/CMakeLists.txt -+++ b/Sources/FoundationNetworking/CMakeLists.txt -@@ -63,8 +63,10 @@ target_link_libraries(FoundationNetworking - Foundation) - set_target_properties(FoundationNetworking PROPERTIES - INSTALL_RPATH "$ORIGIN" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(FoundationNetworking INTERFACE -+ $ -+ $) - - if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") - target_link_options(FoundationNetworking PRIVATE "SHELL:-no-toolchain-stdlib-rpath") -@@ -72,7 +74,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking) --install(TARGETS FoundationNetworking -+install(TARGETS FoundationNetworking EXPORT FoundationNetworkingExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/Sources/FoundationXML/CMakeLists.txt b/Sources/FoundationXML/CMakeLists.txt -index a11e0272..b573cc8e 100644 ---- a/Sources/FoundationXML/CMakeLists.txt -+++ b/Sources/FoundationXML/CMakeLists.txt -@@ -17,8 +17,10 @@ target_link_libraries(FoundationXML - Foundation) - set_target_properties(FoundationXML PROPERTIES - INSTALL_RPATH "$ORIGIN" -- Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift -- INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) -+ Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) -+target_include_directories(FoundationXML INTERFACE -+ $ -+ $) - - if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") - target_link_options(FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath") -@@ -26,7 +28,7 @@ endif() - - - set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML) --install(TARGETS FoundationXML -+install(TARGETS FoundationXML EXPORT FoundationXMLExports - ARCHIVE DESTINATION lib/swift$<$>:_static>/$ - LIBRARY DESTINATION lib/swift$<$>:_static>/$ - RUNTIME DESTINATION bin) -diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt -index 3dbaaace..02e971da 100644 ---- a/cmake/modules/CMakeLists.txt -+++ b/cmake/modules/CMakeLists.txt -@@ -1,7 +1,22 @@ - --set(Foundation_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/FoundationExports.cmake) --configure_file(FoundationConfig.cmake.in -- ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake) -+set(INCLUDE_INSTALL_DIR lib/swift) -+set(LIB_INSTALL_DIR lib/swift) -+ -+include(CMakePackageConfigHelpers) -+configure_package_config_file(FoundationConfig.cmake.in -+ ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake -+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake -+ PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR) -+ -+#write_basic_package_version_file( -+# ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfigVersion.cmake -+# VERSION 1.2.3 -+# COMPATIBILITY SameMajorVersion ) -+ -+install(EXPORT FoundationExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(EXPORT FoundationNetworkingExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(EXPORT FoundationXMLExports DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake) -+install(FILES -+ ${CMAKE_CURRENT_BINARY_DIR}/FoundationConfig.cmake -+ DESTINATION ${LIB_INSTALL_DIR}/Foundation/cmake ) - --get_property(Foundation_EXPORTS GLOBAL PROPERTY Foundation_EXPORTS) --export(TARGETS ${Foundation_EXPORTS} FILE ${Foundation_EXPORTS_FILE}) -diff --git a/cmake/modules/FoundationConfig.cmake.in b/cmake/modules/FoundationConfig.cmake.in -index 77f0b76f..30a58e28 100644 ---- a/cmake/modules/FoundationConfig.cmake.in -+++ b/cmake/modules/FoundationConfig.cmake.in -@@ -1,4 +1,12 @@ - -+@PACKAGE_INIT@ -+set_and_check(FOUNDATION_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") -+set_and_check(FOUNDATION_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") -+ -+check_required_components(Foundation) -+ - if(NOT TARGET Foundation) -- include(@Foundation_EXPORTS_FILE@) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationExports.cmake) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationNetworkingExports.cmake) -+ include(${FOUNDATION_LIB_DIR}/Foundation/cmake/FoundationXMLExports.cmake) - endif() diff --git a/recipes-devtools/swift/swift-foundation-essentials.bb b/recipes-devtools/swift/swift-foundation-essentials.bb new file mode 100644 index 0000000..f6c4e20 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials.bb @@ -0,0 +1,64 @@ +SUMMARY = "FoundationEssentials" +DESCRIPTION = "Foundation provides a base layer of functionality useful in many applications, including fundamental types for numbers, data, collections, and dates, as well as functions for task management, file system access, and more." +HOMEPAGE = "https://github.com/swiftlang/swift-foundation" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2380e856fbdbc7ccae6bd699d53ec121" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "foundation_icu_syntax_collections" + +SRC_URI = "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=${SWIFT_TAG};nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/apple/swift-collections.git;protocol=https;nobranch=1;name=collections;tag=1.1.4;destsuffix=swift-collections;" +SRC_URI += "file://0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch;striplevel=1;" +SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" + +S = "${WORKDIR}/git" + +DEPENDS = "icu swift-stdlib swift-native swift-foundation-icu" +RDEPENDS:${PN} += "icu swift-stdlib swift-foundation-icu" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +# Enable Swift parts +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" +EXTRA_OECMAKE += "-D_SwiftFoundationICU_SourceDIR=${WORKDIR}/swift-foundation-icu" +EXTRA_OECMAKE += "-D_SwiftCollections_SourceDIR=${WORKDIR}/swift-collections" +EXTRA_OECMAKE += "-DSwiftFoundation_MODULE_TRIPLE=${SWIFT_TARGET_NAME}" +EXTRA_OECMAKE += "-DSwiftSyntax_DIR=${WORKDIR}/swift-syntax/cmake/modules" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +do_install:append() { + # don't double up on Unicode + rm -rf ${D}${libdir}/swift/_foundation_unicode + rm -rf ${D}${libdir}/swift/linux/lib_FoundationICU.so +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libFoundationEssentials.so \ + ${libdir}/swift/linux/libFoundationInternationalization.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/_FoundationCShims/* \ + ${libdir}/swift/linux/FoundationEssentials.swiftmodule/* \ + ${libdir}/swift/linux/FoundationInternationalization.swiftmodule/* \ + ${libdir}/swift/linux/_FoundationCollections.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/lib_SwiftLibraryPluginProviderCShims.a \ + ${libdir}/swift_static/linux/libFoundationEssentials.a \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch b/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch new file mode 100644 index 0000000..efad4c6 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials/0001-build-with-64-bit-fsblkcnt_t-on-32-bit-glibc-platfor.patch @@ -0,0 +1,33 @@ +From 3eb8a04f9597ed71ddd3eb54db77a9d5e37f032d Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 11:58:13 +1000 +Subject: [PATCH 1/2] build with 64-bit fsblkcnt_t on 32-bit glibc platforms + +It is possible to build with 64-bit file offsets on 32-bit platforms such as +armv7, and indeed this is the default for some build environments such as +Yocto. Use fsblkcnt_t, which is an alias to a type of the correct width, when +computing blockSize. +--- + .../FoundationEssentials/FileManager/FileManager+Files.swift | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +index 64f8e21..824c3ac 100644 +--- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift ++++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +@@ -727,8 +727,12 @@ extension _FileManagerImpl { + let blockSize = UInt64(result.f_bsize) + #else + let fsNumber = result.f_fsid ++ #if canImport(Glibc) ++ let blockSize = fsblkcnt_t(result.f_frsize) // support 64-bit block sizes on 32-bit platforms ++ #else + let blockSize = UInt(result.f_frsize) + #endif ++ #endif + var totalSizeBytes = result.f_blocks * blockSize + var availSizeBytes = result.f_bavail * blockSize + var totalFiles = result.f_files +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch b/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch new file mode 100644 index 0000000..a955bea --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-essentials/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch @@ -0,0 +1,34 @@ +From ad2b4b35979caf1d66d77933dda66012f7108294 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 11:59:30 +1000 +Subject: [PATCH 2/2] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t), so for Glibc make it a private alias of time_t to fix +the build. +--- + .../FileManager/FileManager+Files.swift | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +index 824c3ac..c7ea78c 100644 +--- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift ++++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift +@@ -951,6 +951,12 @@ extension _FileManagerImpl { + #endif + } + ++ #if canImport(Glibc) ++ // support for 64-bit timestamps on 32-bit platforms; unfortunately ++ // suseconds_t is not an alias of the appropriate type, but time_t is ++ typealias suseconds_t = time_t ++ #endif ++ + if let date = attributes[.modificationDate] as? Date { + let (isecs, fsecs) = modf(date.timeIntervalSince1970) + if let tv_sec = time_t(exactly: isecs), +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-foundation-icu.bb b/recipes-devtools/swift/swift-foundation-icu.bb new file mode 100644 index 0000000..15225ed --- /dev/null +++ b/recipes-devtools/swift/swift-foundation-icu.bb @@ -0,0 +1,40 @@ +SUMMARY = "swift-foundation-icu" +DESCRIPTION = "This version of the ICU4C project contains customized extensions for use by the Foundation package." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-foundation-icu" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2380e856fbdbc7ccae6bd699d53ec121" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" + +SRC_URI = "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;" + +S = "${WORKDIR}/git" + +DEPENDS = "icu swift-stdlib" +RDEPENDS:${PN} += "swift-stdlib" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +# Enable Swift parts +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/lib_FoundationICU.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/_foundation_unicode/* \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH}/FoundationICU.swiftmodule/* \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/swift-foundation.bb b/recipes-devtools/swift/swift-foundation.bb new file mode 100644 index 0000000..470e5d9 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation.bb @@ -0,0 +1,85 @@ +SUMMARY = "Foundation" +DESCRIPTION = "The Foundation framework defines a base layer of functionality that is required for almost all applications." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-foundation" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "corelibs_foundation_icu_syntax" + +SRC_URI = "git://github.com/swiftlang/swift-corelibs-foundation.git;protocol=https;name=corelibs;tag=${SWIFT_TAG};nobranch=1;" +SRC_URI += "git://github.com/swiftlang/swift-foundation.git;protocol=https;name=foundation;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation;" +SRC_URI += "git://github.com/swiftlang/swift-foundation-icu.git;protocol=https;name=icu;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-foundation-icu;" +SRC_URI += "git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-syntax;" +SRC_URI += "file://0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch;striplevel=1;" +SRC_URI += "file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1;" + +S = "${WORKDIR}/git" + +DEPENDS = "swift-foundation-essentials swift-foundation-icu swift-stdlib swift-native libdispatch ncurses libxml2 icu curl" +RDEPENDS:${PN} += "swift-foundation-essentials swift-stdlib libdispatch" + +inherit swift-cmake-base + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}${libdir}/swift/linux" + +OECMAKE_C_FLAGS += "-I${STAGING_DIR_TARGET}${libdir}/swift" + +EXTRA_OECMAKE += "-DENABLE_SWIFT=YES" +EXTRA_OECMAKE += "-DCMAKE_VERBOSE_MAKEFILE=ON" +EXTRA_OECMAKE += "-DCF_DEPLOYMENT_SWIFT=ON" + +EXTRA_OECMAKE += "-D_SwiftFoundation_SourceDIR=${S}/swift-foundation" +EXTRA_OECMAKE += "-D_SwiftFoundationICU_SourceDIR=${S}/swift-foundation-icu" +EXTRA_OECMAKE += "-DSwiftFoundation_MODULE_TRIPLE=${SWIFT_TARGET_NAME}" + +EXTRA_OECMAKE += "-DCMAKE_FIND_ROOT_PATH:PATH=${CROSS_COMPILE_DEPS_PATH}" + +EXTRA_OECMAKE += "-Ddispatch_DIR=${STAGING_DIR_TARGET}${libdir}/cmake/dispatch" +EXTRA_OECMAKE += "-DSwiftSyntax_DIR=${STAGING_DIR_TARGET}${libdir}/cmake/dispatch" +EXTRA_OECMAKE += "-DENABLE_TESTING=0" +EXTRA_OECMAKE += "-DBUILD_SHARED_LIBS=YES" +EXTRA_OECMAKE += "-DDISPATCH_INCLUDE_PATH=${STAGING_DIR_TARGET}/${includedir}" + +# Ensure the right CPU is targeted +cmake_do_generate_toolchain_file:append() { + sed -i 's/set([ ]*CMAKE_SYSTEM_PROCESSOR .*[ ]*)/set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU_NAME})/' ${WORKDIR}/toolchain.cmake +} + +do_install:append() { + # don't double up on Unicode + rm -rf ${D}${libdir}/swift/_foundation_unicode + + # No need to install the plutil onto the target, so remove it for now + rm ${D}${bindir}/plutil + + # Since plutil was the only thing in the bindir, remove the bindir as well + rmdir ${D}${bindir} + + # Don't install CMake modules until absolute paths are corrected +# install -d ${D}${libdir}/cmake/Foundation +# install -m 0644 ${S}/cmake/modules/FoundationConfig.cmake ${D}${libdir}/cmake/Foundation +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libFoundation.so \ + ${libdir}/swift/linux/libFoundationNetworking.so \ + ${libdir}/swift/linux/libFoundationXML.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/CoreFoundation/* \ + ${libdir}/swift/linux/Foundation.swiftmodule/* \ + ${libdir}/swift/linux/FoundationNetworking.swiftmodule/* \ + ${libdir}/swift/linux/FoundationXML.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift/linux/libFoundation.a \ + ${libdir}/swift/linux/libFoundationNetworking.a \ + ${libdir}/swift/linux/libFoundationXML.a \ +" + +INSANE_SKIP:${PN} = "file-rdeps" diff --git a/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch b/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch new file mode 100644 index 0000000..d4437c1 --- /dev/null +++ b/recipes-devtools/swift/swift-foundation/0001-CFRunLoopTimerGetTolerance-CFRunLoopTimerSetToleranc.patch @@ -0,0 +1,44 @@ +From a38fd03fd9411ac5ffa94a523f0228f8ef75f058 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Tue, 4 Mar 2025 12:58:32 +1100 +Subject: [PATCH] CFRunLoopTimerGetTolerance/CFRunLoopTimerSetTolerance for + non-Mac + +--- + Sources/CoreFoundation/CFRunLoop.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/Sources/CoreFoundation/CFRunLoop.c b/Sources/CoreFoundation/CFRunLoop.c +index 91299fc5..3d2ed85d 100644 +--- a/Sources/CoreFoundation/CFRunLoop.c ++++ b/Sources/CoreFoundation/CFRunLoop.c +@@ -4735,18 +4735,13 @@ void CFRunLoopTimerGetContext(CFRunLoopTimerRef rlt, CFRunLoopTimerContext *cont + } + + CFTimeInterval CFRunLoopTimerGetTolerance(CFRunLoopTimerRef rlt) { +-#if TARGET_OS_MAC + CHECK_FOR_FORK(); + CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), CFTimeInterval, (NSTimer *)rlt, tolerance); + __CFGenericValidateType(rlt, CFRunLoopTimerGetTypeID()); + return rlt->_tolerance; +-#else +- return 0.0; +-#endif + } + + void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef rlt, CFTimeInterval tolerance) { +-#if TARGET_OS_MAC + CHECK_FOR_FORK(); + CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, setTolerance:tolerance); + __CFGenericValidateType(rlt, CFRunLoopTimerGetTypeID()); +@@ -4764,7 +4759,6 @@ void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef rlt, CFTimeInterval tolerance) + if (tolerance < 0) tolerance = 0.0; + rlt->_tolerance = tolerance; + } +-#endif + } + + #endif /* __HAS_DISPATCH__ */ +-- +2.39.5 (Apple Git-154) + diff --git a/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch b/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch new file mode 100644 index 0000000..a0484cb --- /dev/null +++ b/recipes-devtools/swift/swift-foundation/0002-build-with-64-bit-time_t-on-32-bit-platforms.patch @@ -0,0 +1,34 @@ +From 214f7205f8a4065c6b4b5ac3471167bd1edc475f Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 12:04:30 +1000 +Subject: [PATCH] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t), so for Glibc make it a private alias of time_t to fix +the build. +--- + Sources/Foundation/NSDate.swift | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Sources/Foundation/NSDate.swift b/Sources/Foundation/NSDate.swift +index ac7bd1bc..77579282 100644 +--- a/Sources/Foundation/NSDate.swift ++++ b/Sources/Foundation/NSDate.swift +@@ -30,6 +30,12 @@ extension TimeInterval { + #else + extension timeval { + internal init(_timeIntervalSince1970: TimeInterval) { ++ #if canImport(Glibc) ++ // support for 64-bit timestamps on 32-bit platforms; unfortunately ++ // suseconds_t is not an alias of the appropriate type, but time_t is ++ typealias suseconds_t = time_t ++ #endif ++ + let (integral, fractional) = modf(_timeIntervalSince1970) + self.init(tv_sec: time_t(integral), tv_usec: suseconds_t(1.0e6 * fractional)) + } +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-llvm-native.bb b/recipes-devtools/swift/swift-llvm-native.bb deleted file mode 100644 index 1b42f81..0000000 --- a/recipes-devtools/swift/swift-llvm-native.bb +++ /dev/null @@ -1,27 +0,0 @@ -SUMMARY = "Compiled Swift LLVM for Linux" -HOMEPAGE = "https://github.com/apple/llvm-project" - -LICENSE="CLOSED" -LIC_FILES_CHKSUM="" - -require swift-version.inc -PV = "${SWIFT_VERSION}" - -SRC_DIR = "llvm-swift" -SRC_URI = "https://github.com/colemancda/swift-armv7/releases/download/0.4.0/llvm-swift.zip" -SRC_URI[sha256sum] = "84c21ce101c6627f07d90f10df0448d4cb2848e6e2f96e544019207467dffca7" - -inherit native - -SYSROOT_DIRS_NATIVE += "${base_prefix}/opt" -S = "${WORKDIR}/${SRC_DIR}" - -do_install_append () { - mkdir -p ${D}${base_prefix}/opt/usr/lib/llvm-swift - cp -rf ${S}/../bin ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../include ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../lib ${D}${base_prefix}/opt/usr/lib/llvm-swift/ - cp -rf ${S}/../share ${D}${base_prefix}/opt/usr/lib/llvm-swift/ -} - -FILES_${PN} += "${base_prefix}/opt/*" diff --git a/recipes-devtools/swift/swift-native.bb b/recipes-devtools/swift/swift-native.bb index 6197e49..97e5fd6 100644 --- a/recipes-devtools/swift/swift-native.bb +++ b/recipes-devtools/swift/swift-native.bb @@ -1,5 +1,5 @@ -SUMMARY = "Swift toolchain for Linux" -HOMEPAGE = "https://swift.org/download/#releases" +SUMMARY = "Swift native toolchain for Linux" +HOMEPAGE = "https://swift.org/install/" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/usr/share/swift/LICENSE.txt;md5=f6c482a0548ea60d6c2e015776534035" @@ -7,13 +7,33 @@ LIC_FILES_CHKSUM = "file://${S}/usr/share/swift/LICENSE.txt;md5=f6c482a0548ea60d require swift-version.inc PV = "${SWIFT_VERSION}" -SRC_DIR = "swift-${PV}-RELEASE-ubuntu20.04" -SRC_URI = "https://download.swift.org/swift-${PV}-release/ubuntu2004/swift-${PV}-RELEASE/swift-${PV}-RELEASE-ubuntu20.04.tar.gz" -SRC_URI[sha256sum] = "b014975844beac5ab3a7f71420181f45d0a93243f9ea4853e6588c05cad1e363" +def swift_native_arch_suffix(d): + host_arch = d.getVar('HOST_ARCH') + if host_arch == 'x86_64': + return '' + else: + return f'-{host_arch}' + +def swift_native_arch_checksum(d): + sha256 = { + "x86_64": "3f4b7e2c9219a52fcecb7cb90153f9aacd3da85aa53e75e38dd406c0e9122551", + "aarch64": "9441091be33ca5d909337b8795f98e8234a52d79c197c6c015bca4b8994fbc87" + } + + host_arch = d.getVar('HOST_ARCH') + return sha256[host_arch] + +SWIFT_ARCH_SUFFIX = "${@swift_native_arch_suffix(d)}" + +SWIFT_LINUX_DISTRO = "amazonlinux2" + +SRC_DIR = "${SWIFT_TAG}-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}" +SRC_URI = "https://download.swift.org/swift-${SWIFT_VERSION}-release/${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}/${SWIFT_TAG}/${SWIFT_TAG}-${SWIFT_LINUX_DISTRO}${SWIFT_ARCH_SUFFIX}.tar.gz" +SRC_URI[sha256sum] = "${@swift_native_arch_checksum(d)}" DEPENDS = "curl" -RDEPENDS = "ncurses-native" - +RDEPENDS:${PN} = "ncurses-native" + S = "${WORKDIR}/${SRC_DIR}" inherit native @@ -21,31 +41,20 @@ inherit native ######################################################################## # This informs bitbake that we want to install a non-default directory # # in the native sysroot. # -# # -# We install the swift toolchain into opt to avoid conflicts with # -# other packages when installing. Ex: # -# # -# The file /usr/include/unicode/sortkey.h is installed by both # -# swift-native and icu-native, aborting # -# # ######################################################################## -SYSROOT_DIRS_NATIVE += "${base_prefix}/opt" - -do_install_append () { - install -d ${D}${base_prefix}/opt/usr/bin/ - cp -r ${S}/usr/bin/* ${D}${base_prefix}/opt/usr/bin/ - install -d ${D}${bindir}/ - ln -s ../../opt/usr/bin ${D}${bindir}/swift-tools +do_install:append () { + install -d ${D}${bindir} + cp -r ${S}/usr/bin/* ${D}${bindir} - install -d ${D}${base_prefix}/opt/usr/lib/ - cp -r ${S}/usr/lib/* ${D}${base_prefix}/opt/usr/lib/ + install -d ${D}${libdir} + cp -rd ${S}/usr/lib/* ${D}${libdir} - install -d ${D}${base_prefix}/opt/usr/include/ - cp -r ${S}/usr/include/* ${D}${base_prefix}/opt/usr/include/ + install -d ${D}${includedir} + cp -rd ${S}/usr/include/* ${D}${includedir} - install -d ${D}${base_prefix}/opt/usr/share/ - cp -r ${S}/usr/share/* ${D}${base_prefix}/opt/usr/share/ + install -d ${D}${datadir} + cp -rd ${S}/usr/share/* ${D}${datadir} } -FILES_${PN} += "${base_prefix}/opt/*" +FILES:${PN} += "${base_prefix}/*" diff --git a/recipes-devtools/swift/swift-stdlib.bb b/recipes-devtools/swift/swift-stdlib.bb index 6278ea5..6a7bbda 100644 --- a/recipes-devtools/swift/swift-stdlib.bb +++ b/recipes-devtools/swift/swift-stdlib.bb @@ -1,91 +1,261 @@ -SUMMARY = "Swift standard library" -HOMEPAGE = "https://swift.org/" +SUMMARY = "Swift" +DESCRIPTION = "The Swift programming language standard library" +HOMEPAGE = "https://github.com/swiftlang/swift" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${S}/LICENSE.txt;md5=f6c482a0548ea60d6c2e015776534035" +PACKAGES:append = " ${PN}-embedded" + require swift-version.inc -PV = "${SWIFT_VERSION}" +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "swift_libdispatch_stringproc_syntax" + +SRC_URI = "\ + git://github.com/swiftlang/llvm-project.git;protocol=https;name=llvm-project;tag=${SWIFT_TAG};nobranch=1;destsuffix=llvm-project; \ + git://github.com/swiftlang/swift.git;protocol=https;name=swift;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift; \ + git://github.com/swiftlang/swift-corelibs-libdispatch.git;protocol=https;name=libdispatch;tag=${SWIFT_TAG};nobranch=1;destsuffix=libdispatch; \ + git://github.com/swiftlang/swift-experimental-string-processing.git;protocol=https;name=stringproc;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-experimental-string-processing; \ + git://github.com/swiftlang/swift-syntax.git;protocol=https;name=syntax;tag=${SWIFT_TAG};nobranch=1;destsuffix=swift-syntax; \ + file://0001-add-arm-to-float16support-for-armv7.patch;striplevel=1; \ + file://0002-build-with-64-bit-time_t-on-32-bit-platforms.patch;striplevel=1; \ + " -SRC_URI = "git://github.com/apple/swift.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1 \ - file://0001-Float16.patch \ - file://fix_modulemap.sh \ - file://cmake-configure-swift-stdlib.sh \ - " -SRC_URI += "git://github.com/apple/swift-corelibs-libdispatch.git;protocol=https;tag=swift-${PV}-RELEASE;nobranch=1;destsuffix=libdispatch" +S = "${WORKDIR}/swift" -S = "${WORKDIR}/git" SWIFT_BUILDDIR = "${S}/build" -DEPENDS = "gcc-runtime python3-native icu ncurses" -DEPENDS += " swift-native swift-llvm-native libgcc gcc glibc libxml2" +DEPENDS = "gcc-runtime python3-native icu ncurses swift-native libgcc gcc glibc libxml2 libxml2-native ninja-native" inherit swift-cmake-base -HOST_SWIFT_SUPPORT_DIR = "${WORKDIR}/swift-stdlib-yocto" -SWIFT_CMAKE_TOOLCHAIN_FILE = "${HOST_SWIFT_SUPPORT_DIR}/linux-${SWIFT_TARGET_ARCH}-toolchain.cmake" -SWIFT_CONFIGURE_CMAKE_SCRIPT="${WORKDIR}/cmake-configure-swift-stdlib.sh" -EXTRA_INCLUDE_FLAGS = "\ - -I${STAGING_DIR_TARGET}/usr/include/c++/current/${TARGET_SYS} \ - -I${STAGING_DIR_TARGET}/usr/include/c++/current" -TARGET_LDFLAGS += "-w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current" -SWIFT_C_FLAGS = "-w -fuse-ld=lld -target ${SWIFT_TARGET_NAME} \ - --sysroot ${STAGING_DIR_TARGET} \ - -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ - -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/current \ - ${EXTRA_INCLUDE_FLAGS}" -SWIFT_C_LINK_FLAGS = "-target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} ${EXTRA_INCLUDE_FLAGS}" +TARGET_LDFLAGS:append = " -w -fuse-ld=lld -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION}" + +SWIFT_CMAKE_TOOLCHAIN_FILE = "${WORKDIR}/linux-${SWIFT_TARGET_ARCH}-toolchain.cmake" + +SWIFT_C_FLAGS = "${TARGET_CC_ARCH} -w -fuse-ld=lld -target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} -B${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} -L${STAGING_DIR_TARGET}/usr/lib/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include ${EXTRA_INCLUDE_FLAGS}" +SWIFT_C_LINK_FLAGS = "${TARGET_LD_ARCH} -target ${SWIFT_TARGET_NAME} --sysroot ${STAGING_DIR_TARGET} ${EXTRA_INCLUDE_FLAGS}" + SWIFT_CXX_FLAGS = "${SWIFT_C_FLAGS}" SWIFT_CXX_LINK_FLAGS = "${SWIFT_C_LINK_FLAGS}" +do_fix_gcc_install_dir() { + # symbolic links do not work, will not be found by Swift clang driver + # this is necessary to make the libstdc++ location heuristic work, necessary for C++ interop + (cd ${STAGING_DIR_TARGET}/usr/lib && rm -rf gcc && mkdir -p gcc && cp -rp ${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS} gcc) +} + +addtask fix_gcc_install_dir before do_configure after do_prepare_recipe_sysroot + do_configure() { - export LDFLAGS="" - export STAGING_DIR=${STAGING_DIR_TARGET} + export SDKROOT=${STAGING_DIR_TARGET} + export LLVM_SRCDIR=${WORKDIR}/llvm-project + export LLVM_BUILDDIR=${LLVM_SRCDIR}/build export SWIFT_SRCDIR=${S} - export LIBDISPATCH_SRCDIR=${WORKDIR}/libdispatch - export SWIFT_BUILDDIR="${SWIFT_BUILDDIR}" - export SWIFT_CMAKE_TOOLCHAIN_FILE=${SWIFT_CMAKE_TOOLCHAIN_FILE} - export SWIFT_NATIVE_PATH=${STAGING_DIR_NATIVE}/opt/usr/bin - export SWIFT_C_FLAGS="${SWIFT_C_FLAGS}" - export SWIFT_C_LINK_FLAGS="${SWIFT_C_LINK_FLAGS}" - export SWIFT_CXX_FLAGS="${SWIFT_CXX_FLAGS}" - export SWIFT_CXX_LINK_FLAGS="${SWIFT_CXX_LINK_FLAGS}" - export SWIFT_LLVM_DIR=${HOST_LLVM_PATH} - export CC=${STAGING_DIR_NATIVE}/opt/usr/bin/clang + export SWIFT_NATIVE_PATH=${STAGING_DIR_NATIVE}/usr/bin + export CC=${STAGING_DIR_NATIVE}/usr/bin/clang export CFLAGS="${SWIFT_C_FLAGS}" export CCLD="${SWIFT_C_LINK_FLAGS}" - export CXX=${STAGING_DIR_NATIVE}/opt/usr/bin/clang++ + export CXX=${STAGING_DIR_NATIVE}/usr/bin/clang++ export CXXFLAGS="${SWIFT_CXX_FLAGS}" - export SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH} - export SWIFT_TARGET_NAME=${SWIFT_TARGET_NAME} - mkdir -p ${HOST_SWIFT_SUPPORT_DIR} - rm -rf $SWIFT_BUILDDIR - mkdir -p $SWIFT_BUILDDIR - ${SWIFT_CONFIGURE_CMAKE_SCRIPT} + rm -rf ${LLVM_BUILDDIR} + mkdir -p ${LLVM_BUILDDIR} + + # Configure the llvm project to get the cmake files generated, so we can point + # LLVM_DIR to this folder + cmake -S ${LLVM_SRCDIR}/llvm -B ${LLVM_BUILDDIR} -G Ninja \ + -DCMAKE_INSTALL_PREFIX=${STAGING_DIR_NATIVE}/usr/lib \ + -DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \ + -DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \ + -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \ + -DLLVM_ENABLE_PROJECTS="llvm" \ + -DCMAKE_BUILD_TYPE=Release + + rm -rf ${SWIFT_BUILDDIR} + mkdir -p ${SWIFT_BUILDDIR} + + cat < ${SWIFT_CMAKE_TOOLCHAIN_FILE} +set(CMAKE_INSTALL_PREFIX /usr) +set(CMAKE_COLOR_MAKEFILE OFF) +set(CMAKE_CROSSCOMPILING ON) +set(CMAKE_BUILD_TYPE Release) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ${SWIFT_TARGET_ARCH}) +set(CMAKE_SYSROOT ${STAGING_DIR_TARGET}) + +set(CMAKE_C_COMPILER ${SWIFT_NATIVE_PATH}/clang) +set(CMAKE_C_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_C_FLAGS "${SWIFT_C_FLAGS}") +set(CMAKE_C_LINK_FLAGS "${SWIFT_C_LINK_FLAGS}") + +set(CMAKE_CXX_COMPILER ${SWIFT_NATIVE_PATH}/clang++) +set(CMAKE_CXX_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_CXX_FLAGS "${SWIFT_CXX_FLAGS}") +set(CMAKE_CXX_LINK_FLAGS "${SWIFT_CXX_LINK_FLAGS}") + +set(CMAKE_Swift_COMPILER ${SWIFT_NATIVE_PATH}/swiftc) +set(CMAKE_Swift_COMPILER_TARGET ${TARGET_SYS}) +set(CMAKE_Swift_COMPILER_WORKS ON) + +set(BUILD_DOC OFF) +set(BUILD_DOCS OFF) +set(BUILD_EXAMPLE OFF) +set(BUILD_EXAMPLES OFF) +set(BUILD_TEST OFF) +set(BUILD_TESTS OFF) +set(BUILD_TESTING OFF) +set(BUILD_SHARED_LIBS ON) + +set(LLVM_USE_LINKER lld) +set(LLVM_DIR ${LLVM_BUILDDIR}/lib/cmake/llvm) +set(LLVM_BUILD_LIBRARY_DIR ${LLVM_BUILDDIR}) +set(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN ON) + +set(SWIFT_USE_LINKER lld) +set(SWIFT_INCLUDE_TOOLS OFF) +set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER ON) +set(SWIFT_PREBUILT_CLANG ON) +set(SWIFT_NATIVE_CLANG_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_NATIVE_LLVM_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_NATIVE_SWIFT_TOOLS_PATH ${SWIFT_NATIVE_PATH}) +set(SWIFT_BUILD_AST_ANALYZER OFF) +set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY ON) +set(SWIFT_BUILD_DYNAMIC_STDLIB ON) +set(SWIFT_BUILD_REMOTE_MIRROR OFF) +set(SWIFT_BUILD_SOURCEKIT OFF) +set(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT OFF) +set(SWIFT_BUILD_SYNTAXPARSERLIB OFF) +set(SWIFT_ENABLE_SOURCEKIT_TESTS OFF) +set(SWIFT_INCLUDE_DOCS OFF) +set(SWIFT_INCLUDE_TOOLS OFF) +set(SWIFT_INCLUDE_TESTS OFF) +set(SWIFT_INCLUDE_TEST_BINARIES OFF) +set(SWIFT_LIBRARY_EVOLUTION 0) +set(SWIFT_RUNTIME_OS_VERSIONING OFF) +set(SWIFT_HOST_VARIANT_ARCH ${SWIFT_TARGET_ARCH}) +set(SWIFT_SDKS LINUX) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH ${STAGING_DIR_TARGET}) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY ${STAGING_DIR_TARGET}/usr/include) +set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY ${STAGING_DIR_TARGET}/usr/include) +set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N ${STAGING_DIR_TARGET}/usr/lib/libicui18n.so) +set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC ${STAGING_DIR_TARGET}/usr/lib/libicuuc.so) +set(SWIFT_PATH_TO_LIBDISPATCH_SOURCE ${WORKDIR}/libdispatch) +set(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ON) +set(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP ON) +set(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING ON) +set(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING ON) +set(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED ON) +set(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES ON) +set(SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION ON) +set(SWIFT_ENABLE_SYNCHRONIZATION ON) +set(SWIFT_PATH_TO_STRING_PROCESSING_SOURCE ${WORKDIR}/swift-experimental-string-processing) +set(SWIFT_SYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) +set(SWIFTSYNTAX_SOURCE_DIR ${WORKDIR}/swift-syntax) +set(SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS -Xcc --gcc-install-dir=${STAGING_DIR_TARGET}/usr/lib/gcc/${TARGET_SYS}/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION} -I${STAGING_DIR_TARGET}/usr/include/c++/${SWIFT_GCC_VERSION}/${TARGET_SYS} -no-verify-emitted-module-interface ${SWIFT_EXTRA_SWIFTC_CC_FLAGS}) +set(SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS "") + +set(ICU_I18N_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/libicui18n.so) +set(ICU_I18N_INCLUDE_DIRS ${STAGING_DIR_TARGET}/usr/include) +set(ICU_UC_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/libicuuc.so) +set(ICU_UC_INCLUDE_DIRS ${STAGING_DIR_TARGET}/usr/include) +set(LibRT_LIBRARIES ${STAGING_DIR_TARGET}/usr/lib/librt.a) +set(ZLIB_LIBRARY ${STAGING_DIR_TARGET}/usr/lib/libz.so) +EOF + + # pthreads does not work with armv7, so use c11 threading package in lieu + if [ "${SWIFT_TARGET_ARCH}" = "armv7" ]; then + echo "set(SWIFT_THREADING_PACKAGE c11)" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} + fi + + cmake -S ${SWIFT_SRCDIR} -B ${SWIFT_BUILDDIR} -G Ninja \ + -DSDKROOT=${STAGING_DIR_TARGET} \ + -DCMAKE_SYSROOT=${STAGING_DIR_TARGET} \ + -DCMAKE_TOOLCHAIN_FILE=${SWIFT_CMAKE_TOOLCHAIN_FILE} \ + -DSWIFT_HOST_VARIANT_ARCH=${SWIFT_TARGET_ARCH} \ + -DSWIFT_NATIVE_CLANG_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ + -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR_TARGET} \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR_TARGET}/usr/include \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY=${STAGING_DIR_TARGET}/usr/include } do_compile() { cd ${SWIFT_BUILDDIR} && ninja - # remove Swift static libs - rm -rf ${SWIFT_BUILDDIR}/lib/swift_static +} + +do_install:prepend() { # remove Dispatch (it will be built by another package) - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/libBlocksRuntime.so - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/libdispatch.so - rm -rf ${SWIFT_BUILDDIR}/lib/swift/linux/${SWIFT_TARGET_ARCH}/*.so - # remove some dirs from /usr/lib (we don't include them in any packages) - rm -rf ${SWIFT_BUILDDIR}/lib//swift/clang - rm -rf ${SWIFT_BUILDDIR}/lib//swift/FrameworkABIBaseline - # remove /usr/share (we don't include it in any packages) + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/libBlocksRuntime.so + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/libdispatch.so + rm -f ${SWIFT_BUILDDIR}/lib/swift/linux/${SWIFT_TARGET_ARCH}/*.so + + # remove some dirs from /lib/swift (we don't include them in any packages) + rm -rf ${SWIFT_BUILDDIR}/lib/swift/clang + rm -rf ${SWIFT_BUILDDIR}/lib/swift/FrameworkABIBaseline + + # remove /usr/share (we don't include it in any packages) rm -rf ${SWIFT_BUILDDIR}/share + # remove /usr/bin (we don't include it in any packages) rm -rf ${SWIFT_BUILDDIR}/bin } do_install() { + # install bridging and custom executor headers + install -d ${D}${includedir}/swift + install -m 0644 ${SWIFT_BUILDDIR}/include/swift/*.h ${D}${includedir}/swift + install -m 0644 ${S}/lib/ClangImporter/SwiftBridging/swift/bridging* ${D}${includedir}/swift + + # install libraries install -d ${D}${libdir} - cp -rf ${SWIFT_BUILDDIR}/lib/swift ${D}${libdir}/ + cp -rfd ${SWIFT_BUILDDIR}/lib/swift ${D}${libdir}/ } -FILES_${PN} = "${libdir}/swift/*" -INSANE_SKIP_${PN} = "file-rdeps" +FILES:${PN} = "\ + ${libdir}/swift/linux/libswift_RegexParser.so \ + ${libdir}/swift/linux/libswiftSwiftPrivateThreadExtras.so \ + ${libdir}/swift/linux/libswift_Concurrency.so \ + ${libdir}/swift/linux/libswift_Differentiation.so \ + ${libdir}/swift/linux/libswiftDifferentiationUnittest.so \ + ${libdir}/swift/linux/libswiftDistributed.so \ + ${libdir}/swift/linux/libswiftRegexBuilder.so \ + ${libdir}/swift/linux/libswiftObservation.so \ + ${libdir}/swift/linux/libswiftSwiftOnoneSupport.so \ + ${libdir}/swift/linux/libswiftSwiftPrivateLibcExtras.so \ + ${libdir}/swift/linux/libswiftRuntimeUnittest.so \ + ${libdir}/swift/linux/libswift_StringProcessing.so \ + ${libdir}/swift/linux/libswiftGlibc.so \ + ${libdir}/swift/linux/libswiftCore.so \ + ${libdir}/swift/linux/libswift_Builtin_float.so \ + ${libdir}/swift/linux/libswiftSwiftPrivate.so \ + ${libdir}/swift/linux/libswiftSynchronization.so \ + ${libdir}/swift/linux/libswiftStdlibUnittest.so \ +" + +FILES:${PN}-dev = "\ + ${includedir}/swift \ + ${libdir}/swift/shims \ + ${libdir}/swift/apinotes \ + ${libdir}/swift/linux/libswiftCommandLineSupport.a \ + ${libdir}/swift/linux/libswiftCxxStdlib.a \ + ${libdir}/swift/linux/libswiftCxx.a \ + ${libdir}/swift/linux/libcxxshim.modulemap \ + ${libdir}/swift/linux/libstdcxx.modulemap \ + ${libdir}/swift/linux/libstdcxx.h \ + ${libdir}/swift/linux/libcxxshim.h \ + ${libdir}/swift/linux/libcxxstdlibshim.h \ + ${libdir}/swift/linux/${SWIFT_TARGET_ARCH} \ + ${libdir}/swift/linux/*.swiftmodule/* \ +" + +FILES:${PN}-staticdev = "\ + ${libdir}/swift_static \ +" + +FILES:${PN}-embedded = "\ + ${libdir}/swift/embedded \ +" + +INSANE_SKIP:${PN} = "file-rdeps" + do_package_qa[noexec] = "1" diff --git a/recipes-devtools/swift/swift-stdlib/0001-Float16.patch b/recipes-devtools/swift/swift-stdlib/0001-Float16.patch deleted file mode 100644 index 56475f4..0000000 --- a/recipes-devtools/swift/swift-stdlib/0001-Float16.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 8b1dfbee0a542fe44b931f1d63bec253e320915b Mon Sep 17 00:00:00 2001 -From: Alsey Coleman Miller -Date: Fri, 11 Feb 2022 03:13:27 +0000 -Subject: [PATCH] Added Float16 patch - ---- - stdlib/public/runtime/Float16Support.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp -index 817739d4cdf..5ccd5639d67 100644 ---- a/stdlib/public/runtime/Float16Support.cpp -+++ b/stdlib/public/runtime/Float16Support.cpp -@@ -29,7 +29,7 @@ - - // Android NDK +Date: Fri, 28 Feb 2025 15:27:33 -0500 +Subject: [PATCH] Add __arm__ to Float16Support for missing symbol + +--- + stdlib/public/runtime/Float16Support.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp +index fa259559e45..dfa9c9876de 100644 +--- a/stdlib/public/runtime/Float16Support.cpp ++++ b/stdlib/public/runtime/Float16Support.cpp +@@ -31,7 +31,7 @@ + // Android NDK +Date: Sat, 28 Jun 2025 15:01:30 +1000 +Subject: [PATCH] build with 64-bit time_t on 32-bit platforms + +It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to +avoid the Y2038 issue. This is the default when building on Yocto for armv7, +for example. Unfortunately suseconds_t is not an alias to a type of the correct +width (unlike time_t). +--- + stdlib/public/Platform/Platform.swift | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift +index 0c2d63a0cff..4949fc66456 100644 +--- a/stdlib/public/Platform/Platform.swift ++++ b/stdlib/public/Platform/Platform.swift +@@ -439,7 +439,7 @@ extension timespec { + @available(SwiftStdlib 5.7, *) + public init(_ duration: Duration) { + let comps = duration.components +- self.init(tv_sec: Int(comps.seconds), ++ self.init(tv_sec: time_t(comps.seconds), + tv_nsec: Int(comps.attoseconds / 1_000_000_000)) + } + } +@@ -458,14 +458,18 @@ extension timeval { + public init(_ duration: Duration) { + let comps = duration.components + #if os(Linux) +- // Linux platforms define timeval as Int/Int +- self.init(tv_sec: Int(comps.seconds), +- tv_usec: Int(comps.attoseconds / 1_000_000_000_000)) ++ // Linux platforms define timeval as Int/Int, except on 32-bit platforms ++ // where _TIME_BITS=64 is defined. Abuse time_t as an alias for the correct ++ // suseconds_t type, as it is not an alias to the 64-bit type on 32-bit ++ // platforms. ++ typealias _Seconds = time_t ++ typealias _Microseconds = time_t + #else +- // Darwin platforms define timeval as Int/Int32 +- self.init(tv_sec: Int(comps.seconds), +- tv_usec: Int32(comps.attoseconds / 1_000_000_000_000)) ++ typealias _Seconds = Int ++ typealias _Microseconds = Int32 + #endif ++ self.init(tv_sec: _Seconds(comps.seconds), ++ tv_usec: _Microseconds(comps.attoseconds / 1_000_000_000_000)) + } + } + +-- +2.39.5 (Apple Git-154) + diff --git a/recipes-devtools/swift/swift-stdlib/cmake-configure-swift-stdlib.sh b/recipes-devtools/swift/swift-stdlib/cmake-configure-swift-stdlib.sh deleted file mode 100755 index f374b06..0000000 --- a/recipes-devtools/swift/swift-stdlib/cmake-configure-swift-stdlib.sh +++ /dev/null @@ -1,104 +0,0 @@ -echo "Generate cmake toolchain" -rm -f ${SWIFT_CMAKE_TOOLCHAIN_FILE} -touch ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_SYSTEM_NAME Linux)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_COMPILER $SWIFT_NATIVE_PATH/clang)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_COMPILER ${SWIFT_NATIVE_PATH}/clang++)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_FLAGS \"${SWIFT_C_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_C_LINK_FLAGS \"${SWIFT_C_LINK_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_FLAGS \"${SWIFT_CXX_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(CMAKE_CXX_LINK_FLAGS \"${SWIFT_CXX_LINK_FLAGS}\")\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_USE_LINKER lld)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_USE_LINKER lld)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_DIR ${SWIFT_LLVM_DIR}/lib/cmake/llvm)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_BUILD_LIBRARY_DIR ${SWIFT_LLVM_DIR})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TOOLS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_PREBUILT_CLANG ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_CLANG_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_LLVM_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_NATIVE_SWIFT_TOOLS_PATH ${SWIFT_NATIVE_PATH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_AST_ANALYZER OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_DYNAMIC_STDLIB ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_REMOTE_MIRROR OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_SOURCEKIT OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_SYNTAXPARSERLIB OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_BUILD_REMOTE_MIRROR OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_ENABLE_SOURCEKIT_TESTS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_DOCS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TOOLS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_INCLUDE_TESTS OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LIBRARY_EVOLUTION 0)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_RUNTIME_OS_VERSIONING OFF)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_HOST_VARIANT_ARCH ${SWIFT_TARGET_ARCH})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDKS LINUX)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH ${STAGING_DIR} )\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY ${STAGING_DIR}/usr/include )\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N ${STAGING_DIR}/usr/lib/libicui18n.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC ${STAGING_DIR}/usr/lib/libicuuc.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_I18N_LIBRARIES ${STAGING_DIR}/usr/lib/libicui18n.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_I18N_INCLUDE_DIRS ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_UC_LIBRARIES ${STAGING_DIR}/usr/lib/libicuuc.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ICU_UC_INCLUDE_DIRS ${STAGING_DIR}/usr/include)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(LibRT_LIBRARIES ${STAGING_DIR}/usr/lib/librt.a)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(ZLIB_LIBRARY ${STAGING_DIR}/usr/lib/libz.so)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_PATH_TO_LIBDISPATCH_SOURCE ${LIBDISPATCH_SRCDIR})\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - printf "set(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY ON)\n" >> ${SWIFT_CMAKE_TOOLCHAIN_FILE} - -echo "Configure Swift" -cmake -S $SWIFT_SRCDIR -B $SWIFT_BUILDDIR -G Ninja \ - -DCMAKE_INSTALL_PREFIX="/usr" \ - -DCMAKE_COLOR_MAKEFILE=OFF \ - -DBUILD_DOC=OFF \ - -DBUILD_DOCS=OFF \ - -DBUILD_EXAMPLE=OFF \ - -DBUILD_EXAMPLES=OFF \ - -DBUILD_TEST=OFF \ - -DBUILD_TESTS=OFF \ - -DBUILD_TESTING=OFF \ - -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_CROSSCOMPILING=ON \ - -DCMAKE_TOOLCHAIN_FILE=$SWIFT_CMAKE_TOOLCHAIN_FILE \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \ - -DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \ - -DCMAKE_C_FLAGS="${SWIFT_C_FLAGS}" \ - -DCMAKE_C_LINK_FLAGS="${SWIFT_C_LINK_FLAGS}" \ - -DCMAKE_CXX_FLAGS="${SWIFT_CXX_FLAGS}" \ - -DCMAKE_CXX_LINK_FLAGS="${SWIFT_CXX_LINK_FLAGS}" \ - -DSWIFT_USE_LINKER=lld \ - -DLLVM_USE_LINKER=lld \ - -DLLVM_DIR=${SWIFT_LLVM_DIR}/lib/cmake/llvm \ - -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ - -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=ON \ - -DSWIFT_NATIVE_CLANG_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ - -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=${SWIFT_NATIVE_PATH} \ - -DSWIFT_BUILD_AST_ANALYZER=OFF \ - -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=ON \ - -DSWIFT_BUILD_DYNAMIC_STDLIB=ON \ - -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ - -DSWIFT_BUILD_SOURCEKIT=OFF \ - -DSWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=OFF \ - -DSWIFT_BUILD_SYNTAXPARSERLIB=OFF \ - -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ - -DSWIFT_ENABLE_SOURCEKIT_TESTS=OFF \ - -DSWIFT_INCLUDE_DOCS=OFF \ - -DSWIFT_INCLUDE_TOOLS=OFF \ - -DSWIFT_INCLUDE_TESTS=OFF \ - -DSWIFT_LIBRARY_EVOLUTION=0 \ - -DSWIFT_RUNTIME_OS_VERSIONING=OFF \ - -DSWIFT_HOST_VARIANT_ARCH=$SWIFT_TARGET_ARCH \ - -DSWIFT_SDKS=LINUX \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ - -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N=${STAGING_DIR}/usr/lib/libicui18n.so \ - -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC=${STAGING_DIR}/usr/lib/libicuuc.so \ - -DICU_I18N_LIBRARIES=${STAGING_DIR}/usr/lib/libicui18n.so \ - -DICU_I18N_INCLUDE_DIRS=${STAGING_DIR}/usr/include \ - -DICU_UC_LIBRARIES=${STAGING_DIR}/usr/lib/libicuuc.so \ - -DICU_UC_INCLUDE_DIRS=${STAGING_DIR}/usr/include \ diff --git a/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh b/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh deleted file mode 100755 index e831c3a..0000000 --- a/recipes-devtools/swift/swift-stdlib/fix_modulemap.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -# See https://github.com/CSCIX65G/SwiftCrossCompilers/blob/master/build_cross_compiler#L34 -# This is a funny function. The Glibc.modulemap contains absolute include -# pathes like so: -# header "/usr/include/aarch64-linux-gnu/sys/ioctl.h" -# This thing creates a new directory: -# ${ARCH_NAME}-swift.xctoolchain/usr/lib/swift/linux/aarch64/private_includes -# and for each header in the modmap it creates a shim header which includes -# a relative path, like: -# ${ARCH_NAME}-swift.xctoolchain/usr/lib/swift/linux/aarch64/private_includes/aarch64-linux-gnu_sys_ioctl.h -# which includes: -# #include -function fix_glibc_modulemap() { - local glc_mm - local tmp - local inc_dir - - glc_mm="$1" - if ! test -f "$glc_mm"; then - echo "Missing: $glc_mm" - exit 42 - fi - - echo "step 1: $glc_mm" - - tmp=$(mktemp "$glc_mm"_orig_XXXXXX) - echo "step 2: $tmp" - inc_dir="$(dirname "$glc_mm")/private_includes" - echo "step 3: $inc_dir" - cat "$glc_mm" >>"$tmp" - echo -n >"$glc_mm" - rm -rf "$inc_dir" - mkdir "$inc_dir" - cat "$tmp" | while IFS='' read line; do - # hh: apparently the modmap started w/ two slashes? ///usr/local/ - # if [[ "$line" =~ ^(\ *header\ )\"\/\/\/usr\/include\/(${TC_TARGET}\/)?([^\"]+)\" ]]; then - if [[ "$line" =~ ^(\ *header\ )\"\/usr\/include\/(${TC_TARGET}\/)?([^\"]+)\" ]]; then - local orig_inc - local rel_repl_inc - local repl_inc - - orig_inc="${BASH_REMATCH[3]}" - rel_repl_inc="$(echo "$orig_inc" | tr / _)" - repl_inc="$inc_dir/$rel_repl_inc" - echo "${BASH_REMATCH[1]} \"$(basename "$inc_dir")/$rel_repl_inc\"" >>"$glc_mm" - if [[ "$orig_inc" == "uuid/uuid.h" ]]; then - # no idea why ;) - echo "#include " >>"$repl_inc" - elif [[ $orig_inc == *"gnueabi"* ]]; then - echo "#include <${orig_inc#*/}>" >>"$repl_inc" - else - echo "#include <$orig_inc>" >>"$repl_inc" - fi - true - else - echo "$line" >>"$glc_mm" - fi - done -} - - -fix_glibc_modulemap $1 diff --git a/recipes-devtools/swift/swift-testing.bb b/recipes-devtools/swift/swift-testing.bb new file mode 100644 index 0000000..cf84ebb --- /dev/null +++ b/recipes-devtools/swift/swift-testing.bb @@ -0,0 +1,42 @@ +SUMMARY = "swift-testing" +DESCRIPTION = "A package with expressive and intuitive APIs that make testing your Swift code a breeze." +HOMEPAGE = "https://github.com/swiftlang/swift-testing" + +SWIFT_BUILD_TESTS = "0" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=9426349f482bb39d6a4a080793545176" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" +SRCREV_FORMAT = "swift_testing" + +SRC_URI = "git://github.com/swiftlang/swift-testing.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" +SRC_URI += "file://0001-build-as-dynamic-library.patch;striplevel=1;" +SRC_URI += "file://0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch;striplevel=1;" + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +inherit swift + +do_install() { + install -d ${D}${libdir}/swift/linux + + install -m 0644 ${BUILD_DIR}/libTesting.so ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftmodule ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftdoc ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/Testing.swiftinterface ${D}${libdir}/swift/linux + + rm -f ${BUILD_DIR}/Modules/*.swiftsourceinfo +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libTesting.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/Testing.swiftmodule \ + ${libdir}/swift/linux/Testing.swiftdoc \ + ${libdir}/swift/linux/Testing.swiftinterface \ +" diff --git a/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch b/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch new file mode 100644 index 0000000..dd218ec --- /dev/null +++ b/recipes-devtools/swift/swift-testing/0001-build-as-dynamic-library.patch @@ -0,0 +1,35 @@ +From 150381e5bda561daa70b53aee1f222254bb4cf00 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Mon, 17 Mar 2025 10:14:02 +1100 +Subject: [PATCH] build as dynamic library + +--- + Package.swift | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Package.swift b/Package.swift +index c498b59..7065f6f 100644 +--- a/Package.swift ++++ b/Package.swift +@@ -28,6 +28,7 @@ let package = Package( + products: [ + .library( + name: "Testing", ++ type: .dynamic, + targets: ["Testing"] + ), + ], +@@ -45,7 +46,9 @@ let package = Package( + ], + exclude: ["CMakeLists.txt"], + cxxSettings: .packageSettings, +- swiftSettings: .packageSettings ++ swiftSettings: .packageSettings + [ ++ .unsafeFlags(["-enable-library-evolution", "-emit-module-interface", "-emit-module-interface-path", "Testing.swiftinterface"]) ++ ] + ), + .testTarget( + name: "TestingTests", +-- +2.43.0 + diff --git a/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch b/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch new file mode 100644 index 0000000..4fc6072 --- /dev/null +++ b/recipes-devtools/swift/swift-testing/0002-order-limits.h-before-stdlib.h-to-workaround-for-gli.patch @@ -0,0 +1,42 @@ +From 2ee53c692f781dff38dcbabe819ecfe841841588 Mon Sep 17 00:00:00 2001 +From: Luke Howard +Date: Sat, 28 Jun 2025 16:00:04 +1000 +Subject: [PATCH] order limits.h before stdlib.h to workaround for glibc + fortify source issue + +limits.h must be included before stdlib.h with glibc, otherwise the fortified +realpath() in this module's stdlib will differ from the one in SwiftGlibc. +--- + Sources/_TestingInternals/include/Includes.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/Sources/_TestingInternals/include/Includes.h b/Sources/_TestingInternals/include/Includes.h +index 1b95151..acc38df 100644 +--- a/Sources/_TestingInternals/include/Includes.h ++++ b/Sources/_TestingInternals/include/Includes.h +@@ -39,6 +39,11 @@ + #include + #include + #include ++#if __has_include() ++/// limits.h must be included before stdlib.h with glibc, otherwise the ++/// fortified realpath() in this module will differ from the one in SwiftGlibc. ++#include ++#endif + #include + #include + #include +@@ -97,10 +102,6 @@ + #include + #endif + +-#if __has_include() +-#include +-#endif +- + #if __has_include() + #include + #endif +-- +2.39.5 (Apple Git-154) + diff --git a/recipes-devtools/swift/swift-version.inc b/recipes-devtools/swift/swift-version.inc index 787737a..eda5f1b 100644 --- a/recipes-devtools/swift/swift-version.inc +++ b/recipes-devtools/swift/swift-version.inc @@ -1 +1,2 @@ -SWIFT_VERSION = "5.7.1" +SWIFT_VERSION = "6.1.2" +SWIFT_TAG = "swift-${SWIFT_VERSION}-RELEASE" diff --git a/recipes-devtools/swift/swift-xctest.bb b/recipes-devtools/swift/swift-xctest.bb new file mode 100644 index 0000000..4b69453 --- /dev/null +++ b/recipes-devtools/swift/swift-xctest.bb @@ -0,0 +1,39 @@ +SUMMARY = "swift-xctest" +DESCRIPTION = "A common framework for writing unit tests in Swift." +HOMEPAGE = "https://github.com/swiftlang/swift-corelibs-xctest" + +SWIFT_BUILD_TESTS = "0" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=1cd73afe3fb82e8d5c899b9d926451d0" + +require swift-version.inc +PV = "${SWIFT_VERSION}+git${SRCPV}" + +SRC_URI = "git://github.com/swiftlang/swift-corelibs-xctest.git;protocol=https;tag=${SWIFT_TAG};nobranch=1" + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +inherit swift + +TARGET_LDFLAGS += "-L${STAGING_DIR_TARGET}/usr/lib/swift/linux" + +do_install() { + install -d ${D}${libdir}/swift/linux + + install -m 0755 ${BUILD_DIR}/libXCTest.so ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/XCTest.swiftmodule ${D}${libdir}/swift/linux + install -m 0644 ${BUILD_DIR}/Modules/XCTest.swiftdoc ${D}${libdir}/swift/linux + + rm -f ${BUILD_DIR}/Modules/XCTest.swiftsourceinfo +} + +FILES:${PN} = "\ + ${libdir}/swift/linux/libXCTest.so \ +" + +FILES:${PN}-dev = "\ + ${libdir}/swift/linux/XCTest.swiftmodule \ + ${libdir}/swift/linux/XCTest.swiftdoc \ +" diff --git a/recipes-support/icu/icu-swift.inc b/recipes-support/icu/icu-swift.inc deleted file mode 100644 index 1428b9e..0000000 --- a/recipes-support/icu/icu-swift.inc +++ /dev/null @@ -1,65 +0,0 @@ -SUMMARY = "International Component for Unicode libraries" -DESCRIPTION = "The International Component for Unicode (ICU) is a mature, \ -portable set of C/C++ and Java libraries for Unicode support, software \ -internationalization (I18N) and globalization (G11N), giving applications the \ -same results on all platforms." -HOMEPAGE = "http://site.icu-project.org/" - -LICENSE = "ICU" -DEPENDS = "icu-swift-native" -DEPENDS_class-native = "" - -S = "${WORKDIR}/icu/source" -SPDX_S = "${WORKDIR}/icu" -STAGING_ICU_DIR_NATIVE = "${STAGING_DATADIR_NATIVE}/${BPN}/${PV}" - -CPPFLAGS_append_libc-uclibc = " -DU_TIMEZONE=0" - -inherit autotools pkgconfig - -# ICU needs the native build directory as an argument to its --with-cross-build option when -# cross-compiling. Taken the situation that different builds may share a common sstate-cache -# into consideration, the native build directory needs to be staged. -EXTRA_OECONF = "--with-cross-build=${STAGING_ICU_DIR_NATIVE}" -EXTRA_OECONF_class-native = "" -EXTRA_OECONF_class-nativesdk = "--with-cross-build=${STAGING_ICU_DIR_NATIVE}" - -PREPROCESS_RELOCATE_DIRS = "${datadir}/${BPN}/${PV}" -do_install_append_class-native() { - mkdir -p ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/config/icucross.mk ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/config/icucross.inc ${D}/${STAGING_ICU_DIR_NATIVE}/config - cp -r ${B}/lib ${D}/${STAGING_ICU_DIR_NATIVE} - cp -r ${B}/bin ${D}/${STAGING_ICU_DIR_NATIVE} - cp -r ${B}/tools ${D}/${STAGING_ICU_DIR_NATIVE} - - rm -r ${D}${STAGING_BINDIR_NATIVE} - rm -r ${D}${STAGING_SBINDIR_NATIVE} - rm -r ${D}${STAGING_LIBDIR_NATIVE} - rm -r ${D}${STAGING_DATADIR_NATIVE}/icu -} - -do_install_append() { - rm -rf ${D}/usr/lib/icu - rm -rf ${D}/usr/share/icu - rm -f ${D}/${libdir}/*.so - rm -rf ${D}/${bindir} - rm -rf ${D}/usr/sbin - rm -rf ${D}/${includedir} - rm -rf ${D}/usr/lib/pkgconfig -} - -PACKAGES =+ "libicudata-swift libicuuc-swift libicui18n-swift libicule-swift libiculx-swift libicutu-swift libicuio-swift" - -FILES_${PN}-dev += "${libdir}/${BPN}/" - -FILES_libicudata-swift = "${libdir}/libicudata.so.*" -FILES_libicuuc-swift = "${libdir}/libicuuc.so.*" -FILES_libicui18n-swift = "${libdir}/libicui18n.so.*" -FILES_libicule-swift = "${libdir}/libicule.so.*" -FILES_libiculx-swift = "${libdir}/libiculx.so.*" -FILES_libicutu-swift = "${libdir}/libicutu.so.*" -FILES_libicuio-swift = "${libdir}/libicuio.so.*" - -BBCLASSEXTEND = "native" - diff --git a/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch b/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch deleted file mode 100644 index 2968d57..0000000 --- a/recipes-support/icu/icu-swift/0001-Disable-LDFLAGSICUDT-for-Linux.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0c82d6aa02c08e41b13c83b14782bd7024e25d59 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sat, 15 Feb 2014 21:06:42 +0000 -Subject: [PATCH] Disable LDFLAGSICUDT for Linux - -Upstream-Status: Inappropriate [ OE Configuration ] - -Signed-off-by: Khem Raj ---- - source/config/mh-linux | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/config/mh-linux b/config/mh-linux -index 366f0cc..2689aab 100644 ---- a/config/mh-linux -+++ b/config/mh-linux -@@ -21,7 +21,7 @@ LD_RPATH= -Wl,-zorigin,-rpath,'$$'ORIGIN - LD_RPATH_PRE = -Wl,-rpath, - - ## These are the library specific LDFLAGS --LDFLAGSICUDT=-nodefaultlibs -nostdlib -+# LDFLAGSICUDT=-nodefaultlibs -nostdlib - - ## Compiler switch to embed a library name - # The initial tab in the next line is to prevent icu-config from reading it. --- -1.7.10.4 - diff --git a/recipes-support/icu/icu-swift/fix-install-manx.patch b/recipes-support/icu/icu-swift/fix-install-manx.patch deleted file mode 100644 index ec63f50..0000000 --- a/recipes-support/icu/icu-swift/fix-install-manx.patch +++ /dev/null @@ -1,48 +0,0 @@ -The generic recursive target calls target-local so also adding it to the -dependency list results in races due to install-local being executed twice in -parallel. For example, install-manx can fail if the two install processes race -and one process tries to chown a file that the other process has just deleted. - -Also install-manx should be a phony target, and for clarity use $^ instead of $? -in the install command. - -Upstream-Status: Pending -Signed-off-by: Ross Burton - - -diff --git a/Makefile.in b/Makefile.in -index 9db6c52..3441afa 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -71,7 +71,7 @@ EXTRA_DATA = - - ## List of phony targets - .PHONY : all all-local all-recursive install install-local install-udata install-udata-files install-udata-dlls \ --install-recursive clean clean-local clean-recursive distclean \ -+install-recursive install-manx clean clean-local clean-recursive distclean \ - distclean-local distclean-recursive doc dist dist-local dist-recursive \ - check check-local check-recursive clean-recursive-with-twist install-icu \ - doc install-doc tests icu4j-data icu4j-data-install update-windows-makefiles xcheck-local xcheck-recursive xperf xcheck xperf-recursive \ -@@ -82,10 +82,10 @@ check-exhaustive check-exhaustive-local check-exhaustive-recursive releaseDist - - ## List of standard targets - all: all-local all-recursive --install: install-recursive install-local -+install: install-recursive - clean: clean-recursive-with-twist clean-local --distclean : distclean-recursive distclean-local --dist: dist-recursive dist-local -+distclean : distclean-recursive -+dist: dist-recursive - check: all check-recursive - check-recursive: all - xcheck: all xcheck-recursive -@@ -352,7 +352,7 @@ config.status: $(srcdir)/configure $(srcdir)/common/unicode/uvernum.h - - install-manx: $(MANX_FILES) - $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION) -- $(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION) -+ $(INSTALL_DATA) $^ $(DESTDIR)$(mandir)/man$(SECTION) - - config/%.$(SECTION): $(srcdir)/config/%.$(SECTION).in - cd $(top_builddir) \ diff --git a/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch b/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch deleted file mode 100644 index 6e40659..0000000 --- a/recipes-support/icu/icu-swift/icu-pkgdata-large-cmd.patch +++ /dev/null @@ -1,29 +0,0 @@ -pkgdata.cpp: use LARGE_BUFFER_MAX_SIZE for cmd - -Use LARGE_BUFFER_MAX_SIZE for cmd rather than SMALL_BUFFER_MAX_SIZE, -otherwise there was a Segmentation fault error when the command line is -long, this should be a misplay since other cmd uses -LARGE_BUFFER_MAX_SIZE. - -Upstream-Status: Pending - -Signed-off-by: Robert Yang ---- - tools/pkgdata/pkgdata.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/pkgdata/pkgdata.cpp b/tools/pkgdata/pkgdata.cpp ---- a/tools/pkgdata/pkgdata.cpp -+++ b/tools/pkgdata/pkgdata.cpp -@@ -1019,7 +1019,7 @@ normal_symlink_mode: - - static int32_t pkg_installLibrary(const char *installDir, const char *targetDir, UBool noVersion) { - int32_t result = 0; -- char cmd[SMALL_BUFFER_MAX_SIZE]; -+ char cmd[LARGE_BUFFER_MAX_SIZE]; - - sprintf(cmd, "cd %s && %s %s %s%s%s", - targetDir, --- -1.7.10.4 - diff --git a/recipes-support/icu/icu-swift_55.1.bb b/recipes-support/icu/icu-swift_55.1.bb deleted file mode 100644 index 6a91ea6..0000000 --- a/recipes-support/icu/icu-swift_55.1.bb +++ /dev/null @@ -1,25 +0,0 @@ -require icu-swift.inc - -LIC_FILES_CHKSUM = "file://../license.html;md5=64eff4aadff4d104d6d437c4fde0e6d7" - -def icu_download_version(d): - pvsplit = d.getVar('PV', True).split('.') - return pvsplit[0] + "_" + pvsplit[1] - -ICU_PV = "${@icu_download_version(d)}" - -# http://errors.yoctoproject.org/Errors/Details/20486/ -ARM_INSTRUCTION_SET_armv4 = "arm" -ARM_INSTRUCTION_SET_armv5 = "arm" - -BASE_SRC_URI = "http://download.icu-project.org/files/icu4c/${PV}/icu4c-${ICU_PV}-src.tgz" -SRC_URI = "${BASE_SRC_URI} \ - file://icu-pkgdata-large-cmd.patch \ - file://fix-install-manx.patch \ - " - -SRC_URI_append_class-target = "\ - file://0001-Disable-LDFLAGSICUDT-for-Linux.patch \ - " -SRC_URI[md5sum] = "e2d523df79d6cb7855c2fbe284f4db29" -SRC_URI[sha256sum] = "e16b22cbefdd354bec114541f7849a12f8fc2015320ca5282ee4fd787571457b" diff --git a/recipes-test/swift-hello-world/files/Package.swift b/recipes-test/swift-hello-world/files/Package.swift index be660c9..c106ba8 100644 --- a/recipes-test/swift-hello-world/files/Package.swift +++ b/recipes-test/swift-hello-world/files/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.6 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -12,8 +12,16 @@ let package = Package( targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( + .executableTarget( name: "hello-world", - dependencies: []) + dependencies: [], + swiftSettings: [ + .swiftLanguageMode(.v5), + .interoperabilityMode(.Cxx), + ] + ), + .testTarget( + name: "hello-world-test", + dependencies: []), ] ) diff --git a/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift b/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift index 14f6d40..c65c8ed 100644 --- a/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift +++ b/recipes-test/swift-hello-world/files/Sources/hello-world/main.swift @@ -1,10 +1,11 @@ import Foundation import Dispatch import Glibc +import CxxStdlib func main() async throws { print("Hello, world! 👋") - try await Task.sleep(1_000_000_000) + try await Task.sleep(for: .seconds(1)) print("User: \(ProcessInfo.processInfo.fullUserName)") let dateFormatter = DateFormatter() dateFormatter.dateStyle = .full diff --git a/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift b/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift new file mode 100644 index 0000000..807c3ad --- /dev/null +++ b/recipes-test/swift-hello-world/files/Tests/hello-world-test/hello-world-test.swift @@ -0,0 +1,8 @@ +import XCTest +import Testing + +final class TestTest: XCTestCase { + func testSomething() { + XCTAssertEqual(true, true) + } +} diff --git a/recipes-test/swift-hello-world/swift-hello-world.bb b/recipes-test/swift-hello-world/swift-hello-world.bb index 77a0fc1..15fb6ae 100644 --- a/recipes-test/swift-hello-world/swift-hello-world.bb +++ b/recipes-test/swift-hello-world/swift-hello-world.bb @@ -1,8 +1,23 @@ -DESCRIPTION = "swift 5.6.1 test application" +DESCRIPTION = "Swift Hello World!" LICENSE = "CLOSED" -SRC_URI = "file://Sources/hello-world/main.swift \ - file://Package.swift \ +SWIFT_BUILD_TESTS = "1" + +RDEPENDS:${PN} += "swift-xctest swift-testing" + +SRC_URI = "\ + file://Package.swift \ + file://Sources \ + file://Tests \ " +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + inherit swift + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${BUILD_DIR}/hello-world ${D}${bindir} + install -m 0755 ${BUILD_DIR}/hello-worldPackageTests.xctest ${D}${bindir} +} diff --git a/recipes-test/swift/swift-build-test.bb b/recipes-test/swift/swift-build-test.bb deleted file mode 100644 index 1fc6c1c..0000000 --- a/recipes-test/swift/swift-build-test.bb +++ /dev/null @@ -1,9 +0,0 @@ -DESCRIPTION = "swift 5.1.2 test application" -LICENSE = "CLOSED" - -SRC_URI = "file://Sources/hello-world/main.swift \ - file://Package.swift \ -" - -inherit swift - diff --git a/recipes-test/swift/swift-build-test/Package.swift b/recipes-test/swift/swift-build-test/Package.swift deleted file mode 100644 index 43e8841..0000000 --- a/recipes-test/swift/swift-build-test/Package.swift +++ /dev/null @@ -1,19 +0,0 @@ -// swift-tools-version:5.1 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "hello-world", - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( - name: "hello-world", - dependencies: []) - ] -) diff --git a/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift b/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift deleted file mode 100644 index a43bbc4..0000000 --- a/recipes-test/swift/swift-build-test/Sources/hello-world/main.swift +++ /dev/null @@ -1,4 +0,0 @@ -import Dispatch -import Foundation - -print("Hello, world!") diff --git a/recipes-test/swift/swift-cmake-test.bb b/recipes-test/swift/swift-cmake-test.bb deleted file mode 100644 index d9a15fc..0000000 --- a/recipes-test/swift/swift-cmake-test.bb +++ /dev/null @@ -1,12 +0,0 @@ -SUMMARY = "Swift standard library testing package" - -LICENSE = "CLOSED" - -SRC_URI = "file://main.swift \ - file://CMakeLists.txt \ -" - -inherit swift-cmake - -S = "${WORKDIR}" - diff --git a/recipes-test/swift/swift-cmake-test/CMakeLists.txt b/recipes-test/swift/swift-cmake-test/CMakeLists.txt deleted file mode 100644 index 3b3266a..0000000 --- a/recipes-test/swift/swift-cmake-test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.16.3) - -project(HelloWorld - LANGUAGES C Swift) - -add_executable(hello main.swift) - -install(TARGETS hello RUNTIME DESTINATION bin) diff --git a/recipes-test/swift/swift-cmake-test/main.swift b/recipes-test/swift/swift-cmake-test/main.swift deleted file mode 100644 index b01292c..0000000 --- a/recipes-test/swift/swift-cmake-test/main.swift +++ /dev/null @@ -1,4 +0,0 @@ -import Dispatch -import Foundation - -print("hello world")