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