Bug 1833753 [wpt PR 40065] - Allow newly-added test to also pass when mutation events...
[gecko.git] / toolkit / library / moz.build
blob0f9d7e95bf46b678246907efc93ef32fe13adf38
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_ARCH"] == "Linux" and CONFIG["OS_TARGET"] != "Android":
110         GeneratedFile(
111             "symverscript",
112             script="/build/gen_symverscript.py",
113             inputs=["../symverscript.in"],
114             flags=["xul%s" % CONFIG["MOZILLA_SYMBOLVERSION"]],
115         )
116         SYMBOLS_FILE = "!symverscript"
119 # The real libxul definition is in ./build/moz.build, but we define a
120 # xul library here such that # FINAL_LIBRARY = 'xul' refers to here, which
121 # is then linked to both build/libxul and gtest/libxul.
122 Library("xul")
124 STATIC_LIBRARY_NAME = "xul_s"
126 # Use a FINAL_LIBRARY for Libxul_defines to propagate from there. They wouldn't
127 # propagate from here.
128 FINAL_LIBRARY = "xul-real"
130 if CONFIG["OS_ARCH"] == "WINNT":
131     SOURCES += [
132         "nsDllMain.cpp",
133     ]
135 LOCAL_INCLUDES += [
136     "/config",
137     # need widget/windows for resource.h (included from widget.rc)
138     "/widget/windows",
141 if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CC_TYPE"] not in ("clang", "gcc"):
142     LOCAL_INCLUDES += [
143         "/xpcom/base",
144     ]
146 DIRS += [
147     "build",
148     "gtest",
151 if CONFIG["OS_ARCH"] == "WINNT":
152     DIRS += ["dummydll"]
154 # js needs to come after xul for now, because it is an archive and its content
155 # is discarded when it comes first.
156 USE_LIBS += [
157     "js",
160 USE_LIBS += [
161     "lgpllibs",
162     "nspr",
163     "nss",
164     "psshparser",
165     "sqlite",
166     "zlib",
169 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
170     # The mozgtk library is a workaround that makes Gtk+ use libwayland-client
171     # instead of mozwayland. The reason it works is that by being a dependency
172     # of libxul, mozgtk appears in dependentlibs.list, preceding mozwayland
173     # (which is important and guaranteed by the USE_LIBS order in this file).
174     # That, in turn, makes firefox dlopen() mozgtk before mozwayland, which
175     # will trigger the loading of the Gtk+ libraries (mozgtk depending on them).
176     # Those libraries, if they depend on libwayland-client, will use the symbols
177     # from libwayland-client because mozwayland is not loaded yet.
178     # When eventually libxul is loaded after both mozgtk and mozwayland, it will
179     # get symbols from libwayland-client too.
180     # In the case where Gtk+ doesn't have wayland support, libwayland-client is
181     # not loaded, and libxul ends up using the mozwayland symbols.
182     USE_LIBS += [
183         "mozgtk",
184     ]
185     OS_LIBS += CONFIG["MOZ_GTK3_LIBS"]
187 if CONFIG["MOZ_WAYLAND"]:
188     USE_LIBS += [
189         "mozwayland",
190     ]
192 if CONFIG["MOZ_JPROF"]:
193     USE_LIBS += [
194         "jprof",
195     ]
197 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" or CONFIG["MOZ_TREE_FREETYPE"]:
198     USE_LIBS += [
199         "freetype",
200     ]
202 if CONFIG["MOZ_WEBRTC"]:
203     if CONFIG["OS_TARGET"] == "WINNT":
204         OS_LIBS += [
205             "secur32",
206             "iphlpapi",
207             "strmiids",
208             "dmoguids",
209             "wmcodecdspuuid",
210             "amstrmid",
211             "msdmo",
212             "wininet",
213         ]
215 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
216     OS_LIBS += [
217         "-framework Foundation",
218         "-framework CoreFoundation",
219         "-framework CoreLocation",
220         "-framework QuartzCore",
221         "-framework Carbon",
222         "-framework CoreAudio",
223         "-framework CoreVideo",
224         "-framework AudioToolbox",
225         "-framework AudioUnit",
226         "-framework AddressBook",
227         "-framework OpenGL",
228         "-framework Security",
229         "-framework ServiceManagement",
230         "-framework CoreServices",
231         "-framework ApplicationServices",
232         "-framework AppKit",
233         "-framework CoreMIDI",
234         "-framework SystemConfiguration",
235         "-framework AVFoundation",
236         "-framework CoreMedia",
237         "-framework IOKit",
238         "-F%s" % CONFIG["MACOS_PRIVATE_FRAMEWORKS_DIR"],
239         "-framework CoreUI",
240         "-framework CoreSymbolication",
241         "cups",
242     ]
244 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
245     OS_LIBS += [
246         "-framework Foundation",
247         "-framework CoreFoundation",
248         "-framework CoreGraphics",
249         "-framework CoreText",
250         "-framework AVFoundation",
251         "-framework AudioToolbox",
252         "-framework CoreMedia",
253         "-framework CoreVideo",
254         "-framework OpenGLES",
255         "-framework QuartzCore",
256     ]
258 if CONFIG["MOZ_WMF"]:
259     OS_LIBS += [
260         "mfuuid",
261         "wmcodecdspuuid",
262         "strmiids",
263     ]
265 if CONFIG["OS_ARCH"] == "FreeBSD":
266     OS_LIBS += [
267         "util",
268     ]
270 if CONFIG["OS_ARCH"] == "WINNT":
271     OS_LIBS += [
272         "crypt32",
273         "gdi32",
274         "shell32",
275         "ntdll",
276         "ole32",
277         "version",
278         "winspool",
279         "userenv",
280         "uuid",
281     ]
283 if CONFIG["OS_ARCH"] == "Linux" and CONFIG["OS_TARGET"] != "Android":
284     OS_LIBS += [
285         "rt",
286     ]
288 if CONFIG["MOZ_ANDROID_GOOGLE_VR"]:
289     OS_LIBS += [
290         "-L%s" % CONFIG["MOZ_ANDROID_GOOGLE_VR_LIBS"],
291         "-lgvr",
292     ]
294 if CONFIG["MOZ_SYSTEM_JPEG"]:
295     OS_LIBS += CONFIG["MOZ_JPEG_LIBS"]
297 if CONFIG["MOZ_SYSTEM_PNG"]:
298     OS_LIBS += CONFIG["MOZ_PNG_LIBS"]
300 if CONFIG["MOZ_SYSTEM_WEBP"]:
301     OS_LIBS += CONFIG["MOZ_WEBP_LIBS"]
303 if CONFIG["MOZ_SYSTEM_LIBEVENT"]:
304     OS_LIBS += CONFIG["MOZ_LIBEVENT_LIBS"]
306 if CONFIG["MOZ_SYSTEM_LIBVPX"]:
307     OS_LIBS += CONFIG["MOZ_LIBVPX_LIBS"]
309 if not CONFIG["MOZ_TREE_PIXMAN"]:
310     OS_LIBS += CONFIG["MOZ_PIXMAN_LIBS"]
312 if CONFIG["HAVE_CLOCK_MONOTONIC"]:
313     OS_LIBS += CONFIG["REALTIME_LIBS"]
315 OS_LIBS += CONFIG["ICONV_LIBS"]
317 if CONFIG["OS_ARCH"] == "OpenBSD":
318     OS_LIBS += [
319         "sndio",
320     ]
322 if CONFIG["MOZ_ENABLE_DBUS"]:
323     OS_LIBS += CONFIG["MOZ_DBUS_GLIB_LIBS"]
325 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" and CONFIG["COMPILE_ENVIRONMENT"]:
326     OS_LIBS += [l for l in CONFIG["MOZ_GTK3_LIBS"] if l not in ("-lgtk-3", "-lgdk-3")]
327     OS_LIBS += CONFIG["MOZ_X11_LIBS"]
328     OS_LIBS += CONFIG["MOZ_PANGO_LIBS"]
330 if CONFIG["MOZ_ENABLE_LIBPROXY"]:
331     OS_LIBS += CONFIG["MOZ_LIBPROXY_LIBS"]
333 if CONFIG["OS_ARCH"] == "FreeBSD":
334     OS_LIBS += [
335         "util",
336     ]
338 if CONFIG["OS_ARCH"] == "Darwin":
339     OS_LIBS += [
340         # Link to Metal as required by the Metal gfx-hal backend
341         "-weak_framework Metal",
342         "-weak_framework MediaPlayer",
343     ]
346 if CONFIG["OS_ARCH"] == "WINNT":
347     OS_LIBS += [
348         "shell32",
349         "ole32",
350         "version",
351         "winspool",
352         "comdlg32",
353         "imm32",
354         "msimg32",
355         "netapi32",
356         "shlwapi",
357         "ws2_32",
358         "dnsapi",
359         "dwmapi",
360         "iphlpapi",
361         "uxtheme",
362         "setupapi",
363         "secur32",
364         "sensorsapi",
365         "portabledeviceguids",
366         "wininet",
367         "wintrust",
368         "wtsapi32",
369         "locationapi",
370         "sapi",
371         "dxguid",
372         "dhcpcsvc",
373         # gfx-rs supports D3D11 and D3D12, but we are not linking to them implicitly
374         # "d3d11", # should be explicitly linked by gfx-backend-d3d11
375         #'d3d12', # should be explicitly linked by d3d12-rs
376         "d3dcompiler",
377     ]
379     if CONFIG["CC_TYPE"] == "clang-cl":
380         OS_LIBS += [
381             "runtimeobject",
382         ]
384     if CONFIG["ACCESSIBILITY"]:
385         OS_LIBS += [
386             "oleacc",
387         ]
389     # Prevent winapi-rs from statically linking
390     LIBRARY_DEFINES["WINAPI_NO_BUNDLED_LIBRARIES"] = True
392 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
393     OS_LIBS += [
394         "usp10",
395         "oleaut32",
396     ]
398 # The buildid is refreshed on every (incremental) build. But we want to avoid
399 # rebuilding libxul every time, so instead of having a source file that
400 # #include's buildid.h, which would have a dependency on it, and that would
401 # thus trigger make to rebuild everything, we generate a source with the
402 # buildid hard coded in it. Then we make that source file depend on all the
403 # objects files that constitute libxul, so that if any of the files linked into
404 # libxul is rebuilt, we refresh the buildid and link it into libxul.
406 if CONFIG["COMPILE_ENVIRONMENT"]:
407     SOURCES += ["!buildid.cpp"]
408     if CONFIG["MOZ_WIDGET_TOOLKIT"] in ("cocoa", "uikit"):
409         libxul_list = "XUL"
410     else:
411         libxul_list = "%sxul_%s" % (
412             CONFIG["DLL_PREFIX"],
413             CONFIG["DLL_SUFFIX"].lstrip(".").replace(".", "_"),
414         )
415     GeneratedFile(
416         "buildid.cpp", script="gen_buildid.py", inputs=["!build/%s.list" % libxul_list]
417     )