diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 56a1b86..2e58101 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,11 +11,18 @@ env: jobs: ci: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest,macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Install libvncserver + - name: Install libvncserver (Ubuntu) + if: matrix.os == 'ubuntu-latest' run: sudo apt-get install libvncserver-dev + - name: Install libvncserver (Macos) + if: matrix.os == 'macos-latest' + run: brew install libvncserver - name: Install Rust nightly run : rustup update nightly - name: Build @@ -27,7 +34,10 @@ jobs: - name: Cargo Fmt Check run : cargo fmt --all -- --check build-from-source: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest,windows-latest,macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: @@ -37,4 +47,6 @@ jobs: - name: Build run: cargo build -p libvnc --no-default-features --verbose - name: Test - run: cargo test -p libvnc --no-default-features --verbose \ No newline at end of file + run: | + cargo test -p libvnc --no-default-features --verbose & + cargo test -p libvnc-sys --verbose \ No newline at end of file diff --git a/examples/image_capture/.gitignore b/examples/image_capture/.gitignore index deee6ef..ee3c65e 100644 --- a/examples/image_capture/.gitignore +++ b/examples/image_capture/.gitignore @@ -1 +1,2 @@ -/image_output \ No newline at end of file +/image_output +*.png \ No newline at end of file diff --git a/libvnc-sys/build.rs b/libvnc-sys/build.rs index 3b4f7c9..49ea19d 100644 --- a/libvnc-sys/build.rs +++ b/libvnc-sys/build.rs @@ -46,16 +46,32 @@ fn bindgen_vncserver() { compile_error!("Unsupported Target Android"); let mut config = cmake::Config::new("libvncserver"); - #[cfg(target_os = "windows")] - config.define( - "CMAKE_TOOLCHAIN_FILE", - "../cmake/Toolchain-cross-mingw32-linux.cmake", - ); + + let target_triple = env::var("TARGET").unwrap(); + if target_triple != env::var("HOST").unwrap() { + if !cfg!(target_os = "linux") { + //cfg!(target_os) in build.rs means the host os that build script is running + panic!("Cross-compilation on platforms other than linux is not supported") + } + #[cfg(target_os = "windows")] + config.define( + "CMAKE_TOOLCHAIN_FILE", + "../cmake/Toolchain-cross-mingw32-linux.cmake", + ); + } else { + #[cfg(target_os = "windows")] + config.define( + "CMAKE_TOOLCHAIN_FILE", + "C:/vcpkg/scripts/buildsystems/vcpkg.cmake", + ); + //TODO BETTER toolchain path + } + //TODO In WSL, if QT is installed in Windows system, then the build process might fail on Qt example. let dst = config.build(); println!("cargo:rustc-link-lib=dylib=vncserver"); println!("cargo:rustc-link-lib=dylib=vncclient"); //There's no libvncclient , so we need to specify the vncclient manually - println!("cargo:rustc-link-search={}/{}", dst.display(), "build"); + println!("cargo:rustc-link-search={}/build", dst.display(),); let rfb_header = format!("{}/{}", dst.display(), "include/rfb/rfb.h"); let rfbclient_header = format!("{}/{}", dst.display(), "include/rfb/rfbclient.h"); let bindings = bindgen::Builder::default()