• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MACOSX() 0
30 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
31 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
32 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
33 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
34 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
35 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
36 #elif defined(__APPLE__)
37 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
38 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 1
39 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
40 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
41 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
42 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
43 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
44 // Include TARGET_OS_IPHONE when on __APPLE__ systems.
45 #include <TargetConditionals.h>
46 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
47 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 1
48 #endif
49 #elif defined(__linux__)
50 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
51 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
52 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 1
53 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
54 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
55 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
56 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
57 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
58 #elif defined(_WIN32)
59 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
60 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
61 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
62 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 1
63 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
64 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
65 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
66 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
67 #elif defined(__EMSCRIPTEN__)
68 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
69 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
70 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
71 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
72 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 1
73 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
74 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
75 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
76 #elif defined(__Fuchsia__)
77 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
78 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
79 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
80 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
81 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
82 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 1
83 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0
84 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
85 #elif defined(__native_client__)
86 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
87 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
88 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
89 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0
90 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0
91 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0
92 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 1
93 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0
94 #else
95 #error OS not supported (see build_config.h)
96 #endif
97 
98 #if defined(__clang__)
99 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 1
100 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
101 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
102 #elif defined(__GNUC__) // Careful: Clang also defines this!
103 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
104 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 1
105 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
106 #elif defined(_MSC_VER)
107 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
108 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
109 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 1
110 #else
111 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_CLANG() 0
112 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_GCC() 0
113 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_COMPILER_MSVC() 0
114 #endif
115 
116 #if defined(PERFETTO_BUILD_WITH_ANDROID_USERDEBUG)
117 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 1
118 #else
119 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 0
120 #endif
121 
122 // perfetto_build_flags.h contains the tweakable build flags defined via GN.
123 // - In GN builds (e.g., standalone, chromium, v8) this file is generated at
124 //   build time via the gen_rule //gn/gen_buildflags.
125 // - In Android in-tree builds, this file is generated by tools/gen_android_bp
126 //   and checked in into include/perfetto/base/build_configs/android_tree/. The
127 //   default cflags add this path to the default include path.
128 // - Similarly, in bazel builds, this file is generated by tools/gen_bazel and
129 //   checked in into include/perfetto/base/build_configs/bazel/.
130 // - In amaglamated builds, this file is generated by tools/gen_amalgamated and
131 //   added to the amalgamated headers.
132 #include "perfetto_build_flags.h"  // no-include-violation-check
133 
134 #endif  // INCLUDE_PERFETTO_BASE_BUILD_CONFIG_H_
135