diff --git a/.github/workflows/swift-arm.yml b/.github/workflows/swift-arm.yml new file mode 100644 index 0000000..5fc04f3 --- /dev/null +++ b/.github/workflows/swift-arm.yml @@ -0,0 +1,87 @@ +name: Swift ARM +on: [push] +jobs: + + linux-arm-raspios-build: + name: Linux (Build) + runs-on: ubuntu-latest + strategy: + matrix: + config: ["debug" , "release"] + swift: ["6.1.2"] + linux: ["raspios"] + release: ["bookworm"] + arch: ["armv6", "armv7"] + container: swift:${{ matrix.swift }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies + run: apt update -y; apt install wget -y + - name: Install SDK + run: | + wget https://github.com/xtremekforever/swift-armv7/releases/download/${{ matrix.swift }}/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}-sdk.tar.gz + tar -xvf swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}-sdk.tar.gz + mv swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }} /opt/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }} + - name: Swift Version + run: swift --version + - name: Build + run: SWIFT_BUILD_DYNAMIC_LIBRARY=1 swift build -c ${{ matrix.config }} --destination /opt/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}/${{ matrix.linux }}-${{ matrix.release }}.json + + linux-arm-debian-build: + name: Linux (Build) + runs-on: ubuntu-latest + strategy: + matrix: + config: ["debug" , "release"] + swift: ["6.1.2"] + linux: ["debian"] + release: ["bookworm", "bullseye"] + arch: ["armv7"] + container: swift:${{ matrix.swift }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies + run: apt update -y; apt install wget -y + - name: Install SDK + run: | + wget https://github.com/xtremekforever/swift-armv7/releases/download/${{ matrix.swift }}/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}-sdk.tar.gz + tar -xvf swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}-sdk.tar.gz + mv swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }} /opt/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }} + - name: Swift Version + run: swift --version + - name: Build + run: SWIFT_BUILD_DYNAMIC_LIBRARY=1 swift build -c ${{ matrix.config }} --destination /opt/swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}/${{ matrix.linux }}-${{ matrix.release }}.json + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: "swift-${{ matrix.swift }}-RELEASE-${{ matrix.linux }}-${{ matrix.release }}-${{ matrix.arch }}-binder-${{ matrix.config }}" + path: .build/armv7-unknown-linux-gnueabihf/${{ matrix.config }}/libBinder.so + + linux-arm-test: + name: Linux (Test) + runs-on: ubuntu-latest + strategy: + matrix: + swift: ["6.0.3"] + container: swift:${{ matrix.swift }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies + run: apt update -y; apt install wget -y + - name: Install SDK + run: | + wget https://github.com/xtremekforever/swift-armv7/releases/download/${{ matrix.swift }}/swift-${{ matrix.swift }}-RELEASE-debian-bookworm-armv7-sdk.tar.gz + tar -xvf swift-${{ matrix.swift }}-RELEASE-debian-bookworm-armv7-sdk.tar.gz + mv swift-${{ matrix.swift }}-RELEASE-debian-bookworm-armv7 /opt/swift-${{ matrix.swift }}-RELEASE-debian-bookworm-armv7 + - name: Swift Version + run: swift --version + - name: Build + run: SWIFT_BUILD_DYNAMIC_LIBRARY=0 swift build --build-tests --destination /opt/swift-${{ matrix.swift }}-RELEASE-debian-bookworm-armv7/debian-bookworm.json + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: "linux-armv7-bookworm-tests-${{ matrix.swift }}" + path: .build/armv7-unknown-linux-gnueabihf/debug/BinderPackageTests.xctest diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 0e6ea7d..d658cf2 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -5,23 +5,27 @@ jobs: macos: name: macOS runs-on: macos-15 + strategy: + matrix: + config: ["debug", "release"] + options: ["", "SWIFT_BUILD_DYNAMIC_LIBRARY=1"] steps: - name: Checkout uses: actions/checkout@v4 - name: Swift Version run: swift --version - - name: Build (Debug) - run: swift build -c debug - - name: Build (Release) - run: swift build -c release - - name: Test (Debug) - run: swift test -c debug + - name: Build + run: ${{ matrix.options }} swift build -c ${{ matrix.config }} + - name: Test + run: ${{ matrix.options }} swift test -c ${{ matrix.config }} - linux-x86: + linux: name: Linux strategy: matrix: - container: ["swift:6.0.3", "swift:6.1.1", "swiftlang/swift:nightly"] + container: ["swift:6.0.3", "swift:6.1.2"] + config: ["debug", "release"] + options: ["", "SWIFT_BUILD_DYNAMIC_LIBRARY=1"] runs-on: ubuntu-latest container: ${{ matrix.container }}-jammy steps: @@ -29,48 +33,22 @@ jobs: uses: actions/checkout@v4 - name: Swift Version run: swift --version - - name: Build (Debug) - run: swift build -c debug --build-tests - - name: Build (Release) - run: swift build -c release + - name: Build + run: ${{ matrix.options }} swift build -c ${{ matrix.config }} - linux-armv7: - name: Armv7 Debian Bookworm - runs-on: ubuntu-latest - container: swift:6.0.3 + android-arm: + name: Android + strategy: + fail-fast: false + matrix: + swift: ['6.1', 'nightly-6.2'] + arch: ["aarch64", "x86_64"] + runs-on: macos-15 + timeout-minutes: 30 steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install dependencies - run: apt update -y; apt install wget -y - - name: Install SDK + - uses: actions/checkout@v4 + - name: "Build Swift Package for Android" run: | - wget https://github.com/xtremekforever/swift-armv7/releases/download/6.0.3/swift-6.0.3-RELEASE-debian-bookworm-armv7-sdk.tar.gz - tar -xvf swift-6.0.3-RELEASE-debian-bookworm-armv7-sdk.tar.gz - mv swift-6.0.3-RELEASE-debian-bookworm-armv7 /opt/swift-6.0.3-RELEASE-debian-bookworm-armv7 - - name: Swift Version - run: swift --version - - name: Build - run: swift build --build-tests --destination /opt/swift-6.0.3-RELEASE-debian-bookworm-armv7/debian-bookworm.json - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: "armv7-bookworm" - path: .build/armv7-unknown-linux-gnueabihf/debug/BinderPackageTests.xctest - - android: - name: Android - strategy: - fail-fast: false - matrix: - swift: ['6.1', 'nightly-6.2'] - runs-on: macos-15 - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - name: "Build Swift Package for Android" - run: | - brew install skiptools/skip/skip || (brew update && brew install skiptools/skip/skip) - skip android sdk install --version ${{ matrix.swift }} - # https://github.com/swiftlang/swift-driver/pull/1879 - ANDROID_NDK_ROOT="" skip android build \ No newline at end of file + brew install skiptools/skip/skip || (brew update && brew install skiptools/skip/skip) + skip android sdk install --version ${{ matrix.swift }} + ANDROID_NDK_ROOT="" skip android build --arch ${{ matrix.arch }} \ No newline at end of file diff --git a/Package.swift b/Package.swift index f763de5..fe8eae8 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,10 @@ // swift-tools-version: 6.0 import PackageDescription +import class Foundation.ProcessInfo + +// force building as dynamic library +let dynamicLibrary = ProcessInfo.processInfo.environment["SWIFT_BUILD_DYNAMIC_LIBRARY"] != nil +let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrary ? .dynamic : nil let package = Package( name: "Binder", @@ -12,13 +17,14 @@ let package = Package( products: [ .library( name: "Binder", + type: libraryType, targets: ["Binder"] ) ], dependencies: [ .package( url: "https://github.com/apple/swift-system", - from: "1.4.0" + from: "1.5.0" ), .package( url: "https://github.com/PureSwift/Socket",