@@ -46,16 +46,32 @@ fn bindgen_vncserver() {
46
46
compile_error ! ( "Unsupported Target Android" ) ;
47
47
48
48
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
+
54
70
//TODO In WSL, if QT is installed in Windows system, then the build process might fail on Qt example.
55
71
let dst = config. build ( ) ;
56
72
println ! ( "cargo:rustc-link-lib=dylib=vncserver" ) ;
57
73
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( ) , ) ;
59
75
let rfb_header = format ! ( "{}/{}" , dst. display( ) , "include/rfb/rfb.h" ) ;
60
76
let rfbclient_header = format ! ( "{}/{}" , dst. display( ) , "include/rfb/rfbclient.h" ) ;
61
77
let bindings = bindgen:: Builder :: default ( )
0 commit comments