Backed out changeset 36e95068e103 (bug 1848160) for bc failures on browser_preference...
[gecko.git] / tools / profiler / moz.build
blobde362493a865594b6a8e99e4e769f9dc22acc2c2
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/.
7 if CONFIG["MOZ_GECKO_PROFILER"]:
8     DEFINES["MOZ_REPLACE_MALLOC_PREFIX"] = "profiler"
9     XPIDL_MODULE = "profiler"
10     XPIDL_SOURCES += [
11         "gecko/nsIProfiler.idl",
12     ]
13     EXPORTS += [
14         "public/GeckoProfilerReporter.h",
15         "public/ProfilerChild.h",
16         "public/ProfilerCodeAddressService.h",
17         "public/shared-libraries.h",
18     ]
19     UNIFIED_SOURCES += [
20         "core/PageInformation.cpp",
21         "core/platform.cpp",
22         "core/ProfileBuffer.cpp",
23         "core/ProfileBufferEntry.cpp",
24         "core/ProfiledThreadData.cpp",
25         "core/ProfilerBacktrace.cpp",
26         "core/ProfilerCodeAddressService.cpp",
27         "core/ProfilerMarkers.cpp",
28         "gecko/ChildProfilerController.cpp",
29         "gecko/nsProfilerStartParams.cpp",
30         "gecko/ProfilerChild.cpp",
31         "gecko/ProfilerIOInterposeObserver.cpp",
32     ]
33     if CONFIG["MOZ_REPLACE_MALLOC"] and CONFIG["MOZ_PROFILER_MEMORY"]:
34         SOURCES += [
35             "core/memory_hooks.cpp",  # Non-unified because of order of #includes
36         ]
38     XPCOM_MANIFESTS += [
39         "gecko/components.conf",
40     ]
42     if CONFIG["OS_TARGET"] == "Darwin":
43         # This file cannot be built in unified mode because it includes
44         # "nsLocalFile.h", which pulls in a system header which uses a type
45         # called TextRange, which conflicts with mozilla::TextRange due to
46         # a "using namespace mozilla;" declaration from a different file.
47         SOURCES += [
48             "gecko/nsProfiler.cpp",
49         ]
50     else:
51         UNIFIED_SOURCES += [
52             "gecko/nsProfiler.cpp",
53         ]
55     if CONFIG["OS_TARGET"] in ("Android", "Linux"):
56         UNIFIED_SOURCES += [
57             "core/ProfilerCPUFreq-linux-android.cpp",
58         ]
59     if CONFIG["OS_TARGET"] in ("Android", "Linux", "FreeBSD"):
60         if CONFIG["CPU_ARCH"] in ("arm", "aarch64", "x86", "x86_64", "mips64"):
61             UNIFIED_SOURCES += [
62                 "lul/AutoObjectMapper.cpp",
63                 "lul/LulCommon.cpp",
64                 "lul/LulDwarf.cpp",
65                 "lul/LulDwarfSummariser.cpp",
66                 "lul/LulElf.cpp",
67                 "lul/LulMain.cpp",
68                 "lul/platform-linux-lul.cpp",
69             ]
70         # These files cannot be built in unified mode because of name clashes with mozglue headers on Android.
71         SOURCES += [
72             "core/shared-libraries-linux.cc",
73         ]
74         if not CONFIG["MOZ_CRASHREPORTER"]:
75             SOURCES += [
76                 "/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.cc",
77                 "/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc",
78                 "/toolkit/crashreporter/google-breakpad/src/common/linux/linux_libc_support.cc",
79                 "/toolkit/crashreporter/google-breakpad/src/common/linux/memory_mapped_file.cc",
80             ]
81             if not CONFIG["HAVE_GETCONTEXT"]:
82                 SOURCES += [
83                     "/toolkit/crashreporter/google-breakpad/src/common/linux/breakpad_getcontext.S"
84                 ]
85         if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
86             UNIFIED_SOURCES += [
87                 "core/PowerCounters-linux.cpp",
88             ]
89         if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] != "FreeBSD":
90             SOURCES += [
91                 "core/EHABIStackWalk.cpp",
92             ]
93     elif CONFIG["OS_TARGET"] == "Darwin":
94         UNIFIED_SOURCES += [
95             "core/shared-libraries-macos.cc",
96         ]
97         if CONFIG["CPU_ARCH"] == "aarch64":
98             UNIFIED_SOURCES += [
99                 "core/PowerCounters-mac-arm64.cpp",
100             ]
101         if CONFIG["CPU_ARCH"] == "x86_64":
102             UNIFIED_SOURCES += [
103                 "core/PowerCounters-mac-amd64.cpp",
104             ]
105     elif CONFIG["OS_TARGET"] == "WINNT":
106         if CONFIG["CC_TYPE"] == "clang-cl":
107             UNIFIED_SOURCES += [
108                 "core/PowerCounters-win.cpp",
109             ]
110         SOURCES += [
111             "core/ProfilerCPUFreq-win.cpp",
112             "core/shared-libraries-win32.cc",
113         ]
115     LOCAL_INCLUDES += [
116         "/caps",
117         "/docshell/base",
118         "/ipc/chromium/src",
119         "/mozglue/linker",
120         "/netwerk/base",
121         "/netwerk/protocol/http",
122         "/toolkit/components/jsoncpp/include",
123         "/toolkit/crashreporter/google-breakpad/src",
124         "/tools/profiler/core/",
125         "/tools/profiler/gecko/",
126         "/xpcom/base",
127     ]
129     if CONFIG["OS_TARGET"] == "Android":
130         DEFINES["ANDROID_NDK_MAJOR_VERSION"] = CONFIG["ANDROID_NDK_MAJOR_VERSION"]
131         DEFINES["ANDROID_NDK_MINOR_VERSION"] = CONFIG["ANDROID_NDK_MINOR_VERSION"]
132         LOCAL_INCLUDES += [
133             # We need access to Breakpad's getcontext(3) which is suitable for Android
134             "/toolkit/crashreporter/google-breakpad/src/common/android/include",
135         ]
137     if CONFIG["MOZ_VTUNE"]:
138         DEFINES["MOZ_VTUNE_INSTRUMENTATION"] = True
139         UNIFIED_SOURCES += [
140             "core/VTuneProfiler.cpp",
141         ]
143     XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
144     MOCHITEST_CHROME_MANIFESTS += ["tests/chrome/chrome.toml"]
145     BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
147 UNIFIED_SOURCES += [
148     "core/MicroGeckoProfiler.cpp",
149     "core/ProfileAdditionalInformation.cpp",
150     "core/ProfilerBindings.cpp",
151     "core/ProfilerThreadRegistration.cpp",
152     "core/ProfilerThreadRegistrationData.cpp",
153     "core/ProfilerThreadRegistry.cpp",
154     "core/ProfilerUtils.cpp",
155     "gecko/ProfilerParent.cpp",
158 IPDL_SOURCES += [
159     "gecko/PProfiler.ipdl",
160     "gecko/ProfilerTypes.ipdlh",
163 include("/ipc/chromium/chromium-config.mozbuild")
165 EXPORTS += [
166     "public/ChildProfilerController.h",
167     "public/GeckoProfiler.h",
168     "public/MicroGeckoProfiler.h",
169     "public/ProfileAdditionalInformation.h",
170     "public/ProfilerBindings.h",
171     "public/ProfilerControl.h",
172     "public/ProfilerParent.h",
173     "public/ProfilerRustBindings.h",
176 EXPORTS.mozilla += [
177     "public/ProfileBufferEntrySerializationGeckoExtensions.h",
178     "public/ProfileJSONWriter.h",
179     "public/ProfilerCounts.h",
180     "public/ProfilerLabels.h",
181     "public/ProfilerMarkers.h",
182     "public/ProfilerMarkersDetail.h",
183     "public/ProfilerMarkersPrerequisites.h",
184     "public/ProfilerMarkerTypes.h",
185     "public/ProfilerRunnable.h",
186     "public/ProfilerState.h",
187     "public/ProfilerThreadPlatformData.h",
188     "public/ProfilerThreadRegistration.h",
189     "public/ProfilerThreadRegistrationData.h",
190     "public/ProfilerThreadRegistrationInfo.h",
191     "public/ProfilerThreadRegistry.h",
192     "public/ProfilerThreadSleep.h",
193     "public/ProfilerThreadState.h",
194     "public/ProfilerUtils.h",
197 GeneratedFile(
198     "rust-api/src/gecko_bindings/profiling_categories.rs",
199     script="../../mozglue/baseprofiler/build/generate_profiling_categories.py",
200     entry_point="generate_rust_enums",
201     inputs=["../../mozglue/baseprofiler/build/profiling_categories.yaml"],
204 CONFIGURE_SUBST_FILES += [
205     "rust-api/extra-bindgen-flags",
209 if CONFIG["COMPILE_ENVIRONMENT"]:
210     CbindgenHeader("profiler_ffi_generated.h", inputs=["rust-api"])
212     EXPORTS.mozilla += [
213         "!profiler_ffi_generated.h",
214     ]
216 USE_LIBS += [
217     "jsoncpp",
220 FINAL_LIBRARY = "xul"
222 if CONFIG["ENABLE_TESTS"]:
223     DIRS += ["tests/gtest"]
225 if CONFIG["CC_TYPE"] in ("clang", "gcc"):
226     CXXFLAGS += [
227         "-Wno-error=stack-protector",
228         "-Wno-ignored-qualifiers",  # due to use of breakpad headers
229     ]
231 with Files("**"):
232     BUG_COMPONENT = ("Core", "Gecko Profiler")