diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..cb149f4 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.aarch64-apple-darwin] +rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] diff --git a/.github/workflows/rust-build.yml b/.github/workflows/rust-build.yml index 1d84561..9b1a1ff 100644 --- a/.github/workflows/rust-build.yml +++ b/.github/workflows/rust-build.yml @@ -10,9 +10,13 @@ env: CARGO_TERM_COLOR: always jobs: - build-release: - name: "build-release" - runs-on: ubuntu-latest + build: + name: "Build on ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: - uses: actions/checkout@v4 - name: Build project diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.yml index a6e48f5..7bda873 100644 --- a/.github/workflows/rust-release.yml +++ b/.github/workflows/rust-release.yml @@ -4,46 +4,101 @@ on: release: types: [created] +env: + CARGO_TERM_COLOR: always + jobs: - create-release: + release-linux: + name: Linux - Build and Publish runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Set up Rust" + - name: Set up Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true - - name: "Install dependencies" + - name: Install dependencies run: | sudo apt update sudo apt install -y rpm cargo install cargo-deb cargo install cargo-generate-rpm - - name: "Publish crates" + - name: Publish crates run: | cargo publish -p adb_client --token ${CRATES_IO_TOKEN} cargo publish -p adb_cli --token ${CRATES_IO_TOKEN} env: CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - name: "build-release" + - name: Build release run: cargo build --all-features --release - - name: "Build DEB package" + - name: Rename binary + run: mv target/release/adb_cli target/release/adb_cli-linux + + - name: Build DEB package run: cargo deb -p adb_cli - - name: "Build RPM package" + - name: Build RPM package run: cargo generate-rpm -p adb_cli - - name: "Publish GitHub artefacts" + - name: Upload Linux artifacts uses: softprops/action-gh-release@v2 with: files: | target/debian/*.deb target/generate-rpm/*.rpm - target/release/adb_cli \ No newline at end of file + target/release/adb_cli-linux + + release-macos: + name: macOS - Build Binary + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Build release + run: cargo build --all-features --release + + - name: Rename binary + run: mv target/release/adb_cli target/release/adb_cli-macos + + - name: Upload macOS binary + uses: softprops/action-gh-release@v2 + with: + files: target/release/adb_cli-macos + + release-windows: + name: Windows - Build Binary + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Build release + run: cargo build --all-features --release + + - name: Rename binary + run: Rename-Item -Path target/release/adb_cli.exe -NewName adb_cli-windows.exe + + - name: Upload Windows binary + uses: softprops/action-gh-release@v2 + with: + files: target/release/adb_cli-windows.exe diff --git a/adb_cli/src/main.rs b/adb_cli/src/main.rs index 7e0a856..99e9c4e 100644 --- a/adb_cli/src/main.rs +++ b/adb_cli/src/main.rs @@ -10,7 +10,10 @@ mod utils; use adb_client::{ ADBDeviceExt, ADBServer, ADBServerDevice, ADBTcpDevice, ADBUSBDevice, MDNSDiscoveryService, }; + +#[cfg(any(target_os = "linux", target_os = "macos"))] use adb_termios::ADBTermios; + use anyhow::Result; use clap::Parser; use handlers::{handle_emulator_commands, handle_host_commands, handle_local_commands}; @@ -104,7 +107,7 @@ fn main() -> Result<()> { #[cfg(not(any(target_os = "linux", target_os = "macos")))] { - device.shell(std::io::stdin(), std::io::stdout())?; + device.shell(&mut std::io::stdin(), Box::new(std::io::stdout()))?; } } else { let commands: Vec<&str> = commands.iter().map(|v| v.as_str()).collect(); diff --git a/pyadb_client/Cargo.toml b/pyadb_client/Cargo.toml index c08df38..8b17b89 100644 --- a/pyadb_client/Cargo.toml +++ b/pyadb_client/Cargo.toml @@ -21,7 +21,7 @@ name = "stub_gen" [dependencies] adb_client = { path = "../adb_client" } anyhow = { version = "1.0.95" } -pyo3 = { version = "0.23.4", features = [ +pyo3 = { version = "0.24.1", features = [ "abi3-py37", "anyhow", "extension-module",