diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..68122e305 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,23 @@ +[target.aarch64-apple-ios-sim] +runner = "cargo dinghy -p auto-ios-aarch64-sim runner" + +[target.x86_64-apple-ios] +runner = "cargo dinghy -p auto-ios-x86_64 runner" + +# Running on device requires doing the steps in +# https://github.com/sonos/dinghy/blob/main/docs/ios.md#additional-requirements +[target.aarch64-apple-ios] +runner = "cargo dinghy -p auto-ios-aarch64 runner" + +# These target runners are added in https://github.com/sonos/dinghy/pull/203 +[target.aarch64-apple-tvos-sim] +runner = "cargo dinghy -p auto-tvos-aarch64-sim runner" + +[target.x86_64-apple-tvos] +runner = "cargo dinghy -p auto-tvos-x86_64 runner" + +[target.x86_64-apple-watchos-sim] +runner = "cargo dinghy -p auto-watchos-x86_64-sim runner" + +[target.aarch64-apple-watchos-sim] +runner = "cargo dinghy -p auto-watchos-aarch64-sim runner" diff --git a/.github/workflows/apple-devices.yml b/.github/workflows/apple-devices.yml new file mode 100644 index 000000000..7e09f2685 --- /dev/null +++ b/.github/workflows/apple-devices.yml @@ -0,0 +1,61 @@ +# based on https://gist.github.com/learnopengles/60c945b92fbe60a0fecaa0143c35c4a for testing in simulator +name: x86_64-apple-ios + +on: pull_request + +env: + TOOLCHAIN: nightly + CARGO_TERM_COLOR: always + CARGO_DINGHY_REV: "a8ec5b0" + +jobs: + integration_tests: + # rust cross-compilation + runs-on: macos-latest + strategy: + matrix: + rust-target: ["x86_64-apple-ios" ] + apple-sim: [ "iOS" ] + include: + - rust-target: "x86_64-apple-tvos" + apple-sim: "tvOS" + - rust-target: "x86_64-apple-watchos-sim" + apple-sim: "watchOS" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN }} + components: rust-src + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin + ~/.cargo/git + ~/.cargo/registry + target + key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ env.CARGO_DINGHY_REV }}-${{ hashFiles('**/Cargo.lock') }} + - name: Install cargo-dinghy + run: | + if ! command -v cargo-dinghy &> /dev/null; then + cargo install --git https://github.com/liveview-native/dinghy.git --force --rev ${CARGO_DINGHY_REV} cargo-dinghy + fi + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --package liveview-native-core + + - name: Start Simulator + uses: futureware-tech/simulator-action@v3 + with: + os: ${{ matrix.apple-sim }} + + - name: Run Rust tests on simulator for ${{ matrix.rust-target }} + env: + DINGHY_LOG: debug + run: | + cargo dinghy all-platforms + cargo dinghy all-devices + cargo -Zbuild-std test --target ${{ matrix.rust-target }} diff --git a/.github/workflows/x86_64-apple-ios.yml b/.github/workflows/x86_64-apple-ios.yml deleted file mode 100644 index 82a4f14f3..000000000 --- a/.github/workflows/x86_64-apple-ios.yml +++ /dev/null @@ -1,86 +0,0 @@ -# based on https://gist.github.com/learnopengles/60c945b92fbe60a0fecaa0143c35c4a for testing in simulator -name: x86_64-apple-ios - -on: pull_request - -env: - TOOLCHAIN: nightly - CARGO_TERM_COLOR: always - DYLD_ROOT_PATH: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/ - -jobs: - integration_tests: - # rust cross-compilation - runs-on: macos-12 - - steps: - - uses: actions/checkout@v4 - - name: Install Rust Nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.TOOLCHAIN }} - target: x86_64-apple-ios - default: true - - name: Cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin - ~/.cargo/git - ~/.cargo/registry - target - key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --package liveview-native-core - - name: Set linker - run: echo "CARGO_TARGET_X86_64_APPLE_IOS_LINKER=$PWD/crates/core/tests/support/linker_shim.sh" >> $GITHUB_ENV - - name: Build tests - run: cargo test --package liveview-native-core --no-run --target=x86_64-apple-ios - - name: Start Simulator - uses: futureware-tech/simulator-action@v3 - with: - os: 'iOS' - - name: Copy unittests to app bundle - run: | - cp `find target/x86_64-apple-ios/debug/deps/ -perm +111 -type f -name "liveview_native_core-*" -exec ls -l -D "%FT%T" {} \; | awk '{ print $6, $7 }' | sort -r | awk '{ print $2 }' | head -1` crates/core/tests/support/app/test - - name: Install unittests into Simulator - run: xcrun simctl install booted crates/core/tests/support/app - - name: Run unittests - run: | - xcrun simctl launch --console booted com.rust.tests | tee output - grep -q "test result: ok." output - - name: Uninstall unittests from Simulator - run: xcrun simctl uninstall booted com.rust.tests - - name: Copy diff to app bundle - run: cp `find target/x86_64-apple-ios/debug/deps/ -perm +111 -type f -name "diff-*" -exec ls -l -D "%FT%T" {} \; | awk '{ print $6, $7 }' | sort -r | awk '{ print $2 }' | head -1` crates/core/tests/support/app/test - - name: Install diff into Simulator - run: xcrun simctl install booted crates/core/tests/support/app - - name: Run diff - run: | - xcrun simctl launch --console booted com.rust.tests | tee output - grep -q "test result: ok." output - - name: Uninstall diff from Simulator - run: xcrun simctl uninstall booted com.rust.tests - - name: Copy dom to app bundle - run: cp `find target/x86_64-apple-ios/debug/deps/ -perm +111 -type f -name "dom-*" -exec ls -l -D "%FT%T" {} \; | awk '{ print $6, $7 }' | sort -r | awk '{ print $2 }' | head -1` crates/core/tests/support/app/test - - name: Install dom into Simulator - run: xcrun simctl install booted crates/core/tests/support/app - - name: Run dom - run: | - xcrun simctl launch --console booted com.rust.tests | tee output - grep -q "test result: ok." output - - name: Uninstall dom from Simulator - run: xcrun simctl uninstall booted com.rust.tests - - name: Copy parser to app bundle - run: cp `find target/x86_64-apple-ios/debug/deps/ -perm +111 -type f -name "parser-*" -exec ls -l -D "%FT%T" {} \; | awk '{ print $6, $7 }' | sort -r | awk '{ print $2 }' | head -1` crates/core/tests/support/app/test - - name: Install parser into Simulator - run: xcrun simctl install booted crates/core/tests/support/app - - name: Run parser - run: | - xcrun simctl launch --console booted com.rust.tests | tee output - grep -q "test result: ok." output - - name: Uninstall parser from Simulator - run: xcrun simctl uninstall booted com.rust.tests diff --git a/Cargo.toml b/Cargo.toml index cd3306df5..60c8bb9d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,5 +29,5 @@ opt-level = 1 split-debuginfo = "packed" debug = 1 -[patch.crates-io] -uniffi = { git = "https://github.com/mozilla/uniffi-rs/", branch = "main" } +#[patch.crates-io] +#uniffi = { git = "https://github.com/mozilla/uniffi-rs/", branch = "main" } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 079d4f102..fb4a183b9 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -37,11 +37,11 @@ serde_json = { version = "1.0" } smallstr = { version = "0.3", features = ["union"] } smallvec = { version = "1.10", features = ["union", "const_generics", "specialization"] } thiserror = "1.0" -uniffi = { version = "0.25", features = ["cli"] } +uniffi = { version = "0.26", features = ["cli"] } [build-dependencies] Inflector = "0.11" -uniffi = { version = "0.25", features = [ "build" ] } +uniffi = { version = "0.26", features = [ "build" ] } [dev-dependencies] paste = { version = "1.0" } diff --git a/crates/core/tests/support/app/.gitignore b/crates/core/tests/support/app/.gitignore deleted file mode 100644 index 806e5f4f2..000000000 --- a/crates/core/tests/support/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -integration_test diff --git a/crates/core/tests/support/app/Info.plist b/crates/core/tests/support/app/Info.plist deleted file mode 100644 index 0a667e0c2..000000000 --- a/crates/core/tests/support/app/Info.plist +++ /dev/null @@ -1,18 +0,0 @@ - - - - - CFBundleExecutable - test - CFBundleVersion - 0.0.1 - CFBundleShortVersionString - 0.0.1 - CFBundleIdentifier - com.rust.tests - UIRequiredDeviceCapabilities - - x86_64 - - - diff --git a/crates/core/tests/support/linker_shim.sh b/crates/core/tests/support/linker_shim.sh deleted file mode 100755 index 158bdc408..000000000 --- a/crates/core/tests/support/linker_shim.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -cc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk "$@"