@@ -4,6 +4,18 @@ use std::env;
44use std:: path:: PathBuf ;
55
66fn main ( ) {
7+ #[ cfg( unix) ]
8+ {
9+ use std:: { fs, process:: Command } ;
10+ Command :: new ( "bash" )
11+ . current_dir ( fs:: canonicalize ( "." ) . unwrap ( ) )
12+ . arg ( "apply_linux_patches.sh" )
13+ . spawn ( )
14+ . unwrap ( )
15+ . wait ( )
16+ . unwrap ( ) ;
17+ }
18+
719 let out_dir = PathBuf :: from ( env:: var ( "OUT_DIR" ) . expect ( "Missing OUT_DIR env var" ) ) ;
820
921 println ! ( "cargo:rerun-if-changed=wrapper.hpp" ) ;
@@ -24,13 +36,17 @@ fn main() {
2436 . define ( "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE" , & out_dir_str)
2537 . define ( "CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG" , & out_dir_str)
2638 . define ( "CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE" , & out_dir_str)
27- . out_dir ( & out_dir) ;
39+ . out_dir ( & out_dir) ;
2840
2941 if target_os == "macos" {
3042 config. define ( "BUILD_UNIVERSAL" , "OFF" ) ;
3143 } else if target_os == "windows" {
3244 // Work around broken cmake build.
33- config. cxxflag ( "/DWIN32" ) ;
45+ if env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap ( ) == "gnu" {
46+ config. cxxflag ( "-DWIN32" ) ;
47+ } else {
48+ config. cxxflag ( "/DWIN32" ) ;
49+ }
3450 }
3551
3652 let dst = config. build ( ) ;
@@ -61,4 +77,16 @@ fn main() {
6177 . expect ( "could not generate bindings" )
6278 . write_to_file ( out_dir. join ( "bindings.rs" ) )
6379 . expect ( "could not write bindings.rs" ) ;
80+ #[ cfg( unix) ]
81+ {
82+ use std:: { fs, process:: Command } ;
83+ //reset openvr submodule so git doesn't say it's dirty
84+ Command :: new ( "bash" )
85+ . current_dir ( fs:: canonicalize ( "." ) . unwrap ( ) )
86+ . arg ( "reset_openvr_submodule.sh" )
87+ . spawn ( )
88+ . unwrap ( )
89+ . wait ( )
90+ . unwrap ( ) ;
91+ }
6492}
0 commit comments