Skip to content

Commit

Permalink
Use zlib from libz-sys
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Jul 26, 2024
1 parent c24d153 commit 15db7f6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 58 deletions.
3 changes: 3 additions & 0 deletions mozjs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ fn build_spidermonkey(build_dir: &Path) {
}
cmd.env("PKG_CONFIG_PATH", pkg_config_path);
}
if let Ok(include) = std::env::var("DEP_Z_INCLUDE") {
cppflags.push(format!("-I{include}").replace("\\", "/"));
}
cppflags.push(get_cc_rs_env_os("CPPFLAGS").unwrap_or_default());
cmd.env("CPPFLAGS", cppflags);

Expand Down
83 changes: 83 additions & 0 deletions mozjs-sys/etc/patches/0033-no-zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/config/external/zlib/moz.build b/config/external/zlib/moz.build
index 755400fa7..d1311b9a7 100644
--- a/config/external/zlib/moz.build
+++ b/config/external/zlib/moz.build
@@ -6,16 +6,4 @@

Library("zlib")

-if CONFIG["MOZ_SYSTEM_ZLIB"]:
- OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
-else:
- if CONFIG["ZLIB_IN_MOZGLUE"]:
- # Can't do this until mozglue is handled by moz.build instead of
- # config/rules.mk.
- # USE_LIBS += [
- # 'mozglue'
- # ]
- pass
- DIRS += [
- "../../../modules/zlib",
- ]
+OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
diff --git a/moz.configure b/moz.configure
index 804b9a375..87ccc508d 100755
--- a/moz.configure
+++ b/moz.configure
@@ -905,52 +905,11 @@ check_prog(
validate=validate_strip,
)

+pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when=use_pkg_config)

-@depends(js_standalone, target)
-def system_zlib_default(js_standalone, target):
- return (
- js_standalone
- and target.kernel not in ("WINNT", "Darwin")
- and target.os != "Android"
- )
-
-
-option(
- "--with-system-zlib",
- nargs="?",
- default=system_zlib_default,
- help="{Use|Do not use} system libz",
- when=use_pkg_config,
-)
-
-
-@depends("--with-system-zlib", when=use_pkg_config)
-def with_system_zlib_option(with_system_zlib):
- return with_system_zlib
-
-
-@depends(with_system_zlib_option)
-def deprecated_system_zlib_path(value):
- if value and len(value) == 1:
- die(
- "--with-system-zlib=PATH is not supported anymore. Please use "
- "--with-system-zlib and set any necessary pkg-config environment variable."
- )
-
-
-pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
-
-set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
-
-
-@depends(with_system_zlib_option, js_shared, moz_linker, target.os)
-def zlib_in_mozglue(system_zlib, js_shared, linker, os):
- if not system_zlib and (js_shared or linker or os == "Android"):
- return True
-
-
-set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
-set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
+set_config("MOZ_SYSTEM_ZLIB", True)
+# This is not in upstream anymore
+set_config("ZLIB_IN_MOZGLUE", False)


# Please do not add configure checks from here on.
14 changes: 1 addition & 13 deletions mozjs-sys/mozjs/config/external/zlib/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,4 @@

Library("zlib")

if CONFIG["MOZ_SYSTEM_ZLIB"]:
OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
else:
if CONFIG["ZLIB_IN_MOZGLUE"]:
# Can't do this until mozglue is handled by moz.build instead of
# config/rules.mk.
# USE_LIBS += [
# 'mozglue'
# ]
pass
DIRS += [
"../../../modules/zlib",
]
OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
49 changes: 4 additions & 45 deletions mozjs-sys/mozjs/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -905,52 +905,11 @@ check_prog(
validate=validate_strip,
)

pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when=use_pkg_config)

@depends(js_standalone, target)
def system_zlib_default(js_standalone, target):
return (
js_standalone
and target.kernel not in ("WINNT", "Darwin")
and target.os != "Android"
)


option(
"--with-system-zlib",
nargs="?",
default=system_zlib_default,
help="{Use|Do not use} system libz",
when=use_pkg_config,
)


@depends("--with-system-zlib", when=use_pkg_config)
def with_system_zlib_option(with_system_zlib):
return with_system_zlib


@depends(with_system_zlib_option)
def deprecated_system_zlib_path(value):
if value and len(value) == 1:
die(
"--with-system-zlib=PATH is not supported anymore. Please use "
"--with-system-zlib and set any necessary pkg-config environment variable."
)


pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")

set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")


@depends(with_system_zlib_option, js_shared, moz_linker, target.os)
def zlib_in_mozglue(system_zlib, js_shared, linker, os):
if not system_zlib and (js_shared or linker or os == "Android"):
return True


set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
set_config("MOZ_SYSTEM_ZLIB", True)
# This is not in upstream anymore
set_config("ZLIB_IN_MOZGLUE", False)


# Please do not add configure checks from here on.
Expand Down

0 comments on commit 15db7f6

Please sign in to comment.