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/.
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
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
21 GeckoFramework(name, output_category=output_category, linkage=None)
22 SHARED_LIBRARY_NAME = "XUL"
24 GeckoSharedLibrary(name, output_category=output_category, linkage=None)
25 SHARED_LIBRARY_NAME = "xul"
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":
69 "api-ms-win-core-winrt-l1-1-0.dll",
70 "api-ms-win-core-winrt-string-l1-1-0.dll",
73 if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["ACCESSIBILITY"]:
74 LOCAL_INCLUDES += ["!/accessible/interfaces/gecko/"]
76 if CONFIG["OS_ARCH"] == "WINNT":
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"]:
89 if CONFIG["MOZ_NEEDS_LIBATOMIC"]:
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
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.
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":
131 # need widget/windows for resource.h (included from widget.rc)
135 if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["CC_TYPE"] not in ("clang", "gcc"):
145 if CONFIG["OS_ARCH"] == "WINNT":
148 # js needs to come after xul for now, because it is an archive and its content
149 # is discarded when it comes first.
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.
180 OS_LIBS += CONFIG["MOZ_GTK3_LIBS"]
182 if CONFIG["MOZ_WAYLAND"]:
187 if CONFIG["MOZ_JPROF"]:
192 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" or CONFIG["MOZ_TREE_FREETYPE"]:
197 if CONFIG["MOZ_WEBRTC"]:
198 if CONFIG["OS_TARGET"] == "WINNT":
210 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
212 "-framework Foundation",
213 "-framework CoreFoundation",
214 "-framework CoreLocation",
215 "-framework QuartzCore",
217 "-framework CoreAudio",
218 "-framework CoreVideo",
219 "-framework AudioToolbox",
220 "-framework AudioUnit",
221 "-framework AddressBook",
223 "-framework Security",
224 "-framework ServiceManagement",
225 "-framework CoreServices",
226 "-framework ApplicationServices",
228 "-framework CoreMIDI",
229 "-framework SystemConfiguration",
230 "-framework AVFoundation",
231 "-framework CoreMedia",
233 "-F%s" % CONFIG["MACOS_PRIVATE_FRAMEWORKS_DIR"],
235 "-framework CoreSymbolication",
239 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
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",
253 if CONFIG["MOZ_WMF"]:
260 if CONFIG["OS_ARCH"] == "FreeBSD":
265 if CONFIG["OS_ARCH"] == "WINNT":
278 if CONFIG["OS_ARCH"] == "Linux" and CONFIG["OS_TARGET"] != "Android":
283 if CONFIG["MOZ_ANDROID_GOOGLE_VR"]:
285 "-L%s" % CONFIG["MOZ_ANDROID_GOOGLE_VR_LIBS"],
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":
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":
333 if CONFIG["OS_ARCH"] == "Darwin":
335 # Link to Metal as required by the Metal gfx-hal backend
336 "-weak_framework Metal",
337 "-weak_framework MediaPlayer",
341 if CONFIG["OS_ARCH"] == "WINNT":
360 "portabledeviceguids",
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
374 if CONFIG["CC_TYPE"] == "clang-cl":
379 if CONFIG["ACCESSIBILITY"]:
384 # Prevent winapi-rs from statically linking
385 LIBRARY_DEFINES["WINAPI_NO_BUNDLED_LIBRARIES"] = True
387 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
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"):
406 libxul_list = "%sxul_%s" % (
407 CONFIG["DLL_PREFIX"],
408 CONFIG["DLL_SUFFIX"].lstrip(".").replace(".", "_"),
411 "buildid.cpp", script="gen_buildid.py", inputs=["!build/%s.list" % libxul_list]