blob: 2a4837bf14ce647befca30d752321a32f4fd0107 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file adds defines about the platform we're currently building on.
6// Operating System:
7// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX)
8// Compiler:
9// COMPILER_MSVC / COMPILER_GCC
10// Processor:
11// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
12// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
13
14#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
17#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
21// A set of macros to use for platform detection.
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010022#if defined(ANDROID)
23#define OS_ANDROID 1
24#elif defined(__APPLE__)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000025#define OS_MACOSX 1
26#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
27#define OS_IOS 1
28#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
Torne (Richard Coles)58218062012-11-14 11:43:16 +000029#elif defined(__native_client__)
30#define OS_NACL 1
31#elif defined(__linux__)
32#define OS_LINUX 1
33// Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
Torne (Richard Coles)8bcbed82013-10-22 16:41:35 +010034#if !defined(TOOLKIT_VIEWS) && defined(USE_X11) && !defined(USE_AURA)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000035#define TOOLKIT_GTK
36#endif
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010037#if defined(__GLIBC__) && !defined(__UCLIBC__)
38// we really are using glibc, not uClibc pretending to be glibc
39#define LIBC_GLIBC
40#endif
Torne (Richard Coles)58218062012-11-14 11:43:16 +000041#elif defined(_WIN32)
42#define OS_WIN 1
43#define TOOLKIT_VIEWS 1
44#elif defined(__FreeBSD__)
45#define OS_FREEBSD 1
46#define TOOLKIT_GTK
47#elif defined(__OpenBSD__)
48#define OS_OPENBSD 1
49#define TOOLKIT_GTK
50#elif defined(__sun)
51#define OS_SOLARIS 1
52#define TOOLKIT_GTK
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000053#elif defined(__QNXNTO__)
54#define OS_QNX 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +000055#else
56#error Please add support for your platform in build/build_config.h
57#endif
58
59#if defined(USE_OPENSSL) && defined(USE_NSS)
60#error Cannot use both OpenSSL and NSS
61#endif
62
63// For access to standard BSD features, use OS_BSD instead of a
64// more specific macro.
65#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
66#define OS_BSD 1
67#endif
68
69// For access to standard POSIXish features, use OS_POSIX instead of a
70// more specific macro.
71#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
72 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000073 defined(OS_NACL) || defined(OS_QNX)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000074#define OS_POSIX 1
75#endif
76
Torne (Richard Coles)58218062012-11-14 11:43:16 +000077// Use tcmalloc
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010078#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
79 !defined(NO_TCMALLOC)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000080#define USE_TCMALLOC 1
81#endif
82
83// Compiler detection.
84#if defined(__GNUC__)
85#define COMPILER_GCC 1
86#elif defined(_MSC_VER)
87#define COMPILER_MSVC 1
88#else
89#error Please add support for your compiler in build/build_config.h
90#endif
91
92// Processor architecture detection. For more info on what's defined, see:
93// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
94// http://www.agner.org/optimize/calling_conventions.pdf
95// or with gcc, run: "echo | gcc -E -dM -"
96#if defined(_M_X64) || defined(__x86_64__)
97#define ARCH_CPU_X86_FAMILY 1
98#define ARCH_CPU_X86_64 1
99#define ARCH_CPU_64_BITS 1
100#define ARCH_CPU_LITTLE_ENDIAN 1
101#elif defined(_M_IX86) || defined(__i386__)
102#define ARCH_CPU_X86_FAMILY 1
103#define ARCH_CPU_X86 1
104#define ARCH_CPU_32_BITS 1
105#define ARCH_CPU_LITTLE_ENDIAN 1
106#elif defined(__ARMEL__)
107#define ARCH_CPU_ARM_FAMILY 1
108#define ARCH_CPU_ARMEL 1
109#define ARCH_CPU_32_BITS 1
110#define ARCH_CPU_LITTLE_ENDIAN 1
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +0000111#elif defined(__arm64__)
112#define ARCH_CPU_ARM_FAMILY 1
113#define ARCH_CPU_ARM64 1
114#define ARCH_CPU_64_BITS 1
115#define ARCH_CPU_LITTLE_ENDIAN 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000116#elif defined(__pnacl__)
117#define ARCH_CPU_32_BITS 1
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000118#define ARCH_CPU_LITTLE_ENDIAN 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000119#elif defined(__MIPSEL__)
120#define ARCH_CPU_MIPS_FAMILY 1
121#define ARCH_CPU_MIPSEL 1
122#define ARCH_CPU_32_BITS 1
123#define ARCH_CPU_LITTLE_ENDIAN 1
124#else
125#error Please add support for your architecture in build/build_config.h
126#endif
127
128// Type detection for wchar_t.
129#if defined(OS_WIN)
130#define WCHAR_T_IS_UTF16
131#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
132 defined(__WCHAR_MAX__) && \
133 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
134#define WCHAR_T_IS_UTF32
135#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
136 defined(__WCHAR_MAX__) && \
137 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
138// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
139// compile in this mode (in particular, Chrome doesn't). This is intended for
140// other projects using base who manage their own dependencies and make sure
141// short wchar works for them.
142#define WCHAR_T_IS_UTF16
143#else
144#error Please add support for your compiler in build/build_config.h
145#endif
146
147#if defined(__ARMEL__) && !defined(OS_IOS)
148#define WCHAR_T_IS_UNSIGNED 1
149#elif defined(__MIPSEL__)
150#define WCHAR_T_IS_UNSIGNED 0
151#endif
152
153#if defined(OS_ANDROID)
154// The compiler thinks std::string::const_iterator and "const char*" are
155// equivalent types.
156#define STD_STRING_ITERATOR_IS_CHAR_POINTER
157// The compiler thinks base::string16::const_iterator and "char16*" are
158// equivalent types.
159#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
160#endif
161
162#endif // BUILD_BUILD_CONFIG_H_