diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 534df2125..35f45075e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,6 +182,23 @@ jobs: cross: false extra-args: -F "shadowsocks, tuic, onion" rustflags: "-Ctarget-feature=+crt-static --cfg tokio_unstable" + # Android + - os: ubuntu-latest + target: aarch64-linux-android + cross: true + extra-args: -F "shadowsocks, tuic, onion" + - os: ubuntu-latest + target: armv7-linux-androideabi + cross: true + extra-args: -F "shadowsocks, tuic, onion" + - os: ubuntu-latest + target: x86_64-linux-android + cross: true + extra-args: -F "shadowsocks, tuic, onion" + - os: ubuntu-latest + target: i686-linux-android + cross: true + extra-args: -F "shadowsocks, tuic, onion" # Linux mips: tier-3, pity # Windows gnu: tokio dont work # Windows aarch: todo @@ -209,7 +226,11 @@ jobs: toolchain: ${{ matrix.toolchain || 'nightly' }} target: ${{ matrix.target }} components: ${{ matrix.components || 'rustfmt, clippy' }} - + - name: Install cross + if: ${{ matrix.cross }} + run: | + rm -f ~/.cargo/bin/cross* + cargo install cross --git https://github.com/cross-rs/cross - name: Install Protoc uses: arduino/setup-protoc@v3 with: @@ -231,7 +252,6 @@ jobs: - name: Cargo fmt uses: clechasseur/rs-cargo@v2 with: - use-cross: ${{ matrix.cross }} command: fmt args: --all -- --check env: diff --git a/clash_lib/src/app/dns/resolver/mod.rs b/clash_lib/src/app/dns/resolver/mod.rs index d5aabf265..db5efa285 100644 --- a/clash_lib/src/app/dns/resolver/mod.rs +++ b/clash_lib/src/app/dns/resolver/mod.rs @@ -1,9 +1,9 @@ mod enhanced; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] #[path = "system_linux.rs"] mod system; -#[cfg(not(target_os = "linux"))] +#[cfg(all(not(target_os = "linux"), not(target_os = "android")))] #[path = "system_non_linux.rs"] mod system; diff --git a/clash_lib/src/proxy/utils/test_utils/mod.rs b/clash_lib/src/proxy/utils/test_utils/mod.rs index c54336b31..cb0bd1e22 100644 --- a/clash_lib/src/proxy/utils/test_utils/mod.rs +++ b/clash_lib/src/proxy/utils/test_utils/mod.rs @@ -34,7 +34,7 @@ pub async fn ping_pong_test( let sess = Session { destination: ( - if cfg!(target_os = "linux") { + if cfg!(any(target_os = "linux", target_os = "android")) { "127.0.0.1".to_owned() } else { "host.docker.internal".to_owned() @@ -152,7 +152,7 @@ pub async fn ping_pong_udp_test( .try_into() .unwrap_or_else(|_| panic!("")); let dst: SocksAddr = ( - if cfg!(target_os = "linux") { + if cfg!(any(target_os = "linux", target_os = "android")) { "127.0.0.1".to_owned() } else { "host.docker.internal".to_owned()