Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / tools / profiler / moz.build
blob827c93fb41b51d98f89958ba80e7e10fb1c16e56
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["TARGET_CPU"] 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["TARGET_CPU"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
86             UNIFIED_SOURCES += [
87                 "core/PowerCounters-linux.cpp",
88             ]
89         if CONFIG["TARGET_CPU"] == "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["TARGET_CPU"] == "aarch64":
98             UNIFIED_SOURCES += [
99                 "core/PowerCounters-mac-arm64.cpp",
100             ]
101         if CONFIG["TARGET_CPU"] == "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/ETWTools.cpp",\r
112             }
113         SOURCES += [
114             "core/ProfilerCPUFreq-win.cpp",
115             "core/shared-libraries-win32.cc",
116         ]
118     LOCAL_INCLUDES += [
119         "/caps",
120         "/docshell/base",
121         "/ipc/chromium/src",
122         "/mozglue/linker",
123         "/netwerk/base",
124         "/netwerk/protocol/http",
125         "/toolkit/components/jsoncpp/include",
126         "/toolkit/crashreporter/google-breakpad/src",
127         "/tools/profiler/core/",
128         "/tools/profiler/gecko/",
129         "/xpcom/base",
130     ]
132     if CONFIG["OS_TARGET"] == "Android":
133         DEFINES["ANDROID_NDK_MAJOR_VERSION"] = CONFIG["ANDROID_NDK_MAJOR_VERSION"]
134         DEFINES["ANDROID_NDK_MINOR_VERSION"] = CONFIG["ANDROID_NDK_MINOR_VERSION"]
135         LOCAL_INCLUDES += [
136             # We need access to Breakpad's getcontext(3) which is suitable for Android
137             "/toolkit/crashreporter/google-breakpad/src/common/android/include",
138         ]
140     if CONFIG["MOZ_VTUNE"]:
141         DEFINES["MOZ_VTUNE_INSTRUMENTATION"] = True
142         UNIFIED_SOURCES += [
143             "core/VTuneProfiler.cpp",
144         ]
146     XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.toml"]
147     MOCHITEST_CHROME_MANIFESTS += ["tests/chrome/chrome.toml"]
148     BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.toml"]
150 UNIFIED_SOURCES += [
151     "core/MicroGeckoProfiler.cpp",
152     "core/ProfileAdditionalInformation.cpp",
153     "core/ProfilerBindings.cpp",
154     "core/ProfilerThreadRegistration.cpp",
155     "core/ProfilerThreadRegistrationData.cpp",
156     "core/ProfilerThreadRegistry.cpp",
157     "core/ProfilerUtils.cpp",
158     "gecko/ProfilerParent.cpp",
161 IPDL_SOURCES += [
162     "gecko/PProfiler.ipdl",
163     "gecko/ProfilerTypes.ipdlh",
166 include("/ipc/chromium/chromium-config.mozbuild")
168 EXPORTS += [
169     "public/ChildProfilerController.h",
170     "public/ETWTools.h",
171     "public/GeckoProfiler.h",
172     "public/MicroGeckoProfiler.h",
173     "public/ProfileAdditionalInformation.h",
174     "public/ProfilerBindings.h",
175     "public/ProfilerControl.h",
176     "public/ProfilerParent.h",
177     "public/ProfilerRustBindings.h",
180 EXPORTS.mozilla += [
181     "public/ProfileBufferEntrySerializationGeckoExtensions.h",
182     "public/ProfileJSONWriter.h",
183     "public/ProfilerBandwidthCounter.h",
184     "public/ProfilerCounts.h",
185     "public/ProfilerLabels.h",
186     "public/ProfilerMarkers.h",
187     "public/ProfilerMarkersDetail.h",
188     "public/ProfilerMarkersPrerequisites.h",
189     "public/ProfilerMarkerTypes.h",
190     "public/ProfilerRunnable.h",
191     "public/ProfilerState.h",
192     "public/ProfilerThreadPlatformData.h",
193     "public/ProfilerThreadRegistration.h",
194     "public/ProfilerThreadRegistrationData.h",
195     "public/ProfilerThreadRegistrationInfo.h",
196     "public/ProfilerThreadRegistry.h",
197     "public/ProfilerThreadSleep.h",
198     "public/ProfilerThreadState.h",
199     "public/ProfilerUtils.h",
202 GeneratedFile(
203     "rust-api/src/gecko_bindings/profiling_categories.rs",
204     script="../../mozglue/baseprofiler/build/generate_profiling_categories.py",
205     entry_point="generate_rust_enums",
206     inputs=["../../mozglue/baseprofiler/build/profiling_categories.yaml"],
209 CONFIGURE_SUBST_FILES += [
210     "rust-api/extra-bindgen-flags",
214 if CONFIG["COMPILE_ENVIRONMENT"]:
215     CbindgenHeader("profiler_ffi_generated.h", inputs=["rust-api"])
217     EXPORTS.mozilla += [
218         "!profiler_ffi_generated.h",
219     ]
221 USE_LIBS += [
222     "jsoncpp",
225 FINAL_LIBRARY = "xul"
227 if CONFIG["ENABLE_TESTS"]:
228     DIRS += ["tests/gtest"]
230 if CONFIG["CC_TYPE"] in ("clang", "gcc"):
231     CXXFLAGS += [
232         "-Wno-error=stack-protector",
233         "-Wno-ignored-qualifiers",  # due to use of breakpad headers
234     ]
236 with Files("**"):
237     BUG_COMPONENT = ("Core", "Gecko Profiler")