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/. 6 7@template 8def Libxul_defines(): 9 LIBRARY_DEFINES['MOZILLA_INTERNAL_API'] = True 10 LIBRARY_DEFINES['IMPL_LIBXUL'] = True 11 if not CONFIG['JS_SHARED_LIBRARY']: 12 LIBRARY_DEFINES['STATIC_EXPORTABLE_JS_API'] = True 13 14@template 15def Libxul(name): 16 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'): 17 # This is going to be a framework named "XUL", not an ordinary library named 18 # "libxul.dylib" 19 GeckoFramework(name, linkage=None) 20 SHARED_LIBRARY_NAME = 'XUL' 21 else: 22 GeckoSharedLibrary(name, linkage=None) 23 SHARED_LIBRARY_NAME = 'xul' 24 25 DELAYLOAD_DLLS += [ 26 'comdlg32.dll', 27 'netapi32.dll', 28 'secur32.dll', 29 'wininet.dll', 30 'winspool.drv' 31 ] 32 33 if CONFIG['ACCESSIBILITY']: 34 DELAYLOAD_DLLS += ['oleacc.dll'] 35 36 if CONFIG['MOZ_WEBRTC']: 37 DELAYLOAD_DLLS += ['msdmo.dll'] 38 39 if CONFIG['OS_ARCH'] == 'WINNT': 40 DELAYLOAD_DLLS += [ 41 'api-ms-win-core-winrt-l1-1-0.dll', 42 'api-ms-win-core-winrt-string-l1-1-0.dll', 43 ] 44 45 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['ACCESSIBILITY']: 46 LOCAL_INCLUDES += ['!/accessible/interfaces/gecko/'] 47 48 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] not in ('clang', 'gcc'): 49 LOCAL_INCLUDES += [ 50 '/widget/windows', 51 '/xpcom/base', 52 ] 53 # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to 54 # be valid in both toolkit/library and toolkit/library/gtest. 55 # Eventually, the make backend would do its own path canonicalization 56 # and config/version.mk would lift the $(srcdir) 57 RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc' 58 59 # BFD ld doesn't create multiple PT_LOADs as usual when an unknown section 60 # exists. Using an implicit linker script to make it fold that section in 61 # .data.rel.ro makes it create multiple PT_LOADs. That implicit linker 62 # script however makes gold misbehave, first because it doesn't like that 63 # the linker script is given after crtbegin.o, and even past that, replaces 64 # the default section rules with those from the script instead of 65 # supplementing them. Which leads to a lib with a huge load of sections. 66 if CONFIG['OS_TARGET'] not in ('OpenBSD', 'WINNT') and CONFIG['LD_IS_BFD']: 67 LDFLAGS += [TOPSRCDIR + '/toolkit/library/StaticXULComponents.ld'] 68 69 Libxul_defines() 70 71 if CONFIG['MOZ_NEEDS_LIBATOMIC']: 72 OS_LIBS += ['atomic'] 73 74 # This option should go away in bug 1290972, but we need to wait until 75 # Rust 1.12 has been released. 76 # We're also linking against libresolv to solve bug 1367932. 77 if CONFIG['OS_ARCH'] == 'Darwin': 78 LDFLAGS += ['-Wl,-no_compact_unwind,-lresolv'] 79 80Libxul('xul') 81 82FORCE_STATIC_LIB = True 83 84STATIC_LIBRARY_NAME = 'xul_s' 85 86SOURCES += [ 87 'StaticXULComponentsStart.cpp', 88] 89 90# This, combined with the fact the file is first, makes the start pointer 91# it contains first in Windows PGO builds. 92SOURCES['StaticXULComponentsStart.cpp'].no_pgo = True 93 94# Don't let LTO reorder StaticXULComponentsStart.o. 95for f in CONFIG['OS_CXXFLAGS']: 96 if f.startswith('-flto'): 97 SOURCES['StaticXULComponentsStart.cpp'].flags += ['-fno-lto'] 98 break 99 100if CONFIG['OS_ARCH'] == 'WINNT': 101 SOURCES += [ 102 'nsDllMain.cpp', 103 ] 104 105LOCAL_INCLUDES += [ 106 '/config', 107 # need widget/windows for resource.h (included from widget.rc) 108 '/widget/windows', 109] 110 111if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] not in ('clang', 'gcc'): 112 LOCAL_INCLUDES += [ 113 '/xpcom/base', 114 ] 115 116DIRS += ['gtest'] 117 118if CONFIG['OS_ARCH'] == 'WINNT': 119 DIRS += ['dummydll'] 120 121# js needs to come after xul for now, because it is an archive and its content 122# is discarded when it comes first. 123USE_LIBS += [ 124 'js', 125] 126 127USE_LIBS += [ 128 'lgpllibs', 129 'nspr', 130 'nss', 131 'psshparser', 132 'sqlite', 133 'zlib', 134] 135 136if CONFIG['USE_ICU']: 137 USE_LIBS += [ 138 'icu', 139 ] 140 141if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': 142 USE_LIBS += [ 143 'mozgtk_stub', 144 ] 145 146if CONFIG['MOZ_WAYLAND']: 147 USE_LIBS += [ 148 'mozwayland', 149 ] 150 151if CONFIG['MOZ_JPROF']: 152 USE_LIBS += [ 153 'jprof', 154 ] 155 156if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT'] or \ 157 CONFIG['MOZ_TREE_FREETYPE']: 158 USE_LIBS += [ 159 'freetype', 160 ] 161 162if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 163 CXXFLAGS += CONFIG['TK_CFLAGS'] 164 165if CONFIG['MOZ_WEBRTC']: 166 if CONFIG['OS_TARGET'] == 'WINNT': 167 OS_LIBS += [ 168 'secur32', 169 'iphlpapi', 170 'strmiids', 171 'dmoguids', 172 'wmcodecdspuuid', 173 'amstrmid', 174 'msdmo', 175 'wininet', 176 ] 177 178if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 179 OS_LIBS += [ 180 '-framework OpenGL', 181 '-framework SystemConfiguration', 182 '-framework AVFoundation', 183 '-framework CoreMedia', 184 '-framework IOKit', 185 '-F%s' % CONFIG['MACOS_PRIVATE_FRAMEWORKS_DIR'], 186 '-framework CoreUI', 187 '-framework CoreSymbolication', 188 'cups', 189 ] 190 191if CONFIG['MOZ_WMF']: 192 OS_LIBS += [ 193 'mfuuid', 194 'wmcodecdspuuid', 195 'strmiids', 196 ] 197 198if CONFIG['OS_ARCH'] == 'FreeBSD': 199 OS_LIBS += [ 200 'util', 201 ] 202 203if CONFIG['OS_ARCH'] == 'WINNT': 204 OS_LIBS += [ 205 'crypt32', 206 'shell32', 207 'ole32', 208 'version', 209 'winspool', 210 ] 211 212if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android': 213 OS_LIBS += [ 214 'rt', 215 ] 216 217if CONFIG['MOZ_ANDROID_GOOGLE_VR']: 218 OS_LIBS += [ 219 '-L%s' % CONFIG['MOZ_ANDROID_GOOGLE_VR_LIBS'], 220 '-lgvr', 221 ] 222 223OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS'] 224OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS'] 225 226if CONFIG['SERVO_TARGET_DIR']: 227 if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'): 228 OS_LIBS += ['%s/geckoservo' % CONFIG['SERVO_TARGET_DIR']] 229 else: 230 OS_LIBS += ['-L%s' % CONFIG['SERVO_TARGET_DIR'], '-lgeckoservo'] 231 232if CONFIG['MOZ_SYSTEM_JPEG']: 233 OS_LIBS += CONFIG['MOZ_JPEG_LIBS'] 234 235if CONFIG['MOZ_SYSTEM_PNG']: 236 OS_LIBS += CONFIG['MOZ_PNG_LIBS'] 237 238if CONFIG['MOZ_SYSTEM_HUNSPELL']: 239 OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS'] 240 241if CONFIG['MOZ_SYSTEM_LIBEVENT']: 242 OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS'] 243 244if CONFIG['MOZ_SYSTEM_LIBVPX']: 245 OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS'] 246 247if not CONFIG['MOZ_TREE_PIXMAN']: 248 OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS'] 249 250if CONFIG['MOZ_ALSA']: 251 OS_LIBS += CONFIG['MOZ_ALSA_LIBS'] 252 253if CONFIG['HAVE_CLOCK_MONOTONIC']: 254 OS_LIBS += CONFIG['REALTIME_LIBS'] 255 256OS_LIBS += CONFIG['ICONV_LIBS'] 257 258if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'): 259 OS_LIBS += CONFIG['TK_LIBS'] 260 261if CONFIG['OS_ARCH'] == 'OpenBSD': 262 OS_LIBS += [ 263 'sndio', 264 ] 265 266if CONFIG['MOZ_ENABLE_DBUS']: 267 OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS'] 268 269if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: 270 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': 271 OS_LIBS += [l for l in CONFIG['TK_LIBS'] 272 if l not in ('-lgtk-3', '-lgdk-3')] 273 else: 274 OS_LIBS += CONFIG['TK_LIBS'] 275 OS_LIBS += CONFIG['XLDFLAGS'] 276 OS_LIBS += CONFIG['XLIBS'] 277 OS_LIBS += CONFIG['XEXT_LIBS'] 278 OS_LIBS += CONFIG['MOZ_PANGO_LIBS'] 279 OS_LIBS += CONFIG['XT_LIBS'] 280 OS_LIBS += [ 281 'gthread-2.0', 282 ] 283 284if CONFIG['MOZ_ENABLE_STARTUP_NOTIFICATION']: 285 OS_LIBS += CONFIG['MOZ_STARTUP_NOTIFICATION_LIBS'] 286 287if CONFIG['MOZ_ENABLE_LIBPROXY']: 288 OS_LIBS += CONFIG['MOZ_LIBPROXY_LIBS'] 289 290if CONFIG['OS_ARCH'] == 'SunOS': 291 OS_LIBS += [ 292 'elf', 293 ] 294 if CONFIG['CC_TYPE'] in ('clang', 'gcc'): 295 OS_LIBS += [ 296 'demangle', 297 ] 298 299if CONFIG['OS_ARCH'] == 'FreeBSD': 300 OS_LIBS += [ 301 'util', 302 ] 303 304if CONFIG['OS_ARCH'] == 'WINNT': 305 OS_LIBS += [ 306 'shell32', 307 'ole32', 308 'version', 309 'winspool', 310 'comdlg32', 311 'imm32', 312 'msimg32', 313 'netapi32', 314 'shlwapi', 315 'ws2_32', 316 'dwmapi', 317 'iphlpapi', 318 'uxtheme', 319 'setupapi', 320 'secur32', 321 'sensorsapi', 322 'portabledeviceguids', 323 'wininet', 324 'wbemuuid', 325 'wintrust', 326 'wtsapi32', 327 'locationapi', 328 'sapi', 329 'dxguid', 330 ] 331 if CONFIG['ACCESSIBILITY']: 332 OS_LIBS += [ 333 'oleacc', 334 ] 335 336if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 337 OS_LIBS += [ 338 'usp10', 339 'oleaut32', 340 ] 341 342if CONFIG['COMPILE_ENVIRONMENT']: 343 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'): 344 full_libname = SHARED_LIBRARY_NAME 345 else: 346 full_libname = '%s%s%s' % ( 347 CONFIG['DLL_PREFIX'], 348 LIBRARY_NAME, 349 CONFIG['DLL_SUFFIX'] 350 ) 351 GENERATED_FILES += [('dependentlibs.list', 'dependentlibs.list.gtest')] 352 dep_libs_list = GENERATED_FILES[('dependentlibs.list', 'dependentlibs.list.gtest')] 353 dep_libs_list.script = 'dependentlibs.py:gen_list' 354 dep_libs_list.inputs = [ 355 '!%s' % full_libname, 356 ] 357 FINAL_TARGET_FILES += ['!dependentlibs.list', '!dependentlibs.list.gtest'] 358 359 if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android': 360 GENERATED_FILES += ['symverscript'] 361 GENERATED_FILES['symverscript'].script = 'gen_symverscript.py' 362 GENERATED_FILES['symverscript'].inputs = ['symverscript.in'] 363 SYMBOLS_FILE = '!symverscript' 364 365# This library needs to be last to make XPCOM module registration work. 366USE_LIBS += ['StaticXULComponentsEnd'] 367 368# The above library needs to be last for C++ purposes. This library, 369# however, is entirely composed of Rust code, and needs to come after 370# all the C++ code so any possible C++ -> Rust calls can be resolved. 371USE_LIBS += ['gkrust'] 372