Bug 1904139 - Don't re-initialize platform font list from GetDefaultFont. r=jfkthame
[gecko.git] / build / moz.configure / nspr.configure
blobb0b3c803f1819ebb085bfb59d049958d7eefa2e3
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Top-level configure defaults to building NSPR from source. Standalone JS
8 # doesn't.
9 option(
10     "--enable-nspr-build",
11     when=js_standalone,
12     help="{Build|Do not build} NSPR from source tree",
16 @depends("--enable-nspr-build", when=js_standalone)
17 def enable_nspr_build(enable):
18     if enable:
19         return enable
22 system_lib_option(
23     "--with-system-nspr",
24     help="Use system NSPR",
25     when=use_pkg_config,
29 @depends("--with-system-nspr", when=use_pkg_config)
30 def with_system_nspr_option(with_system_nspr):
31     return with_system_nspr
34 @depends(enable_nspr_build, with_system_nspr_option, js_standalone)
35 def build_nspr(nspr_build, system_nspr, js_standalone):
36     if nspr_build is not None and nspr_build.origin != "default":
37         if nspr_build and system_nspr:
38             die("Cannot use both --enable-nspr-build and --with-system-nspr")
39     if js_standalone:
40         return nspr_build
41     return not system_nspr
44 set_config("MOZ_BUILD_NSPR", True, when=build_nspr)
45 set_config("MOZ_SYSTEM_NSPR", True, when="--with-system-nspr")
48 @depends(build_nspr, with_system_nspr_option, js_standalone)
49 def js_without_nspr(build_nspr, system_nspr, js_standalone):
50     if js_standalone:
51         return not build_nspr and not system_nspr
54 set_config("JS_WITHOUT_NSPR", True, when=js_without_nspr)
55 set_define("JS_WITHOUT_NSPR", True, when=js_without_nspr)
58 @depends(js_standalone)
59 def nspr_minver(js_standalone):
60     if js_standalone:
61         return "nspr >= 4.10"
62     return "nspr >= 4.32"
65 nspr_pkg = pkg_check_modules("NSPR", nspr_minver, when="--with-system-nspr")
68 @depends_if(nspr_pkg)
69 def nspr_pkg(nspr_pkg):
70     def extract(prefix, list):
71         for item in list:
72             if item.startswith(prefix):
73                 return item[len(prefix) :]
74         return ""
76     include_dir = extract("-I", nspr_pkg.cflags)
77     lib_dir = extract("-L", nspr_pkg.libs)
78     return namespace(
79         cflags=nspr_pkg.cflags,
80         include_dir=include_dir,
81         libs=nspr_pkg.libs,
82         lib_dir=lib_dir,
83     )
86 @depends(with_system_nspr_option, nspr_minver)
87 def pkgconf_requires_private(system_nspr, nspr_minver):
88     if not system_nspr:
89         return ""
90     return "Requires.private: %s" % nspr_minver
93 set_config("PKGCONF_REQUIRES_PRIVATE", pkgconf_requires_private)
96 # pkg_check_modules takes care of NSPR_CFLAGS and NSPR_LIBS when using --with-system-nspr.
97 @depends(build_environment, c_compiler, fold_libs, when=build_nspr)
98 def nspr_config(build_env, c_compiler, fold_libs):
99     libs = ["nspr4", "plc4", "plds4"]
100     if c_compiler.type == "clang-cl":
101         lib_dir = os.path.join(build_env.dist, "lib")
102         libs = [os.path.join(lib_dir, "%s.lib" % lib) for lib in libs]
103     else:
104         lib_dir = os.path.join(build_env.dist, "lib" if fold_libs else "bin")
105         libs = ["-L%s" % lib_dir] + ["-l%s" % lib for lib in libs]
107     include_dir = os.path.join(build_env.dist, "include", "nspr")
108     return namespace(
109         cflags=["-I%s" % include_dir],
110         include_dir=include_dir,
111         libs=libs,
112         lib_dir=lib_dir,
113     )
116 # Avoid using obsolete NSPR features
117 set_define("NO_NSPR_10_SUPPORT", True)
119 set_config("NSPR_CFLAGS", nspr_config.cflags, when=nspr_config)
120 set_config("NSPR_LIBS", nspr_config.libs, when=nspr_config)
122 set_config("NSPR_INCLUDE_DIR", nspr_config.include_dir, when=nspr_config)
123 set_config("NSPR_LIB_DIR", nspr_config.lib_dir, when=nspr_config)
124 set_config("NSPR_INCLUDE_DIR", nspr_pkg.include_dir, when=nspr_pkg)
125 set_config("NSPR_LIB_DIR", nspr_pkg.lib_dir, when=nspr_pkg)
127 add_old_configure_assignment("NSPR_LIBS", nspr_config.libs, when=nspr_config)
128 add_old_configure_assignment("NSPR_LIBS", nspr_pkg.libs, when=nspr_pkg)