Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / toolkit / library / moz.build
blobda1d8c47f83e2f23cd802615ab8fff822f6e05c8
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/.
8 @template
9 def Libxul_defines():
10     LIBRARY_DEFINES["MOZILLA_INTERNAL_API"] = True
11     LIBRARY_DEFINES["IMPL_LIBXUL"] = True
12     if not CONFIG["JS_SHARED_LIBRARY"]:
13         LIBRARY_DEFINES["STATIC_EXPORTABLE_JS_API"] = True
16 @template
17 def Libxul(name, output_category=None):
18     if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("cocoa", "uikit"):
19         # This is going to be a framework named "XUL", not an ordinary library named
20         # "libxul.dylib"
21         GeckoFramework(name, output_category=output_category, linkage=None)
22         SHARED_LIBRARY_NAME = "XUL"
23     else:
24         GeckoSharedLibrary(name, output_category=output_category, linkage=None)
25         SHARED_LIBRARY_NAME = "xul"
27     DELAYLOAD_DLLS += [
28         "avrt.dll",
29         "comdlg32.dll",
30         "credui.dll",
31         "d3d11.dll",
32         "D3DCompiler_47.dll",
33         "dhcpcsvc.dll",
34         "dnsapi.dll",
35         "dwmapi.dll",
36         "dxgi.dll",
37         "gdi32.dll",
38         "hid.dll",
39         "imm32.dll",
40         "iphlpapi.dll",
41         "msi.dll",
42         "msimg32.dll",
43         "netapi32.dll",
44         "ole32.dll",
45         "oleaut32.dll",
46         "secur32.dll",
47         "setupapi.dll",
48         "shell32.dll",
49         "shlwapi.dll",
50         "urlmon.dll",
51         "user32.dll",
52         "userenv.dll",
53         "usp10.dll",
54         "uxtheme.dll",
55         "wininet.dll",
56         "winmm.dll",
57         "winspool.drv",
58         "wtsapi32.dll",
59     ]
61     if CONFIG["ACCESSIBILITY"]:
62         DELAYLOAD_DLLS += ["oleacc.dll"]
64     if CONFIG["MOZ_WEBRTC"]:
65         DELAYLOAD_DLLS += ["msdmo.dll"]
67     if CONFIG["OS_ARCH"] == "WINNT":
68         DELAYLOAD_DLLS += [
69             "api-ms-win-core-winrt-l1-1-0.dll",
70             "api-ms-win-core-winrt-string-l1-1-0.dll",
71         ]
73     if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["ACCESSIBILITY"]:
74         LOCAL_INCLUDES += ["!/accessible/interfaces/gecko/"]
76     if CONFIG["OS_ARCH"] == "WINNT":
77         LOCAL_INCLUDES += [
78             "/widget/windows",
79             "/xpcom/base",
80         ]
81         RCINCLUDE = "/toolkit/library/xulrunner.rc"
83     # Show a breakdown of linker time. (Too verbose for local builds.)
84     if CONFIG["CC_TYPE"] == "clang-cl" and not CONFIG["DEVELOPER_OPTIONS"]:
85         LDFLAGS += ["-time"]
87     Libxul_defines()
89     if CONFIG["MOZ_NEEDS_LIBATOMIC"]:
90         OS_LIBS += ["atomic"]
92     # TouchBar-related classes are only available in the 10.12.2 SDK and later.
93     # We need to weak link these classes until we've upgraded our SDK to at
94     # least 10.12.2.
95     # We're also linking against libresolv to solve bug 1367932.
96     if CONFIG["OS_ARCH"] == "Darwin":
97         LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSTouchBar"]
98         LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSSharingServicePickerTouchBarItem"]
99         LDFLAGS += ["-Wl,-U,_OBJC_METACLASS_$_NSTouchBar"]
100         LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSCustomTouchBarItem"]
101         LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSPopoverTouchBarItem"]
102         LDFLAGS += ["-lresolv"]
104     if CONFIG["MOZ_DEBUG_SYMBOLS"] and CONFIG["CC_TYPE"] == "clang-cl":
105         LDFLAGS += ["-NATVIS:%s/toolkit/library/gecko.natvis" % TOPSRCDIR]
106     if CONFIG["RUSTC_NATVIS_LDFLAGS"]:
107         LDFLAGS += CONFIG["RUSTC_NATVIS_LDFLAGS"]
109     if CONFIG["OS_TARGET"] != "Android" and name == "xul-real":
110         SYMBOLS_FILE = "../libxul.symbols"
113 # The real libxul definition is in ./build/moz.build, but we define a
114 # xul library here such that # FINAL_LIBRARY = 'xul' refers to here, which
115 # is then linked to both build/libxul and gtest/libxul.
116 Library("xul")
118 STATIC_LIBRARY_NAME = "xul_s"
120 # Use a FINAL_LIBRARY for Libxul_defines to propagate from there. They wouldn't
121 # propagate from here.
122 FINAL_LIBRARY = "xul-real"
124 if CONFIG["OS_ARCH"] == "WINNT":
125     SOURCES += [
126         "nsDllMain.cpp",
127     ]
129 LOCAL_INCLUDES += [
130     "/config",
131     # need widget/windows for resource.h (included from widget.rc)
132     "/widget/windows",
135 if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CC_TYPE"] not in ("clang", "gcc"):
136     LOCAL_INCLUDES += [
137         "/xpcom/base",
138     ]
140 DIRS += [
141     "build",
142     "gtest",
145 if CONFIG["OS_ARCH"] == "WINNT":
146     DIRS += ["dummydll"]
148 # js needs to come after xul for now, because it is an archive and its content
149 # is discarded when it comes first.
150 USE_LIBS += [
151     "js",
154 USE_LIBS += [
155     "gkcodecs",
156     "lgpllibs",
157     "nspr",
158     "nss",
159     "psshparser",
160     "sqlite",
161     "zlib",
164 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
165     # The mozgtk library is a workaround that makes Gtk+ use libwayland-client
166     # instead of mozwayland. The reason it works is that by being a dependency
167     # of libxul, mozgtk appears in dependentlibs.list, preceding mozwayland
168     # (which is important and guaranteed by the USE_LIBS order in this file).
169     # That, in turn, makes firefox dlopen() mozgtk before mozwayland, which
170     # will trigger the loading of the Gtk+ libraries (mozgtk depending on them).
171     # Those libraries, if they depend on libwayland-client, will use the symbols
172     # from libwayland-client because mozwayland is not loaded yet.
173     # When eventually libxul is loaded after both mozgtk and mozwayland, it will
174     # get symbols from libwayland-client too.
175     # In the case where Gtk+ doesn't have wayland support, libwayland-client is
176     # not loaded, and libxul ends up using the mozwayland symbols.
177     USE_LIBS += [
178         "mozgtk",
179     ]
180     OS_LIBS += CONFIG["MOZ_GTK3_LIBS"]
182 if CONFIG["MOZ_WAYLAND"]:
183     USE_LIBS += [
184         "mozwayland",
185     ]
187 if CONFIG["MOZ_JPROF"]:
188     USE_LIBS += [
189         "jprof",
190     ]
192 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" or CONFIG["MOZ_TREE_FREETYPE"]:
193     USE_LIBS += [
194         "freetype",
195     ]
197 if CONFIG["MOZ_WEBRTC"]:
198     if CONFIG["OS_TARGET"] == "WINNT":
199         OS_LIBS += [
200             "secur32",
201             "iphlpapi",
202             "strmiids",
203             "dmoguids",
204             "wmcodecdspuuid",
205             "amstrmid",
206             "msdmo",
207             "wininet",
208         ]
210 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
211     OS_LIBS += [
212         "-framework Foundation",
213         "-framework CoreFoundation",
214         "-framework CoreLocation",
215         "-framework QuartzCore",
216         "-framework Carbon",
217         "-framework CoreAudio",
218         "-framework CoreVideo",
219         "-framework AudioToolbox",
220         "-framework AudioUnit",
221         "-framework AddressBook",
222         "-framework OpenGL",
223         "-framework Security",
224         "-framework ServiceManagement",
225         "-framework CoreServices",
226         "-framework ApplicationServices",
227         "-framework AppKit",
228         "-framework CoreMIDI",
229         "-framework SystemConfiguration",
230         "-framework AVFoundation",
231         "-framework CoreMedia",
232         "-framework IOKit",
233         "-F%s" % CONFIG["MACOS_PRIVATE_FRAMEWORKS_DIR"],
234         "-framework CoreUI",
235         "-framework CoreSymbolication",
236         "cups",
237     ]
239 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
240     OS_LIBS += [
241         "-framework Foundation",
242         "-framework CoreFoundation",
243         "-framework CoreGraphics",
244         "-framework CoreText",
245         "-framework AVFoundation",
246         "-framework AudioToolbox",
247         "-framework CoreMedia",
248         "-framework CoreVideo",
249         "-framework OpenGLES",
250         "-framework QuartzCore",
251     ]
253 if CONFIG["MOZ_WMF"]:
254     OS_LIBS += [
255         "mfuuid",
256         "wmcodecdspuuid",
257         "strmiids",
258     ]
260 if CONFIG["OS_ARCH"] == "FreeBSD":
261     OS_LIBS += [
262         "util",
263     ]
265 if CONFIG["OS_ARCH"] == "WINNT":
266     OS_LIBS += [
267         "crypt32",
268         "gdi32",
269         "shell32",
270         "ntdll",
271         "ole32",
272         "version",
273         "winspool",
274         "userenv",
275         "uuid",
276     ]
278 if CONFIG["OS_ARCH"] == "Linux" and CONFIG["OS_TARGET"] != "Android":
279     OS_LIBS += [
280         "rt",
281     ]
283 if CONFIG["MOZ_ANDROID_GOOGLE_VR"]:
284     OS_LIBS += [
285         "-L%s" % CONFIG["MOZ_ANDROID_GOOGLE_VR_LIBS"],
286         "-lgvr",
287     ]
289 if CONFIG["MOZ_SYSTEM_JPEG"]:
290     OS_LIBS += CONFIG["MOZ_JPEG_LIBS"]
292 if CONFIG["MOZ_SYSTEM_PNG"]:
293     OS_LIBS += CONFIG["MOZ_PNG_LIBS"]
295 if CONFIG["MOZ_SYSTEM_WEBP"]:
296     OS_LIBS += CONFIG["MOZ_WEBP_LIBS"]
298 if CONFIG["MOZ_SYSTEM_LIBEVENT"]:
299     OS_LIBS += CONFIG["MOZ_LIBEVENT_LIBS"]
301 if CONFIG["MOZ_SYSTEM_LIBVPX"]:
302     OS_LIBS += CONFIG["MOZ_LIBVPX_LIBS"]
304 if not CONFIG["MOZ_TREE_PIXMAN"]:
305     OS_LIBS += CONFIG["MOZ_PIXMAN_LIBS"]
307 if CONFIG["HAVE_CLOCK_MONOTONIC"]:
308     OS_LIBS += CONFIG["REALTIME_LIBS"]
310 OS_LIBS += CONFIG["ICONV_LIBS"]
312 if CONFIG["OS_ARCH"] == "OpenBSD":
313     OS_LIBS += [
314         "sndio",
315     ]
317 if CONFIG["MOZ_ENABLE_DBUS"]:
318     OS_LIBS += CONFIG["MOZ_DBUS_LIBS"]
320 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" and CONFIG["COMPILE_ENVIRONMENT"]:
321     OS_LIBS += [l for l in CONFIG["MOZ_GTK3_LIBS"] if l not in ("-lgtk-3", "-lgdk-3")]
322     OS_LIBS += CONFIG["MOZ_X11_LIBS"]
323     OS_LIBS += CONFIG["MOZ_PANGO_LIBS"]
325 if CONFIG["MOZ_ENABLE_LIBPROXY"]:
326     OS_LIBS += CONFIG["MOZ_LIBPROXY_LIBS"]
328 if CONFIG["OS_ARCH"] == "FreeBSD":
329     OS_LIBS += [
330         "util",
331     ]
333 if CONFIG["OS_ARCH"] == "Darwin":
334     OS_LIBS += [
335         # Link to Metal as required by the Metal gfx-hal backend
336         "-weak_framework Metal",
337         "-weak_framework MediaPlayer",
338     ]
341 if CONFIG["OS_ARCH"] == "WINNT":
342     OS_LIBS += [
343         "shell32",
344         "ole32",
345         "version",
346         "winspool",
347         "comdlg32",
348         "imm32",
349         "msimg32",
350         "netapi32",
351         "shlwapi",
352         "ws2_32",
353         "dnsapi",
354         "dwmapi",
355         "iphlpapi",
356         "uxtheme",
357         "setupapi",
358         "secur32",
359         "sensorsapi",
360         "portabledeviceguids",
361         "wininet",
362         "wintrust",
363         "wtsapi32",
364         "locationapi",
365         "sapi",
366         "dxguid",
367         "dhcpcsvc",
368         # gfx-rs supports D3D11 and D3D12, but we are not linking to them implicitly
369         # "d3d11", # should be explicitly linked by gfx-backend-d3d11
370         #'d3d12', # should be explicitly linked by d3d12-rs
371         "d3dcompiler",
372     ]
374     if CONFIG["CC_TYPE"] == "clang-cl":
375         OS_LIBS += [
376             "runtimeobject",
377         ]
379     if CONFIG["ACCESSIBILITY"]:
380         OS_LIBS += [
381             "oleacc",
382         ]
384     # Prevent winapi-rs from statically linking
385     LIBRARY_DEFINES["WINAPI_NO_BUNDLED_LIBRARIES"] = True
387 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
388     OS_LIBS += [
389         "usp10",
390         "oleaut32",
391     ]
393 # The buildid is refreshed on every (incremental) build. But we want to avoid
394 # rebuilding libxul every time, so instead of having a source file that
395 # #include's buildid.h, which would have a dependency on it, and that would
396 # thus trigger make to rebuild everything, we generate a source with the
397 # buildid hard coded in it. Then we make that source file depend on all the
398 # objects files that constitute libxul, so that if any of the files linked into
399 # libxul is rebuilt, we refresh the buildid and link it into libxul.
401 if CONFIG["COMPILE_ENVIRONMENT"]:
402     SOURCES += ["!buildid.cpp"]
403     if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("cocoa", "uikit"):
404         libxul_list = "XUL"
405     else:
406         libxul_list = "%sxul_%s" % (
407             CONFIG["DLL_PREFIX"],
408             CONFIG["DLL_SUFFIX"].lstrip(".").replace(".", "_"),
409         )
410     GeneratedFile(
411         "buildid.cpp", script="gen_buildid.py", inputs=["!build/%s.list" % libxul_list]
412     )