forked from Supreeeme/xrizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
40 lines (32 loc) · 1.8 KB
/
build.rs
File metadata and controls
40 lines (32 loc) · 1.8 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
use anyhow::anyhow;
use std::env;
use vergen_gitcl::{Emitter, GitclBuilder};
fn main() -> Result<(), anyhow::Error> {
let out_dir = env::var("OUT_DIR").unwrap();
for path in shaders::compile(&out_dir) {
println!("cargo::rerun-if-changed={}", path.to_str().unwrap());
}
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_os = target_os.as_str();
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target_arch = target_arch.as_str();
// Object name and platform directory logic is generally based on a couple of pieces of openvr_api code:
// - platform directory names: https://github.com/ValveSoftware/openvr/blob/ae46a8dd0172580648c8922658a100439115d3eb/src/vrcore/pathtools_public.h#L127-L157
// - general logic and special cases: https://github.com/ValveSoftware/openvr/blob/ae46a8dd0172580648c8922658a100439115d3eb/src/openvr_api_public.cpp#L128-L144
// The android and macos platforms have been omitted, since we are currently uninterested in supporting them.
let vrclient_name = match (target_os, target_arch) {
("windows", "x86_64") => "vrclient_x64",
_ => "vrclient",
};
let platform_location = match (target_os, target_arch) {
("windows", "x86") | ("windows", "x86_64") => "bin/",
("linux", "x86") => "bin/",
("linux", "x86_64") => "bin/linux64/",
("linux", "aarch64") => "bin/linuxarm64/",
_ => return Err(anyhow!("Unsupported platform: {target_os}/{target_arch}")),
};
println!("cargo::rustc-env=XRIZER_OPENVR_PLATFORM_DIR={platform_location}");
println!("cargo::rustc-env=XRIZER_OPENVR_VRCLIENT_NAME={vrclient_name}");
let builder = GitclBuilder::default().describe(true, true, None).build()?;
Emitter::default().add_instructions(&builder)?.emit()
}