blob: 5f1c31dc3b37c31daeba3866c55d02bd50abd07c [file] [log] [blame]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +00001/*
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
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000020// 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.
Oystein Eftevaagff729592018-02-12 14:24:06 -080022#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)())
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000026
Primiano Tuccice19ae92018-03-29 23:50:42 +010027#if defined(__ANDROID__)
Oystein Eftevaagff729592018-02-12 14:24:06 -080028#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
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000031#elif defined(__APPLE__)
Oystein Eftevaagff729592018-02-12 14:24:06 -080032#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
33#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 1
34#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000035#elif defined(__linux__)
Oystein Eftevaagff729592018-02-12 14:24:06 -080036#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0
37#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX() 0
38#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 1
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000039#else
40#error OS not supported (see build_config.h)
41#endif
42
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000043#if defined(PERFETTO_BUILD_WITH_ANDROID)
Oystein Eftevaagff729592018-02-12 14:24:06 -080044#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_BUILD() 1
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000045#else
Oystein Eftevaagff729592018-02-12 14:24:06 -080046#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_BUILD() 0
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000047#endif
48
Oystein Eftevaagf7a0d7e2018-01-12 13:02:43 -080049#if defined(PERFETTO_BUILD_WITH_CHROMIUM)
Oystein Eftevaagff729592018-02-12 14:24:06 -080050#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_CHROMIUM_BUILD() 1
Oystein Eftevaagf7a0d7e2018-01-12 13:02:43 -080051#else
Oystein Eftevaagff729592018-02-12 14:24:06 -080052#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_CHROMIUM_BUILD() 0
Oystein Eftevaagf7a0d7e2018-01-12 13:02:43 -080053#endif
54
Lalit Magantid0e76792018-02-12 14:25:01 +000055#if defined(PERFETTO_START_DAEMONS_FOR_TESTING)
Oystein Eftevaagff729592018-02-12 14:24:06 -080056#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_START_DAEMONS() 1
Lalit Magantid0e76792018-02-12 14:25:01 +000057#else
Oystein Eftevaagff729592018-02-12 14:24:06 -080058#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_START_DAEMONS() 0
Lalit Magantid0e76792018-02-12 14:25:01 +000059#endif
60
Lalit Maganti41844ed2018-05-23 14:41:43 +010061#if defined(PERFETTO_BUILD_WITH_ANDROID_USERDEBUG)
62#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 1
63#else
64#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_ANDROID_USERDEBUG_BUILD() 0
65#endif
66
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000067#endif // INCLUDE_PERFETTO_BASE_BUILD_CONFIG_H_