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
7include('../components/telemetry/telemetry-constants.mozbuild')
8
9with Files('**'):
10    BUG_COMPONENT = ('Toolkit', 'Startup and Profile System')
11
12if CONFIG['OS_ARCH'] == 'WINNT':
13    TEST_DIRS += ['test/win']
14
15MOCHITEST_MANIFESTS += ['test/mochitest.ini']
16BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
17XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
18
19XPIDL_SOURCES += [
20    'nsINativeAppSupport.idl',
21    'nsIXREDirProvider.idl',
22]
23
24if CONFIG['OS_ARCH'] == 'WINNT':
25    XPIDL_SOURCES += [
26        'nsIWinAppHelper.idl',
27    ]
28
29XPIDL_MODULE = 'xulapp'
30
31EXPORTS += [
32    'nsAppRunner.h',
33    'nsIAppStartupNotifier.h',
34]
35
36EXPORTS.mozilla += [
37    'AutoSQLiteLifetime.h',
38    'Bootstrap.h',
39    'CmdLineAndEnvUtils.h',
40    'SafeMode.h',
41    'UntrustedModulesData.h',
42]
43
44if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']:
45    EXPORTS += ['EventTracer.h']
46
47if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
48    EXPORTS.mozilla += [
49        'AssembleCmdLine.h',
50        'ModuleVersionInfo.h',
51        'PolicyChecks.h',
52        'UntrustedModulesProcessor.h',
53        'WinDllServices.h',
54        'WinTokenUtils.h',
55    ]
56    UNIFIED_SOURCES += [
57        '/toolkit/mozapps/update/common/updateutils_win.cpp',
58        'ModuleEvaluator.cpp',
59        'ModuleVersionInfo.cpp',
60        'nsNativeAppSupportWin.cpp',
61        'UntrustedModulesData.cpp',
62        'UntrustedModulesProcessor.cpp',
63        'WinDllServices.cpp',
64        'WinTokenUtils.cpp',
65    ]
66    DEFINES['PROXY_PRINTING'] = 1
67    LOCAL_INCLUDES += [
68        '../components/printingui',
69    ]
70    if CONFIG['MOZ_LAUNCHER_PROCESS']:
71        EXPORTS.mozilla += [
72          'LauncherRegistryInfo.h',
73        ]
74        UNIFIED_SOURCES += [
75          'LauncherRegistryInfo.cpp',
76        ]
77elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
78    UNIFIED_SOURCES += [
79        'MacApplicationDelegate.mm',
80        'MacAutoreleasePool.mm',
81        'MacLaunchHelper.mm',
82        'nsCommandLineServiceMac.mm',
83        'nsNativeAppSupportCocoa.mm',
84        'updaterfileutils_osx.mm',
85    ]
86    DEFINES['PROXY_PRINTING'] = 1
87    LOCAL_INCLUDES += [
88        '../components/printingui',
89    ]
90elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
91    UNIFIED_SOURCES += [
92        'nsNativeAppSupportDefault.cpp',
93        'UIKitDirProvider.mm',
94    ]
95elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
96    UNIFIED_SOURCES += [
97        'nsNativeAppSupportUnix.cpp',
98    ]
99else:
100    UNIFIED_SOURCES += [
101        'nsNativeAppSupportDefault.cpp',
102    ]
103
104if CONFIG['MOZ_HAS_REMOTE']:
105    LOCAL_INCLUDES += [
106        '../components/remote',
107    ]
108
109if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
110    UNIFIED_SOURCES += [
111        'nsGDKErrorHandler.cpp',
112    ]
113
114if CONFIG['MOZ_X11']:
115    EXPORTS += ['nsX11ErrorHandler.h']
116    UNIFIED_SOURCES += [
117        'nsX11ErrorHandler.cpp',
118    ]
119
120if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
121    UNIFIED_SOURCES += [
122        'nsAndroidStartup.cpp',
123    ]
124
125UNIFIED_SOURCES += [
126    '/toolkit/mozapps/update/common/commonupdatedir.cpp',
127    'AutoSQLiteLifetime.cpp',
128    'Bootstrap.cpp',
129    'CmdLineAndEnvUtils.cpp',
130    'CreateAppData.cpp',
131    'nsAppStartupNotifier.cpp',
132    'nsConsoleWriter.cpp',
133    'nsEmbeddingModule.cpp',
134    'nsNativeAppSupportBase.cpp',
135    'nsSigHandlers.cpp',
136    'nsXREDirProvider.cpp',
137]
138
139# nsAppRunner.cpp and ProfileReset.cpp cannot be built in unified mode because
140# they pull in OS X system headers.
141# nsEmbedFunctions.cpp cannot be built in unified mode because it pulls in X11 headers.
142SOURCES += [
143    '../../other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp',
144    'nsAppRunner.cpp',
145    'nsEmbedFunctions.cpp',
146    'ProfileReset.cpp',
147]
148
149if CONFIG['MOZ_X11']:
150    UNIFIED_SOURCES += [
151        'glxtest.cpp',
152    ]
153
154if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']:
155    UNIFIED_SOURCES += [
156        'EventTracer.cpp',
157    ]
158
159if CONFIG['MOZ_UPDATER']:
160    if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
161        UNIFIED_SOURCES += [
162            'nsUpdateDriver.cpp',
163        ]
164
165if CONFIG['MOZ_PDF_PRINTING']:
166    DEFINES['PROXY_PRINTING'] = 1
167    LOCAL_INCLUDES += [
168        '../components/printingui',
169    ]
170
171XPCOM_MANIFESTS += [
172    'components.conf',
173]
174
175include('/ipc/chromium/chromium-config.mozbuild')
176
177FINAL_LIBRARY = 'xul'
178
179if CONFIG['MOZ_X11']:
180    DEFINES['USE_GLX_TEST'] = True
181
182for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME',
183            'MOZ_APP_VENDOR', 'MOZ_APP_VERSION', 'OS_TARGET',
184            'MOZ_WIDGET_TOOLKIT'):
185    DEFINES[var] = '"%s"' % CONFIG[var]
186
187if CONFIG['MOZ_DEFAULT_BROWSER_AGENT'] and CONFIG['OS_ARCH'] == 'WINNT':
188    DEFINES['MOZ_DEFAULT_BROWSER_AGENT'] = CONFIG['MOZ_DEFAULT_BROWSER_AGENT']
189
190if CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
191    DEFINES['MOZ_UPDATER'] = True
192
193if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
194    DEFINES['WIN32_LEAN_AND_MEAN'] = True
195    DEFINES['UNICODE'] = True
196    DEFINES['_UNICODE'] = True
197
198if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
199    DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME']
200
201if CONFIG['TARGET_XPCOM_ABI']:
202    DEFINES['TARGET_OS_ABI'] = '"%s_%s"' % (CONFIG['OS_TARGET'],
203                                            CONFIG['TARGET_XPCOM_ABI'])
204
205if CONFIG['OS_ARCH'] == 'Linux' and 'lib64' in CONFIG['libdir']:
206    DEFINES['HAVE_USR_LIB64_DIR'] = True
207
208DEFINES['GRE_MILESTONE'] = CONFIG['GRE_MILESTONE']
209DEFINES['MOZ_APP_VERSION_DISPLAY'] = CONFIG['MOZ_APP_VERSION_DISPLAY']
210
211for var in ('APP_VERSION', 'APP_ID'):
212    DEFINES[var] = CONFIG['MOZ_%s' % var]
213
214if CONFIG['MOZ_BUILD_APP'] == 'browser':
215    DEFINES['MOZ_BUILD_APP_IS_BROWSER'] = True
216
217LOCAL_INCLUDES += [
218    '../../other-licenses/nsis/Contrib/CityHash/cityhash',
219    '../components/find',
220    '../components/printingui/ipc',
221    '../components/windowwatcher',
222    '../mozapps/update/common',
223    '../profile',
224    '/config',
225    '/dom/base',
226    '/dom/commandhandler',
227    '/dom/ipc',
228    '/dom/webbrowserpersist',
229    '/testing/gtest/mozilla',
230    '/toolkit/crashreporter',
231    '/xpcom/build',
232]
233
234if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
235    LOCAL_INCLUDES += [
236        '/security/sandbox/chromium',
237        '/security/sandbox/chromium-shim',
238    ]
239
240if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'Linux':
241    USE_LIBS += [
242        'mozsandbox',
243    ]
244
245if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
246    LOCAL_INCLUDES += [
247        '/widget',
248        '/widget/cocoa',
249        '/xpcom/base',
250    ]
251
252CXXFLAGS += CONFIG['TK_CFLAGS']
253CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
254CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
255
256if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
257    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
258
259DEFINES['TOPOBJDIR'] = TOPOBJDIR
260FINAL_TARGET_PP_FILES += [
261    'platform.ini'
262]
263
264if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
265    CXXFLAGS += ['-Wno-error=shadow']
266
267if CONFIG['MOZ_IPDL_TESTS']:
268    DEFINES['MOZ_IPDL_TESTS'] = True
269
270if CONFIG['ENABLE_TESTS']:
271    DIRS += ['test/gtest']
272