Make glslang work on Linux

This commit is contained in:
Pierre Krieger 2016-02-19 16:44:35 +01:00
parent 254cb78d00
commit 6e465a8c63
5 changed files with 14 additions and 20 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "glsl-to-spirv/glslang"]
path = glsl-to-spirv/glslang
url = https://github.com/KhronosGroup/glslang

View File

@ -6,3 +6,6 @@ build = "build/build.rs"
[dependencies]
tempdir = "0.3.4"
[build-dependencies]
cmake = "0.1.13"

View File

@ -1,38 +1,25 @@
extern crate cmake;
use std::env;
use std::fs;
use std::fs::Permissions;
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=build/glslangValidator");
println!("cargo:rerun-if-changed=build/glslangValidator.exe");
let target = env::var("TARGET").unwrap();
let out_file = Path::new(&env::var("OUT_DIR").unwrap()).join("glslang_validator");
let path = if target.contains("windows") {
Path::new("build/glslangValidator.exe")
} else if target.contains("linux") {
Path::new("build/glslangValidator")
// TODO: check the hash of the file to make sure that it is not altered
Path::new("build/glslangValidator.exe").to_owned()
} else {
panic!("The platform `{}` is not supported", target);
// TODO: automatically initialize the submodule if it wasn't done
cmake::build("glslang");
Path::new(&env::var("OUT_DIR").unwrap()).join("bin").join("glslangValidator")
};
if let Err(_) = fs::hard_link(&path, &out_file) {
fs::copy(&path, &out_file).expect("failed to copy executable");
}
// TODO: check the hash of the files to make sure that they are not altered
// setting permissions of the executable
{
#[cfg(unix)] fn permissions() -> Option<Permissions> {
use std::os::unix::fs::PermissionsExt;
Some(Permissions::from_mode(755))
}
#[cfg(not(unix))] fn permissions() -> Option<Permissions> { None }
if let Some(permissions) = permissions() {
fs::set_permissions(&out_file, permissions).expect("failed to set permissions");
}
}
}

Binary file not shown.

1
glsl-to-spirv/glslang Submodule

@ -0,0 +1 @@
Subproject commit 5047c6f7a70924bfac38c2c9e487299b3416a7f9