1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef INCLUDE_PERFETTO_BASE_BUILD_CONFIG_H_
18#define INCLUDE_PERFETTO_BASE_BUILD_CONFIG_H_
19
20// Allows to define build flags that give a compiler error if the header that
21// defined the flag is not included, instead of silently ignoring the #if block.
22#define PERFETTO_BUILDFLAG_CAT_INDIRECT(a, b) a##b
23#define PERFETTO_BUILDFLAG_CAT(a, b) PERFETTO_BUILDFLAG_CAT_INDIRECT(a, b)
24#define PERFETTO_BUILDFLAG(flag) \
25 (PERFETTO_BUILDFLAG_CAT(PERFETTO_BUILDFLAG_DEFINE_, flag)())
26
27#if defined(__ANDROID__)
28#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 1
29#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
30#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
31#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
32#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
33#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
34#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
35#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
36#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
37#elif defined(__APPLE__)
38#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
39#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 1
40#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
41#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
42#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
43#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
44#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
45// Include TARGET_OS_IPHONE when on __APPLE__ systems.
46#include <TargetConditionals.h>
47#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
48#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
49#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 1
50#else
51#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 1
52#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
53#endif
54#elif defined(__linux__)
55#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
56#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 1
57#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
58#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
59#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
60#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
61#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
62#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
63#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
64#elif defined(_WIN32)
65#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
66#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
67#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 1
68#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
69#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
70#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
71#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
72#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
73#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
74#elif defined(__EMSCRIPTEN__)
75#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
76#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
77#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
78#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
79#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
80#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
81#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 1
82#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
83#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
84#elif defined(__Fuchsia__)
85#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
86#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
87#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
88#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
89#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
90#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
91#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
92#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 1
93#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
94#elif defined(__native_client__)
95#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
96#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
97#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
98#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0
99#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0
100#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
101#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
102#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
103#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 1
104#else
105#error OS not supported (see build_config.h)
106#endif
107
108#if defined(__clang__)
109#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 1
110#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
111#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
112#elif defined(__GNUC__) // Careful: Clang also defines this!
113#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
114#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 1
115#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
116#elif defined(_MSC_VER)
117#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
118#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
119#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 1
120#else
121#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
122#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
123#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
124#endif
125
126#if defined(PERFETTO_BUILD_WITH_ANDROID_USERDEBUG)
127#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 1
128#else
129#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 0
130#endif
131
132// perfetto_build_flags.h contains the tweakable build flags defined via GN.
133// - In GN builds (e.g., standalone, chromium, v8) this file is generated at
134// build time via the gen_rule //gn/gen_buildflags.
135// - In Android in-tree builds, this file is generated by tools/gen_android_bp
136// and checked in into include/perfetto/base/build_configs/android_tree/. The
137// default cflags add this path to the default include path.
138// - Similarly, in bazel builds, this file is generated by tools/gen_bazel and
139// checked in into include/perfetto/base/build_configs/bazel/.
140// - In amalgamated builds, this file is generated by tools/gen_amalgamated and
141// added to the amalgamated headers.
142#include "perfetto_build_flags.h" // no-include-violation-check
143
144#endif // INCLUDE_PERFETTO_BASE_BUILD_CONFIG_H_
145

source code of dart_sdk/third_party/perfetto/include/perfetto/base/build_config.h