-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild.rs
More file actions
93 lines (73 loc) · 2.77 KB
/
build.rs
File metadata and controls
93 lines (73 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
extern crate curl;
extern crate vulkano_shaders;
use std::env;
use std::fs;
use std::io::Write;
use std::path::Path;
use curl::easy::Easy;
/// Fetch the platform specific OpenVR 1.0.1 DLL and include it with the build
fn fetch_openvr_sdk() {
// Get the platform specific version of the openVR DLL
let commit101 = String::from("e1507a27547d22a680153862865d40b90fad8c75");
let mut os = String::from("win");
let mut arch = String::from("64");
let mut file_type = String::from("dll");
let mut prefix = String::from("");
if cfg!(target_arch = "x86") {
arch = String::from("32");
}
if cfg!(target_os = "linux") {
os = String::from("linux");
prefix = String::from("lib");
file_type = String::from("so");
}
let mut file = String::new();
file.push_str(prefix.as_str());
file.push_str("openvr_api.");
file.push_str(file_type.as_str());
// if this file doesn't already exist in build directory
let mut out_dir = String::from(env::var("CARGO_MANIFEST_DIR").unwrap());
out_dir.push_str("/target/");
out_dir.push_str(env::var("PROFILE").unwrap().as_str());
let mut file_path_str = String::new();
file_path_str.push_str(out_dir.as_str());
file_path_str.push_str("/");
file_path_str.push_str(file.as_str());
let file_path = Path::new(file_path_str.as_str());
if !file_path.exists() {
let mut download = String::from("https://raw.githubusercontent.com/ValveSoftware/openvr/");
download.push_str(commit101.as_str());
download.push_str("/bin/");
download.push_str(os.as_str());
download.push_str(arch.as_str());
download.push_str("/");
download.push_str(file.as_str());
println!("{:?}", file_path.clone());
// Fetch the file from GitHub
let mut open = fs::OpenOptions::new()
.read(true)
.write(true)
.create(true)
.open(file_path_str.as_str())
.unwrap();
let mut handle = Easy::new();
handle.url(download.as_str()).unwrap();
handle
.write_function(move |data| Ok(open.write(data).unwrap()))
.unwrap();
handle.perform().unwrap();
}
}
fn compile_spirv() {
// Compiling shaders to SPIR-V
vulkano_shaders::build_glsl_shaders([("src/renderer/gfx/text/shaders/text_vs.glsl",
vulkano_shaders::ShaderType::Vertex),
("src/renderer/gfx/text/shaders/text_fs.glsl",
vulkano_shaders::ShaderType::Fragment)]
.iter()
.cloned());
}
fn main() {
//fetch_openvr_sdk();
compile_spirv();
}