Skip to content

Commit

Permalink
Fixups from review
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev committed Oct 26, 2023
1 parent 1152fe6 commit 84a05da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 633 deletions.
35 changes: 14 additions & 21 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ fn main() {
panic!("Do not know how to build DLLs for a non-Windows platform.");
}

// Contains compiled libs
let mut libs: HashSet<Libs> = HashSet::new();
let mut compiled_libraries: HashSet<Libs> = HashSet::new();

build_translator(&mut libs, &target);
build_translator(&mut compiled_libraries, &target);

#[cfg(feature = "build_dlls")]
{
for lib in build_data::GLESv2.use_libs {
build_lib(&mut libs, &target, *lib);
build_lib(&mut compiled_libraries, &target, *lib);
}
build_windows_dll(
&build_data::GLESv2,
Expand All @@ -59,7 +58,7 @@ fn main() {
#[cfg(feature = "egl")]
{
if !cfg!(feature = "build_dlls") {
build_lib(&mut libs, &target, Libs::EGL);
build_lib(&mut compiled_libraries, &target, Libs::EGL);
}
generate_gl_bindings();
}
Expand Down Expand Up @@ -121,14 +120,10 @@ fn build_windows_dll(data: &build_data::Data, dll_name: &str, def_file: &str) {
cmd.arg(&zlib_link_arg);

if dll_name == "libGLESv2" {
//std::fs::rename(out_path.join("libGLESv2.lib"), out_path.join("libGLESv2_static.lib")).unwrap();
//cmd.arg(out_path.join("libGLESv2_static.lib"));
// transitive lib (that's the only case)
cmd.arg(out_path.join("preprocessor.lib"));
for file in data.sources {
//if !file.contains("libANGLE") {
cmd.arg(fixup_path(file));
//}
}
} else {
for file in data.sources {
Expand All @@ -154,16 +149,16 @@ fn build_windows_dll(data: &build_data::Data, dll_name: &str, def_file: &str) {
assert!(status.unwrap().success());
}

fn build_lib(libs: &mut HashSet<Libs>, target: &String, lib: Libs) {
// Check if we already built it do not rebuild
if libs.contains(&lib) {
fn build_lib(compiled_libraries: &mut HashSet<Libs>, target: &String, lib: Libs) {
// Do not rebuild this library if it is already built.
if compiled_libraries.contains(&lib) {
return;
}

println!("build_lib: {lib:?}");
let data = lib.to_data();
for dep_lib in data.use_libs {
build_lib(libs, target, *dep_lib);
build_lib(compiled_libraries, target, *dep_lib);
}
let repo = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
env::set_current_dir(repo).unwrap();
Expand All @@ -185,12 +180,10 @@ fn build_lib(libs: &mut HashSet<Libs>, target: &String, lib: Libs) {
build.include(fixup_path(file));
}

//if matches!(lib, Libs::COMPRESSION_UTILS_PORTABLE) {
// add zlib from libz-sys to include path
if let Ok(zlib_include_dir) = env::var("DEP_Z_INCLUDE") {
build.include(zlib_include_dir.replace("\\", "/"));
}
//}

for file in data.sources {
build.file(fixup_path(file));
Expand Down Expand Up @@ -244,8 +237,8 @@ fn build_lib(libs: &mut HashSet<Libs>, target: &String, lib: Libs) {
// Enable multiprocessing for faster builds.
build.flag_if_supported("/MP");

// we want all symbols as they are for consumers
if matches!(lib, Libs::EGL | Libs::GLESv2) {
// we want all symbols as they are for consumers (are shared libs)
if data.shared {
build.link_lib_modifier("-bundle");
build.link_lib_modifier("+whole-archive");
}
Expand All @@ -256,12 +249,12 @@ fn build_lib(libs: &mut HashSet<Libs>, target: &String, lib: Libs) {
println!("cargo:rustc-link-lib={}", lib);
}

libs.insert(lib);
compiled_libraries.insert(lib);
}

fn build_translator(libs: &mut HashSet<Libs>, target: &String) {
fn build_translator(compiled_libraries: &mut HashSet<Libs>, target: &String) {
println!("build_translator");
build_lib(libs, target, Libs::TRANSLATOR);
build_lib(compiled_libraries, target, Libs::TRANSLATOR);
let data = build_data::TRANSLATOR;

let repo = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
Expand All @@ -283,7 +276,6 @@ fn build_translator(libs: &mut HashSet<Libs>, target: &String) {
clang_args.push(fixup_path(file));
}

// Change to one of the directory that contains moz.build
let mut build = cc::Build::new();

for flag in &clang_args {
Expand Down Expand Up @@ -359,6 +351,7 @@ const ALLOWLIST_FN: &'static [&'static str] = &[
"GLSLangGetNumUnpackedVaryingVectors",
];

/// Change to one of the directory that contains moz.build
fn fixup_path(path: &str) -> String {
let prefix = "../../";
assert!(path.starts_with(prefix));
Expand Down
12 changes: 12 additions & 0 deletions patches/fix-build-on-newer-compilers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/gfx/angle/checkout/include/GLSLANG/ShaderVars.h b/gfx/angle/checkout/include/GLSLANG/ShaderVars.h
index 3ff8618..6adb28d 100644
--- a/gfx/angle/checkout/include/GLSLANG/ShaderVars.h
+++ b/gfx/angle/checkout/include/GLSLANG/ShaderVars.h
@@ -12,6 +12,7 @@

#include <algorithm>
#include <array>
+#include <cstdint>
#include <string>
#include <vector>

Loading

0 comments on commit 84a05da

Please sign in to comment.