Skip to content

Commit

Permalink
ci: add ci on windows and macos target
Browse files Browse the repository at this point in the history
  • Loading branch information
chiichen committed May 23, 2024
1 parent 5314921 commit 3ec916a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
run: |
cargo test -p libvnc --no-default-features --verbose &
cargo test -p libvnc-sys --verbose
3 changes: 2 additions & 1 deletion examples/image_capture/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/image_output
/image_output
*.png
28 changes: 22 additions & 6 deletions libvnc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3ec916a

Please sign in to comment.