evan@chromium.org | 50dfbc4 | 2012-01-24 21:26:40 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 4 | |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [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 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 14 | #ifndef BUILD_BUILD_CONFIG_H_ |
| 15 | #define BUILD_BUILD_CONFIG_H_ |
| 16 | |
stuartmorgan@chromium.org | 791de94 | 2012-06-30 07:12:20 +0900 | [diff] [blame] | 17 | #if defined(__APPLE__) |
| 18 | #include <TargetConditionals.h> |
| 19 | #endif |
| 20 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 21 | // A set of macros to use for platform detection. |
torne@chromium.org | a00ac9d | 2013-04-04 20:51:27 +0900 | [diff] [blame^] | 22 | #if defined(ANDROID) |
| 23 | #define OS_ANDROID 1 |
| 24 | #elif defined(__APPLE__) |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 25 | #define OS_MACOSX 1 |
bbudge@chromium.org | 3ed0c36 | 2012-07-05 00:23:39 +0900 | [diff] [blame] | 26 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
stuartmorgan@chromium.org | 791de94 | 2012-06-30 07:12:20 +0900 | [diff] [blame] | 27 | #define OS_IOS 1 |
bbudge@chromium.org | 3ed0c36 | 2012-07-05 00:23:39 +0900 | [diff] [blame] | 28 | #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
abarth@chromium.org | e716286 | 2010-11-12 17:37:08 +0900 | [diff] [blame] | 29 | #elif defined(__native_client__) |
| 30 | #define OS_NACL 1 |
deanm@google.com | 5b70cbe | 2008-08-14 20:21:28 +0900 | [diff] [blame] | 31 | #elif defined(__linux__) |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 32 | #define OS_LINUX 1 |
sky@chromium.org | 204c1d8 | 2009-05-08 08:41:29 +0900 | [diff] [blame] | 33 | // Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined. |
| 34 | #if !defined(TOOLKIT_VIEWS) |
| 35 | #define TOOLKIT_GTK |
| 36 | #endif |
maruel@chromium.org | 837a67f | 2009-02-10 00:42:08 +0900 | [diff] [blame] | 37 | #elif defined(_WIN32) |
mmentovai@google.com | 9a0fc8a | 2008-08-05 06:32:57 +0900 | [diff] [blame] | 38 | #define OS_WIN 1 |
sky@chromium.org | 95936bd | 2009-05-14 08:21:45 +0900 | [diff] [blame] | 39 | #define TOOLKIT_VIEWS 1 |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 40 | #elif defined(__FreeBSD__) |
| 41 | #define OS_FREEBSD 1 |
| 42 | #define TOOLKIT_GTK |
evan@chromium.org | 21252b1 | 2009-12-12 05:04:06 +0900 | [diff] [blame] | 43 | #elif defined(__OpenBSD__) |
| 44 | #define OS_OPENBSD 1 |
| 45 | #define TOOLKIT_GTK |
evan@chromium.org | 089339c | 2010-04-01 09:35:15 +0900 | [diff] [blame] | 46 | #elif defined(__sun) |
evan@chromium.org | d0e6b85 | 2010-02-19 01:11:37 +0900 | [diff] [blame] | 47 | #define OS_SOLARIS 1 |
| 48 | #define TOOLKIT_GTK |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 49 | #else |
| 50 | #error Please add support for your platform in build/build_config.h |
| 51 | #endif |
| 52 | |
joth@chromium.org | 0dd3527 | 2010-10-22 22:12:34 +0900 | [diff] [blame] | 53 | #if defined(USE_OPENSSL) && defined(USE_NSS) |
| 54 | #error Cannot use both OpenSSL and NSS |
| 55 | #endif |
| 56 | |
robert.nagy@gmail.com | 5f343eb | 2011-11-15 09:06:16 +0900 | [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 | |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 63 | // For access to standard POSIXish features, use OS_POSIX instead of a |
| 64 | // more specific macro. |
michaelbai@google.com | bd0b245 | 2011-06-28 04:13:10 +0900 | [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) |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 68 | #define OS_POSIX 1 |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 69 | #endif |
| 70 | |
robert.nagy@gmail.com | 5f343eb | 2011-11-15 09:06:16 +0900 | [diff] [blame] | 71 | #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ |
| 72 | !defined(OS_NACL) |
| 73 | #define USE_X11 1 // Use X for graphics. |
| 74 | #endif |
| 75 | |
sgk@chromium.org | 1be49d8 | 2009-09-23 01:16:39 +0900 | [diff] [blame] | 76 | // Use tcmalloc |
thestig@chromium.org | c491b20 | 2010-02-26 09:31:08 +0900 | [diff] [blame] | 77 | #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC) |
sgk@chromium.org | 1be49d8 | 2009-09-23 01:16:39 +0900 | [diff] [blame] | 78 | #define USE_TCMALLOC 1 |
| 79 | #endif |
| 80 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 81 | // Compiler detection. |
| 82 | #if defined(__GNUC__) |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 83 | #define COMPILER_GCC 1 |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 84 | #elif defined(_MSC_VER) |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 85 | #define COMPILER_MSVC 1 |
| 86 | #else |
| 87 | #error Please add support for your compiler in build/build_config.h |
| 88 | #endif |
| 89 | |
| 90 | // Processor architecture detection. For more info on what's defined, see: |
| 91 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 92 | // http://www.agner.org/optimize/calling_conventions.pdf |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 93 | // or with gcc, run: "echo | gcc -E -dM -" |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 94 | #if defined(_M_X64) || defined(__x86_64__) |
| 95 | #define ARCH_CPU_X86_FAMILY 1 |
| 96 | #define ARCH_CPU_X86_64 1 |
| 97 | #define ARCH_CPU_64_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 98 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 99 | #elif defined(_M_IX86) || defined(__i386__) |
| 100 | #define ARCH_CPU_X86_FAMILY 1 |
| 101 | #define ARCH_CPU_X86 1 |
| 102 | #define ARCH_CPU_32_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 103 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 104 | #elif defined(__ARMEL__) |
| 105 | #define ARCH_CPU_ARM_FAMILY 1 |
| 106 | #define ARCH_CPU_ARMEL 1 |
| 107 | #define ARCH_CPU_32_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 108 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
sehr@google.com | 15566f9 | 2011-08-27 04:03:20 +0900 | [diff] [blame] | 109 | #elif defined(__pnacl__) |
| 110 | #define ARCH_CPU_32_BITS 1 |
petarj@mips.com | d3a3e76 | 2012-06-18 11:47:05 +0900 | [diff] [blame] | 111 | #elif defined(__MIPSEL__) |
| 112 | #define ARCH_CPU_MIPS_FAMILY 1 |
| 113 | #define ARCH_CPU_MIPSEL 1 |
| 114 | #define ARCH_CPU_32_BITS 1 |
| 115 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 116 | #else |
| 117 | #error Please add support for your architecture in build/build_config.h |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 118 | #endif |
| 119 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 120 | // Type detection for wchar_t. |
| 121 | #if defined(OS_WIN) |
| 122 | #define WCHAR_T_IS_UTF16 |
| 123 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 124 | defined(__WCHAR_MAX__) && \ |
| 125 | (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 126 | #define WCHAR_T_IS_UTF32 |
brettw@chromium.org | fd7a76b | 2009-10-23 03:04:17 +0900 | [diff] [blame] | 127 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
| 128 | defined(__WCHAR_MAX__) && \ |
| 129 | (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) |
| 130 | // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to |
| 131 | // compile in this mode (in particular, Chrome doesn't). This is intended for |
| 132 | // other projects using base who manage their own dependencies and make sure |
| 133 | // short wchar works for them. |
| 134 | #define WCHAR_T_IS_UTF16 |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 135 | #else |
| 136 | #error Please add support for your compiler in build/build_config.h |
| 137 | #endif |
| 138 | |
stuartmorgan@chromium.org | 791de94 | 2012-06-30 07:12:20 +0900 | [diff] [blame] | 139 | #if defined(__ARMEL__) && !defined(OS_IOS) |
| 140 | #define WCHAR_T_IS_UNSIGNED 1 |
| 141 | #elif defined(__MIPSEL__) |
| 142 | #define WCHAR_T_IS_UNSIGNED 0 |
| 143 | #endif |
| 144 | |
michaelbai@google.com | bd0b245 | 2011-06-28 04:13:10 +0900 | [diff] [blame] | 145 | #if defined(OS_ANDROID) |
| 146 | // The compiler thinks std::string::const_iterator and "const char*" are |
| 147 | // equivalent types. |
| 148 | #define STD_STRING_ITERATOR_IS_CHAR_POINTER |
| 149 | // The compiler thinks base::string16::const_iterator and "char16*" are |
| 150 | // equivalent types. |
| 151 | #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER |
| 152 | #endif |
| 153 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 154 | #endif // BUILD_BUILD_CONFIG_H_ |