[email protected] | cea4aec | 2012-01-24 12:26:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 4 | |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 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 | |||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 14 | #ifndef BUILD_BUILD_CONFIG_H_ |
15 | #define BUILD_BUILD_CONFIG_H_ | ||||
16 | |||||
[email protected] | 1e01367 | 2012-06-29 22:12:20 | [diff] [blame] | 17 | #if defined(__APPLE__) |
18 | #include <TargetConditionals.h> | ||||
19 | #endif | ||||
20 | |||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 21 | // A set of macros to use for platform detection. |
[email protected] | c57a370 | 2013-04-04 11:51:27 | [diff] [blame] | 22 | #if defined(ANDROID) |
23 | #define OS_ANDROID 1 | ||||
24 | #elif defined(__APPLE__) | ||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 25 | #define OS_MACOSX 1 |
[email protected] | 3777ee7 | 2012-07-04 15:23:39 | [diff] [blame] | 26 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
[email protected] | 1e01367 | 2012-06-29 22:12:20 | [diff] [blame] | 27 | #define OS_IOS 1 |
[email protected] | 3777ee7 | 2012-07-04 15:23:39 | [diff] [blame] | 28 | #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
[email protected] | 19ea84ca | 2010-11-12 08:37:08 | [diff] [blame] | 29 | #elif defined(__native_client__) |
30 | #define OS_NACL 1 | ||||
[email protected] | 1020d2f | 2008-08-14 11:21:28 | [diff] [blame] | 31 | #elif defined(__linux__) |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 32 | #define OS_LINUX 1 |
[email protected] | 0ae186f | 2009-05-07 23:41:29 | [diff] [blame] | 33 | // Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined. |
[email protected] | 2fa2f2d8 | 2013-04-29 18:13:12 | [diff] [blame] | 34 | #if !defined(TOOLKIT_VIEWS) && defined(USE_X11) |
[email protected] | 0ae186f | 2009-05-07 23:41:29 | [diff] [blame] | 35 | #define TOOLKIT_GTK |
36 | #endif | ||||
[email protected] | f61b898b | 2009-02-09 15:42:08 | [diff] [blame] | 37 | #elif defined(_WIN32) |
[email protected] | 771b2fd | 2008-08-04 21:32:57 | [diff] [blame] | 38 | #define OS_WIN 1 |
[email protected] | 321792e | 2009-05-13 23:21:45 | [diff] [blame] | 39 | #define TOOLKIT_VIEWS 1 |
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 40 | #elif defined(__FreeBSD__) |
41 | #define OS_FREEBSD 1 | ||||
42 | #define TOOLKIT_GTK | ||||
[email protected] | c51e8d5 | 2009-12-11 20:04:06 | [diff] [blame] | 43 | #elif defined(__OpenBSD__) |
44 | #define OS_OPENBSD 1 | ||||
45 | #define TOOLKIT_GTK | ||||
[email protected] | 93f21e4 | 2010-04-01 00:35:15 | [diff] [blame] | 46 | #elif defined(__sun) |
[email protected] | b5c72b82 | 2010-02-18 16:11:37 | [diff] [blame] | 47 | #define OS_SOLARIS 1 |
48 | #define TOOLKIT_GTK | ||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 49 | #else |
50 | #error Please add support for your platform in build/build_config.h | ||||
51 | #endif | ||||
52 | |||||
[email protected] | 70372d4 | 2010-10-22 13:12:34 | [diff] [blame] | 53 | #if defined(USE_OPENSSL) && defined(USE_NSS) |
54 | #error Cannot use both OpenSSL and NSS | ||||
55 | #endif | ||||
56 | |||||
[email protected] | e37e88a0 | 2011-11-15 00:06:16 | [diff] [blame] | 57 | // For access to standard BSD features, use OS_BSD instead of a |
58 | // more specific macro. | ||||
59 | #if defined(OS_FREEBSD) || defined(OS_OPENBSD) | ||||
60 | #define OS_BSD 1 | ||||
61 | #endif | ||||
62 | |||||
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 63 | // For access to standard POSIXish features, use OS_POSIX instead of a |
64 | // more specific macro. | ||||
[email protected] | be16cf2 | 2011-06-27 19:13:10 | [diff] [blame] | 65 | #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ |
66 | defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ | ||||
67 | defined(OS_NACL) | ||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 68 | #define OS_POSIX 1 |
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 69 | #endif |
70 | |||||
[email protected] | 833b88a | 2009-09-22 16:16:39 | [diff] [blame] | 71 | // Use tcmalloc |
[email protected] | 3c8fe548 | 2013-05-22 15:17:03 | [diff] [blame^] | 72 | #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ |
73 | !defined(NO_TCMALLOC) | ||||
[email protected] | 833b88a | 2009-09-22 16:16:39 | [diff] [blame] | 74 | #define USE_TCMALLOC 1 |
75 | #endif | ||||
76 | |||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 77 | // Compiler detection. |
78 | #if defined(__GNUC__) | ||||
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 79 | #define COMPILER_GCC 1 |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 80 | #elif defined(_MSC_VER) |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 81 | #define COMPILER_MSVC 1 |
82 | #else | ||||
83 | #error Please add support for your compiler in build/build_config.h | ||||
84 | #endif | ||||
85 | |||||
86 | // Processor architecture detection. For more info on what's defined, see: | ||||
87 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | ||||
88 | // http://www.agner.org/optimize/calling_conventions.pdf | ||||
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 89 | // or with gcc, run: "echo | gcc -E -dM -" |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 90 | #if defined(_M_X64) || defined(__x86_64__) |
91 | #define ARCH_CPU_X86_FAMILY 1 | ||||
92 | #define ARCH_CPU_X86_64 1 | ||||
93 | #define ARCH_CPU_64_BITS 1 | ||||
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 94 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 95 | #elif defined(_M_IX86) || defined(__i386__) |
96 | #define ARCH_CPU_X86_FAMILY 1 | ||||
97 | #define ARCH_CPU_X86 1 | ||||
98 | #define ARCH_CPU_32_BITS 1 | ||||
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 99 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 100 | #elif defined(__ARMEL__) |
101 | #define ARCH_CPU_ARM_FAMILY 1 | ||||
102 | #define ARCH_CPU_ARMEL 1 | ||||
103 | #define ARCH_CPU_32_BITS 1 | ||||
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 104 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | 814127c | 2011-08-26 19:03:20 | [diff] [blame] | 105 | #elif defined(__pnacl__) |
106 | #define ARCH_CPU_32_BITS 1 | ||||
[email protected] | f7d2fbd | 2012-06-18 02:47:05 | [diff] [blame] | 107 | #elif defined(__MIPSEL__) |
108 | #define ARCH_CPU_MIPS_FAMILY 1 | ||||
109 | #define ARCH_CPU_MIPSEL 1 | ||||
110 | #define ARCH_CPU_32_BITS 1 | ||||
111 | #define ARCH_CPU_LITTLE_ENDIAN 1 | ||||
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 112 | #else |
113 | #error Please add support for your architecture in build/build_config.h | ||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 114 | #endif |
115 | |||||
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 116 | // Type detection for wchar_t. |
117 | #if defined(OS_WIN) | ||||
118 | #define WCHAR_T_IS_UTF16 | ||||
119 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ | ||||
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 120 | defined(__WCHAR_MAX__) && \ |
121 | (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) | ||||
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 122 | #define WCHAR_T_IS_UTF32 |
[email protected] | d9a30d9 | 2009-10-22 18:04:17 | [diff] [blame] | 123 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
124 | defined(__WCHAR_MAX__) && \ | ||||
125 | (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) | ||||
126 | // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to | ||||
127 | // compile in this mode (in particular, Chrome doesn't). This is intended for | ||||
128 | // other projects using base who manage their own dependencies and make sure | ||||
129 | // short wchar works for them. | ||||
130 | #define WCHAR_T_IS_UTF16 | ||||
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 131 | #else |
132 | #error Please add support for your compiler in build/build_config.h | ||||
133 | #endif | ||||
134 | |||||
[email protected] | 1e01367 | 2012-06-29 22:12:20 | [diff] [blame] | 135 | #if defined(__ARMEL__) && !defined(OS_IOS) |
136 | #define WCHAR_T_IS_UNSIGNED 1 | ||||
137 | #elif defined(__MIPSEL__) | ||||
138 | #define WCHAR_T_IS_UNSIGNED 0 | ||||
139 | #endif | ||||
140 | |||||
[email protected] | be16cf2 | 2011-06-27 19:13:10 | [diff] [blame] | 141 | #if defined(OS_ANDROID) |
142 | // The compiler thinks std::string::const_iterator and "const char*" are | ||||
143 | // equivalent types. | ||||
144 | #define STD_STRING_ITERATOR_IS_CHAR_POINTER | ||||
145 | // The compiler thinks base::string16::const_iterator and "char16*" are | ||||
146 | // equivalent types. | ||||
147 | #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER | ||||
148 | #endif | ||||
149 | |||||
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 150 | #endif // BUILD_BUILD_CONFIG_H_ |