Skip to content

Commit 3ec916a

Browse files
committed
ci: add ci on windows and macos target
1 parent 5314921 commit 3ec916a

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

.github/workflows/CI.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ env:
1111

1212
jobs:
1313
ci:
14-
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest,macos-latest]
17+
runs-on: ${{ matrix.os }}
1518
steps:
1619
- uses: actions/checkout@v4
17-
- name: Install libvncserver
20+
- name: Install libvncserver (Ubuntu)
21+
if: matrix.os == 'ubuntu-latest'
1822
run: sudo apt-get install libvncserver-dev
23+
- name: Install libvncserver (Macos)
24+
if: matrix.os == 'macos-latest'
25+
run: brew install libvncserver
1926
- name: Install Rust nightly
2027
run : rustup update nightly
2128
- name: Build
@@ -27,7 +34,10 @@ jobs:
2734
- name: Cargo Fmt Check
2835
run : cargo fmt --all -- --check
2936
build-from-source:
30-
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
os: [ubuntu-latest,windows-latest,macos-latest]
40+
runs-on: ${{ matrix.os }}
3141
steps:
3242
- uses: actions/checkout@v4
3343
with:
@@ -37,4 +47,6 @@ jobs:
3747
- name: Build
3848
run: cargo build -p libvnc --no-default-features --verbose
3949
- name: Test
40-
run: cargo test -p libvnc --no-default-features --verbose
50+
run: |
51+
cargo test -p libvnc --no-default-features --verbose &
52+
cargo test -p libvnc-sys --verbose

examples/image_capture/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/image_output
1+
/image_output
2+
*.png

libvnc-sys/build.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,32 @@ fn bindgen_vncserver() {
4646
compile_error!("Unsupported Target Android");
4747

4848
let mut config = cmake::Config::new("libvncserver");
49-
#[cfg(target_os = "windows")]
50-
config.define(
51-
"CMAKE_TOOLCHAIN_FILE",
52-
"../cmake/Toolchain-cross-mingw32-linux.cmake",
53-
);
49+
50+
let target_triple = env::var("TARGET").unwrap();
51+
if target_triple != env::var("HOST").unwrap() {
52+
if !cfg!(target_os = "linux") {
53+
//cfg!(target_os) in build.rs means the host os that build script is running
54+
panic!("Cross-compilation on platforms other than linux is not supported")
55+
}
56+
#[cfg(target_os = "windows")]
57+
config.define(
58+
"CMAKE_TOOLCHAIN_FILE",
59+
"../cmake/Toolchain-cross-mingw32-linux.cmake",
60+
);
61+
} else {
62+
#[cfg(target_os = "windows")]
63+
config.define(
64+
"CMAKE_TOOLCHAIN_FILE",
65+
"C:/vcpkg/scripts/buildsystems/vcpkg.cmake",
66+
);
67+
//TODO BETTER toolchain path
68+
}
69+
5470
//TODO In WSL, if QT is installed in Windows system, then the build process might fail on Qt example.
5571
let dst = config.build();
5672
println!("cargo:rustc-link-lib=dylib=vncserver");
5773
println!("cargo:rustc-link-lib=dylib=vncclient"); //There's no libvncclient , so we need to specify the vncclient manually
58-
println!("cargo:rustc-link-search={}/{}", dst.display(), "build");
74+
println!("cargo:rustc-link-search={}/build", dst.display(),);
5975
let rfb_header = format!("{}/{}", dst.display(), "include/rfb/rfb.h");
6076
let rfbclient_header = format!("{}/{}", dst.display(), "include/rfb/rfbclient.h");
6177
let bindings = bindgen::Builder::default()

0 commit comments

Comments
 (0)