Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apply_linux_patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
cd openvr
git reset --hard
git apply ../patches/mingw_build.path
32 changes: 30 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ use std::env;
use std::path::PathBuf;

fn main() {
#[cfg(unix)]
{
use std::{fs, process::Command};
Command::new("bash")
.current_dir(fs::canonicalize(".").unwrap())
.arg("apply_linux_patches.sh")
.spawn()
.unwrap()
.wait()
.unwrap();
}

let out_dir = PathBuf::from(env::var("OUT_DIR").expect("Missing OUT_DIR env var"));

println!("cargo:rerun-if-changed=wrapper.hpp");
Expand All @@ -24,13 +36,17 @@ fn main() {
.define("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE", &out_dir_str)
.define("CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG", &out_dir_str)
.define("CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE", &out_dir_str)
.out_dir(&out_dir);
.out_dir(&out_dir);

if target_os == "macos" {
config.define("BUILD_UNIVERSAL", "OFF");
} else if target_os == "windows" {
// Work around broken cmake build.
config.cxxflag("/DWIN32");
if env::var("CARGO_CFG_TARGET_ENV").unwrap() == "gnu" {
config.cxxflag("-DWIN32");
} else {
config.cxxflag("/DWIN32");
}
}

let dst = config.build();
Expand Down Expand Up @@ -61,4 +77,16 @@ fn main() {
.expect("could not generate bindings")
.write_to_file(out_dir.join("bindings.rs"))
.expect("could not write bindings.rs");
#[cfg(unix)]
{
use std::{fs, process::Command};
//reset openvr submodule so git doesn't say it's dirty
Command::new("bash")
.current_dir(fs::canonicalize(".").unwrap())
.arg("reset_openvr_submodule.sh")
.spawn()
.unwrap()
.wait()
.unwrap();
}
}
13 changes: 13 additions & 0 deletions patches/mingw_build.path
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/headers/openvr_capi.h b/headers/openvr_capi.h
index c4b6877..0d6fdbf 100644
--- a/headers/openvr_capi.h
+++ b/headers/openvr_capi.h
@@ -48,7 +48,7 @@

#include <stdint.h>

-#if defined( __WIN32 )
+#if defined( __WIN32 ) && !defined(__MINGW32__)
typedef char bool;
#else
#include <stdbool.h>
3 changes: 3 additions & 0 deletions reset_openvr_submodule.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd openvr
git reset --hard