diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..cdbe339a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "glsl-to-spirv/glslang"] + path = glsl-to-spirv/glslang + url = https://github.com/KhronosGroup/glslang diff --git a/glsl-to-spirv/Cargo.toml b/glsl-to-spirv/Cargo.toml index 8bf15f35..2a95ca3b 100644 --- a/glsl-to-spirv/Cargo.toml +++ b/glsl-to-spirv/Cargo.toml @@ -6,3 +6,6 @@ build = "build/build.rs" [dependencies] tempdir = "0.3.4" + +[build-dependencies] +cmake = "0.1.13" diff --git a/glsl-to-spirv/build/build.rs b/glsl-to-spirv/build/build.rs index 4310a531..97561575 100644 --- a/glsl-to-spirv/build/build.rs +++ b/glsl-to-spirv/build/build.rs @@ -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 { - use std::os::unix::fs::PermissionsExt; - Some(Permissions::from_mode(755)) - } - #[cfg(not(unix))] fn permissions() -> Option { None } - if let Some(permissions) = permissions() { - fs::set_permissions(&out_file, permissions).expect("failed to set permissions"); - } - } } diff --git a/glsl-to-spirv/build/glslangValidator b/glsl-to-spirv/build/glslangValidator deleted file mode 100755 index 42a8b38e..00000000 Binary files a/glsl-to-spirv/build/glslangValidator and /dev/null differ diff --git a/glsl-to-spirv/glslang b/glsl-to-spirv/glslang new file mode 160000 index 00000000..5047c6f7 --- /dev/null +++ b/glsl-to-spirv/glslang @@ -0,0 +1 @@ +Subproject commit 5047c6f7a70924bfac38c2c9e487299b3416a7f9