From a11252614be39848964ba34b10067cc28a01611c Mon Sep 17 00:00:00 2001
From: ssrlive <30760636+ssrlive@users.noreply.github.com>
Date: Sun, 5 Jan 2025 14:05:20 +0800
Subject: [PATCH 1/6] testing suits for iOS
---
.github/workflows/ci.yml | 23 ++++++++++++++++++++++-
.gitignore | 1 +
Cargo.toml | 3 +++
src/imp/openssl.rs | 2 +-
src/imp/security_framework.rs | 21 +++++++++++++++++----
src/lib.rs | 2 +-
6 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 29e22df7..8aa74f74 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -55,4 +55,25 @@ jobs:
path: target
key: target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- run: cargo test --features vendored
- - run: cargo test --features vendored
+
+ build_n_test_ios:
+ strategy:
+ fail-fast: false
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install cargo lipo and rust compiler for ios target
+ if: ${{ !cancelled() }}
+ run: |
+ cargo install --locked cargo-lipo
+ rustup target add x86_64-apple-ios aarch64-apple-ios
+ - name: clippy
+ if: ${{ !cancelled() }}
+ run: cargo clippy --target x86_64-apple-ios --all-features -- -D warnings
+ - name: Build
+ if: ${{ !cancelled() }}
+ run: |
+ cargo lipo --verbose --all-features
+ - name: Abort on error
+ if: ${{ failure() }}
+ run: echo "iOS build job failed" && false
diff --git a/.gitignore b/.gitignore
index 2deeb18e..5b04ad24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.VSCodeCounter/
target
Cargo.lock
.idea
diff --git a/Cargo.toml b/Cargo.toml
index dc50f8c4..90d6a002 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,9 @@ rust-version = "1.53.0"
features = ["alpn"]
rustdoc-args = ["--cfg", "docsrs"]
+[lib]
+crate-type = ["staticlib", "rlib"]
+
[features]
vendored = ["openssl/vendored"]
alpn = ["security-framework/alpn"]
diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs
index 8fc43620..8b889e77 100644
--- a/src/imp/openssl.rs
+++ b/src/imp/openssl.rs
@@ -16,7 +16,7 @@ use std::fmt;
use std::io;
use std::sync::Once;
-use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
+use crate::{Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
#[cfg(have_min_max_version)]
fn supported_protocols(
diff --git a/src/imp/security_framework.rs b/src/imp/security_framework.rs
index 302791a9..b7d79b57 100644
--- a/src/imp/security_framework.rs
+++ b/src/imp/security_framework.rs
@@ -15,7 +15,6 @@ use std::error;
use std::fmt;
use std::io;
use std::str;
-use std::sync::Mutex;
use std::sync::Once;
#[cfg(not(any(
@@ -58,6 +57,7 @@ use self::security_framework::os::macos::keychain::{self, KeychainSettings, SecK
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
+#[allow(dead_code)]
static SET_AT_EXIT: Once = Once::new();
#[cfg(not(any(
@@ -66,7 +66,8 @@ static SET_AT_EXIT: Once = Once::new();
target_os = "tvos",
target_os = "visionos"
)))]
-static TEMP_KEYCHAIN: Mutex