Skip to content

Commit ff754c5

Browse files
committed
Use zlib from libz-sys
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent d3b0645 commit ff754c5

File tree

4 files changed

+91
-58
lines changed

4 files changed

+91
-58
lines changed

mozjs-sys/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ fn build_spidermonkey(build_dir: &Path) {
305305
}
306306
cmd.env("PKG_CONFIG_PATH", pkg_config_path);
307307
}
308+
if let Ok(include) = std::env::var("DEP_Z_INCLUDE") {
309+
cppflags.push(format!("-I{include}").replace("\\", "/"));
310+
}
308311
cppflags.push(get_cc_rs_env_os("CPPFLAGS").unwrap_or_default());
309312
cmd.env("CPPFLAGS", cppflags);
310313

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
diff --git a/config/external/zlib/moz.build b/config/external/zlib/moz.build
2+
index 755400fa7..d1311b9a7 100644
3+
--- a/config/external/zlib/moz.build
4+
+++ b/config/external/zlib/moz.build
5+
@@ -6,16 +6,4 @@
6+
7+
Library("zlib")
8+
9+
-if CONFIG["MOZ_SYSTEM_ZLIB"]:
10+
- OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
11+
-else:
12+
- if CONFIG["ZLIB_IN_MOZGLUE"]:
13+
- # Can't do this until mozglue is handled by moz.build instead of
14+
- # config/rules.mk.
15+
- # USE_LIBS += [
16+
- # 'mozglue'
17+
- # ]
18+
- pass
19+
- DIRS += [
20+
- "../../../modules/zlib",
21+
- ]
22+
+OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
23+
diff --git a/moz.configure b/moz.configure
24+
index 804b9a375..87ccc508d 100755
25+
--- a/moz.configure
26+
+++ b/moz.configure
27+
@@ -905,52 +905,11 @@ check_prog(
28+
validate=validate_strip,
29+
)
30+
31+
+pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when=use_pkg_config)
32+
33+
-@depends(js_standalone, target)
34+
-def system_zlib_default(js_standalone, target):
35+
- return (
36+
- js_standalone
37+
- and target.kernel not in ("WINNT", "Darwin")
38+
- and target.os != "Android"
39+
- )
40+
-
41+
-
42+
-option(
43+
- "--with-system-zlib",
44+
- nargs="?",
45+
- default=system_zlib_default,
46+
- help="{Use|Do not use} system libz",
47+
- when=use_pkg_config,
48+
-)
49+
-
50+
-
51+
-@depends("--with-system-zlib", when=use_pkg_config)
52+
-def with_system_zlib_option(with_system_zlib):
53+
- return with_system_zlib
54+
-
55+
-
56+
-@depends(with_system_zlib_option)
57+
-def deprecated_system_zlib_path(value):
58+
- if value and len(value) == 1:
59+
- die(
60+
- "--with-system-zlib=PATH is not supported anymore. Please use "
61+
- "--with-system-zlib and set any necessary pkg-config environment variable."
62+
- )
63+
-
64+
-
65+
-pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
66+
-
67+
-set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
68+
-
69+
-
70+
-@depends(with_system_zlib_option, js_shared, moz_linker, target.os)
71+
-def zlib_in_mozglue(system_zlib, js_shared, linker, os):
72+
- if not system_zlib and (js_shared or linker or os == "Android"):
73+
- return True
74+
-
75+
-
76+
-set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
77+
-set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
78+
+set_config("MOZ_SYSTEM_ZLIB", True)
79+
+# This is not in upstream anymore
80+
+set_config("ZLIB_IN_MOZGLUE", False)
81+
82+
83+
# Please do not add configure checks from here on.

mozjs-sys/mozjs/config/external/zlib/moz.build

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,4 @@
66

77
Library("zlib")
88

9-
if CONFIG["MOZ_SYSTEM_ZLIB"]:
10-
OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]
11-
else:
12-
if CONFIG["ZLIB_IN_MOZGLUE"]:
13-
# Can't do this until mozglue is handled by moz.build instead of
14-
# config/rules.mk.
15-
# USE_LIBS += [
16-
# 'mozglue'
17-
# ]
18-
pass
19-
DIRS += [
20-
"../../../modules/zlib",
21-
]
9+
OS_LIBS += CONFIG["MOZ_ZLIB_LIBS"]

mozjs-sys/mozjs/moz.configure

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -905,52 +905,11 @@ check_prog(
905905
validate=validate_strip,
906906
)
907907

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

909-
@depends(js_standalone, target)
910-
def system_zlib_default(js_standalone, target):
911-
return (
912-
js_standalone
913-
and target.kernel not in ("WINNT", "Darwin")
914-
and target.os != "Android"
915-
)
916-
917-
918-
option(
919-
"--with-system-zlib",
920-
nargs="?",
921-
default=system_zlib_default,
922-
help="{Use|Do not use} system libz",
923-
when=use_pkg_config,
924-
)
925-
926-
927-
@depends("--with-system-zlib", when=use_pkg_config)
928-
def with_system_zlib_option(with_system_zlib):
929-
return with_system_zlib
930-
931-
932-
@depends(with_system_zlib_option)
933-
def deprecated_system_zlib_path(value):
934-
if value and len(value) == 1:
935-
die(
936-
"--with-system-zlib=PATH is not supported anymore. Please use "
937-
"--with-system-zlib and set any necessary pkg-config environment variable."
938-
)
939-
940-
941-
pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
942-
943-
set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
944-
945-
946-
@depends(with_system_zlib_option, js_shared, moz_linker, target.os)
947-
def zlib_in_mozglue(system_zlib, js_shared, linker, os):
948-
if not system_zlib and (js_shared or linker or os == "Android"):
949-
return True
950-
951-
952-
set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
953-
set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
910+
set_config("MOZ_SYSTEM_ZLIB", True)
911+
# This is not in upstream anymore
912+
set_config("ZLIB_IN_MOZGLUE", False)
954913

955914

956915
# Please do not add configure checks from here on.

0 commit comments

Comments
 (0)