Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor crate to use glslang static libraries #1

Merged
merged 12 commits into from
Oct 30, 2020
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "glslang"]
path = glslang
url = https://github.com/KhronosGroup/glslang.git
13 changes: 4 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
[package]
name = "bevy-glsl-to-spirv"
version = "0.1.7"
authors = ["Pierre Krieger <[email protected]>", "The vulkano contributors", "Carter Anderson <[email protected]>"]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Deprecated. Use shaderc-rs instead."
authors = ["Pierre Krieger <[email protected]>", "The vulkano contributors", "Carter Anderson <[email protected]>", "Nicholas Rishel <[email protected]>"]
description = "Deprecated. This crate is a temporary measure until native rust shader compilation like https://github.com/gfx-rs/naga lands."
repository = "https://github.com/cart/glsl-to-spirv"
license = "MIT/Apache-2.0"
build = "build/build.rs"
categories = ["rendering::graphics-api"]

[dependencies]
tempfile = "3"

[build-dependencies]
cmake = "0.1.27"
edition = "2018"
Binary file added build/android-arm64-v8a/libHLSL.glsltospirv.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/android-arm64-v8a/libSPIRV.glsltospirv.a
Binary file not shown.
Binary file not shown.
Binary file added build/android-arm64-v8a/libglslang.glsltospirv.a
Binary file not shown.
Binary file added build/android-armeabi-v7a/libHLSL.glsltospirv.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/android-armeabi-v7a/libSPIRV.glsltospirv.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
59 changes: 33 additions & 26 deletions build/build.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
extern crate cmake;

use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
use std::path::PathBuf;

fn main() {
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 mut bin_dir = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
bin_dir.push("build");

let path = if target.contains("windows") {
Path::new("build/glslangValidator.exe").to_owned()
} else if target.contains("linux") {
Path::new("build/glslangValidatorLinux").to_owned()
} else if target.contains("apple-darwin") {
Path::new("build/glslangValidatorOsx").to_owned()
if target.contains("x86_64-pc-windows-msvc") {
bin_dir.push("windows");
} else if target.contains("x86_64-unknown-linux-gnu") {
bin_dir.push("linux");
} else if target.contains("x86_64-apple-darwin") {
bin_dir.push("osx");
} else if target.contains("android") {
if target.contains("aarch64") {
bin_dir.push("android-arm64-v8a");
} else if target.contains("armv7") {
bin_dir.push("android-armeabi-v7a");
} else {
panic!("Missing Android target support {}", target);
}
} else {
// Try to initialize submodules. Don't care if it fails, since this code also runs for
// the crates.io package.
let _ = Command::new("git")
.arg("submodule")
.arg("update")
.arg("--init")
.status();
cmake::build("glslang");
Path::new(&env::var("OUT_DIR").unwrap())
.join("bin")
.join("glslangValidator")
panic!("Missing target support {}", target);
};

fs::copy(&path, &out_file).expect("failed to copy executable");
// Link order matters, make sure dependents are linked before their dependencies.
println!("cargo:rustc-link-search={}", bin_dir.to_str().unwrap());
println!("cargo:rustc-link-lib=glslang.glsltospirv");
println!("cargo:rustc-link-lib=HLSL.glsltospirv");
println!("cargo:rustc-link-lib=OGLCompiler.glsltospirv");
println!("cargo:rustc-link-lib=OSDependent.glsltospirv");
println!("cargo:rustc-link-lib=SPIRV.glsltospirv");
println!("cargo:rustc-link-lib=SPVRemapper.glsltospirv");
if target.contains("x86_64-unknown-linux-gnu") || target.contains("x86_64-apple-darwin") {
println!("cargo:rustc-link-lib=SPIRV-Tools-opt.glsltospirv");
println!("cargo:rustc-link-lib=SPIRV-Tools.glsltospirv");
}
if target.contains("android") {
println!("cargo:rustc-link-lib=c++_shared");
}
}
Binary file removed build/glslangValidator.exe
Binary file not shown.
Binary file removed build/glslangValidatorLinux
Binary file not shown.
Binary file removed build/glslangValidatorOsx
Binary file not shown.
Binary file added build/linux/libHLSL.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libOGLCompiler.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libOSDependent.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libSPIRV-Tools-opt.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libSPIRV-Tools.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libSPIRV.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libSPVRemapper.glsltospirv.a
Binary file not shown.
Binary file added build/linux/libglslang.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libHLSL.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libOGLCompiler.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libOSDependent.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libSPIRV-Tools-opt.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libSPIRV-Tools.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libSPIRV.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libSPVRemapper.glsltospirv.a
Binary file not shown.
Binary file added build/osx/libglslang.glsltospirv.a
Binary file not shown.
Binary file added build/windows/HLSL.glsltospirv.lib
Binary file not shown.
Binary file added build/windows/OGLCompiler.glsltospirv.lib
Binary file not shown.
Binary file added build/windows/OSDependent.glsltospirv.lib
Binary file not shown.
Binary file added build/windows/SPIRV.glsltospirv.lib
Binary file not shown.
Binary file added build/windows/SPVRemapper.glsltospirv.lib
Binary file not shown.
Binary file added build/windows/glslang.glsltospirv.lib
Binary file not shown.
1 change: 1 addition & 0 deletions glslang
Submodule glslang added at bcf6a2
40 changes: 0 additions & 40 deletions glslang/.appveyor.yml

This file was deleted.

12 changes: 0 additions & 12 deletions glslang/.clang-format

This file was deleted.

17 changes: 0 additions & 17 deletions glslang/.gitattributes

This file was deleted.

13 changes: 0 additions & 13 deletions glslang/.gitignore

This file was deleted.

81 changes: 0 additions & 81 deletions glslang/.travis.yml

This file was deleted.

90 changes: 0 additions & 90 deletions glslang/CMakeLists.txt

This file was deleted.

Loading