diff --git a/.github/workflows/wasmBuild.yml b/.github/workflows/wasmBuild.yml index ee2779b0..9c2e1d47 100644 --- a/.github/workflows/wasmBuild.yml +++ b/.github/workflows/wasmBuild.yml @@ -1,17 +1,20 @@ name: WebAssembly build on: [push, pull_request] jobs: - test: + build: name: BezierKit WASM support runs-on: ubuntu-latest - container: ghcr.io/swiftwasm/carton:0.16.0 steps: - - uses: actions/checkout@v2 - - # Carton is not able to find our tests if LinuxMain.swift file is defined - - name: Remove LinuxMain.swift file - run: rm BezierKit/LinuxMain.swift + - uses: actions/checkout@v4 - - name: Test - run: carton test \ No newline at end of file + - uses: swift-actions/setup-swift@v3 + with: + swift-version: main-snapshot-2026-06-24 + skip-verify-signature: true + + - name: Install WebAssembly SDK + run: swift sdk install --checksum b8e808d6c1b83636c68668eea27f504ac07973f0f8c68d0d053d11ef4eb96a44 https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2026-06-24-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2026-06-24-a-wasm32-unknown-wasip1-threads.artifactbundle.zip + + - name: Build + run: swift build --build-system native --swift-sdk DEVELOPMENT-SNAPSHOT-2026-06-24-a-wasm32-unknown-wasip1-threads diff --git a/BezierKit/BezierKitTests/BoundingBoxTests.swift b/BezierKit/BezierKitTests/BoundingBoxTests.swift index 40b2c17d..b24d6079 100644 --- a/BezierKit/BezierKitTests/BoundingBoxTests.swift +++ b/BezierKit/BezierKitTests/BoundingBoxTests.swift @@ -114,13 +114,15 @@ class BoundingBoxTests: XCTestCase { XCTAssertEqual(box2.union(Point(x: 1, y: 7)), BoundingBox(p1: Point(x: -2, y: -1), p2: Point(x: 3, y: 7))) } - func testCGRect() { - // test a standard box - let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0)) - XCTAssertEqual(box1.cgRect, Rect(origin: Point(x: 2.0, y: 3.0), size: CGSize(width: 1.0, height: 2.0)).cgRect) - // test the empty box - XCTAssertEqual(BoundingBox.empty.cgRect, CGRect.null) - } + #if canImport(CoreGraphics) + func testCGRect() { + // test a standard box + let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0)) + XCTAssertEqual(box1.cgRect, Rect(origin: Point(x: 2.0, y: 3.0), size: CGSize(width: 1.0, height: 2.0)).cgRect) + // test the empty box + XCTAssertEqual(BoundingBox.empty.cgRect, CGRect.null) + } + #endif func testInitFirstSecond() { let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0)) diff --git a/BezierKit/Library/Math.swift b/BezierKit/Library/Math.swift index 4e5bc765..75d5fa54 100644 --- a/BezierKit/Library/Math.swift +++ b/BezierKit/Library/Math.swift @@ -53,6 +53,30 @@ enum BezierMath { WASILibc.sqrt(x) } } +#elseif canImport(Android) +import Android + +enum BezierMath { + static func acos(_ x: Double) -> Double { + Android.acos(x) + } + + static func atan2(_ y: Double, _ x: Double) -> Double { + Android.atan2(y, x) + } + + static func cos(_ x: Double) -> Double { + Android.cos(x) + } + + static func pow(_ x: Double, _ y: Double) -> Double { + Android.pow(x, y) + } + + static func sqrt(_ x: Double) -> Double { + Android.sqrt(x) + } +} #elseif canImport(Glibc) import Glibc