Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev committed Oct 30, 2023
1 parent 844d4dc commit 071192b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 5 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn build_windows_dll(data: &build_data::Data, dll_name: &str, def_file: &str) {
build.define(k, v);
}
// add zlib from libz-sys to include path
// See: https://doc.rust-lang.org/cargo/reference/build-script-examples.html#using-another-sys-crate
let zlib_link_arg = if let Ok(zlib_include_dir) = env::var("DEP_Z_INCLUDE") {
build.include(zlib_include_dir.replace("\\", "/"));
PathBuf::from(zlib_include_dir)
Expand Down Expand Up @@ -163,7 +164,6 @@ fn build_lib(compiled_libraries: &mut HashSet<Libs>, target: &String, lib: Libs)
let repo = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
env::set_current_dir(repo).unwrap();

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

build.cpp(true).std("c++17").warnings(false);
Expand All @@ -181,6 +181,7 @@ fn build_lib(compiled_libraries: &mut HashSet<Libs>, target: &String, lib: Libs)
}

// add zlib from libz-sys to include path
// See: https://doc.rust-lang.org/cargo/reference/build-script-examples.html#using-another-sys-crate
if let Ok(zlib_include_dir) = env::var("DEP_Z_INCLUDE") {
build.include(zlib_include_dir.replace("\\", "/"));
}
Expand All @@ -190,7 +191,8 @@ fn build_lib(compiled_libraries: &mut HashSet<Libs>, target: &String, lib: Libs)
}

if matches!(lib, Libs::ANGLE_COMMON) {
// Hard-code lines like `if CONFIG['OS_ARCH'] == 'Darwin':` in moz.build files
// These platform-specific files are added conditionally in moz.build files
// `if CONFIG['OS_ARCH'] == 'Darwin':`
for &(os, sources) in &[
(
"darwin",
Expand Down Expand Up @@ -351,7 +353,7 @@ const ALLOWLIST_FN: &'static [&'static str] = &[
"GLSLangGetNumUnpackedVaryingVectors",
];

/// Change to one of the directory that contains moz.build
/// Make a path relative to the working directory that is used for the build.
fn fixup_path(path: &str) -> String {
let prefix = "../../";
assert!(path.starts_with(prefix));
Expand Down
10 changes: 3 additions & 7 deletions generate_build_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


def libs():
return listdir(path.join(ANGLE, "targets"))
# sorting for consistency between os
return sorted(listdir(path.join(ANGLE, "targets")))


def lib2const(s: str):
Expand Down Expand Up @@ -112,11 +113,6 @@ def no_platform_sources(source):
return "system_utils_posix.cpp" not in source and "system_utils_linux.cpp" not in source


def no_zlib(s):
# Filter out any accidental inclusion of platform-specific source files.
return "zlib" not in s


def write_lib(lib, data, f):
name = str.encode(lib2const(lib))
defines = [
Expand All @@ -133,7 +129,7 @@ def write_lib(lib, data, f):
write_list(b"includes", map(string_literal, data["LOCAL_INCLUDES"]), f)
write_list(b"defines", defines, f)
write_list(b"os_libs", map(string_literal, data["OS_LIBS"]), f)
write_list(b"use_libs", map(lib_enum, filter(no_zlib, data["USE_LIBS"])), f)
write_list(b"use_libs", map(lib_enum, filter(lambda s: "zlib" not in s, data["USE_LIBS"])), f)
if data["SHARED"]:
f.write(b" shared: true,\n")
else:
Expand Down

0 comments on commit 071192b

Please sign in to comment.