mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 1 | # Copyright 2016 Google Inc. |
| 2 | # |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
Mike Klein | 3669a82 | 2017-03-03 10:55:02 -0500 | [diff] [blame] | 6 | is_skia_standalone = true |
| 7 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 8 | # It's best to keep the names and defaults of is_foo flags consistent with Chrome. |
| 9 | |
| 10 | declare_args() { |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 11 | is_official_build = false |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 12 | is_component_build = false |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 13 | ndk = "" |
Mike Klein | b7ce80b | 2016-12-14 13:17:53 -0500 | [diff] [blame] | 14 | if (target_cpu == "x86" || target_cpu == "mipsel" || target_cpu == "arm") { |
| 15 | ndk_api = 18 |
| 16 | } else { |
| 17 | ndk_api = 21 |
| 18 | } |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 19 | sanitize = "" |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 20 | |
| 21 | ar = "ar" |
| 22 | cc = "cc" |
| 23 | cxx = "c++" |
| 24 | |
| 25 | msvc = 2015 |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 26 | clang_win = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 27 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 28 | declare_args() { |
| 29 | is_debug = !is_official_build |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 30 | |
| 31 | if (msvc == 2015) { |
| 32 | windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0" |
| 33 | } else { |
| 34 | windk = "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional" |
| 35 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | assert(!(is_debug && is_official_build)) |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 39 | |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 40 | if (target_cpu == "wasm") { |
| 41 | target_os = "wasm" |
| 42 | } |
| 43 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 44 | # Platform detection |
| 45 | if (target_os == "") { |
| 46 | target_os = host_os |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 47 | if (ndk != "") { |
| 48 | target_os = "android" |
| 49 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 50 | } |
| 51 | if (current_os == "") { |
| 52 | current_os = target_os |
| 53 | } |
| 54 | |
| 55 | is_android = current_os == "android" |
| 56 | is_fuchsia = current_os == "fuchsia" |
Matthew Leibowitz | 3150ec6 | 2017-03-14 16:22:32 -0400 | [diff] [blame] | 57 | is_ios = current_os == "ios" || current_os == "tvos" |
| 58 | is_tvos = current_os == "tvos" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 59 | is_linux = current_os == "linux" |
| 60 | is_mac = current_os == "mac" |
| 61 | is_win = current_os == "win" |
| 62 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 63 | if (target_cpu == "") { |
| 64 | target_cpu = host_cpu |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 65 | if (is_android || is_ios) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 66 | target_cpu = "arm64" |
| 67 | } |
| 68 | } |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 69 | if (target_cpu == "x86_64") { |
| 70 | target_cpu = "x64" |
| 71 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 72 | if (current_cpu == "") { |
| 73 | current_cpu = target_cpu |
| 74 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 75 | |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 76 | is_clang = is_android || is_ios || is_mac || |
| 77 | (cc == "clang" && cxx == "clang++") || clang_win != "" |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 78 | if (!is_clang && !is_win) { |
| 79 | is_clang = exec_script("gn/is_clang.py", |
| 80 | [ |
| 81 | cc, |
| 82 | cxx, |
| 83 | ], |
| 84 | "value") |
| 85 | } |
| 86 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 87 | if (is_android) { |
| 88 | ndk_host = "" |
| 89 | ndk_target = "" |
| 90 | ndk_platform = "" |
| 91 | ndk_stdlib = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 92 | ndk_gccdir = "" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 93 | ndk_gdbserver = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 94 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 95 | if (host_os == "linux") { |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 96 | ndk_host = "linux-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 97 | } else if (host_os == "mac") { |
| 98 | ndk_host = "darwin-x86_64" |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 99 | } else if (host_os == "win") { |
| 100 | ndk_host = "windows-x86_64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 101 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 102 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 103 | if (target_cpu == "arm64") { |
| 104 | ndk_target = "aarch64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 105 | ndk_platform = "android-${ndk_api}/arch-arm64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 106 | ndk_stdlib = "arm64-v8a" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 107 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 108 | ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 109 | } else if (target_cpu == "arm") { |
| 110 | ndk_target = "arm-linux-androideabi" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 111 | ndk_platform = "android-${ndk_api}/arch-arm" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 112 | ndk_stdlib = "armeabi-v7a" |
| 113 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 114 | ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 115 | } else if (target_cpu == "mips64el") { |
| 116 | ndk_target = "mips64el-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 117 | ndk_platform = "android-${ndk_api}/arch-mips64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 118 | ndk_stdlib = "mips64" |
| 119 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 120 | ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 121 | } else if (target_cpu == "mipsel") { |
| 122 | ndk_target = "mipsel-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 123 | ndk_platform = "android-${ndk_api}/arch-mips" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 124 | ndk_stdlib = "mips" |
| 125 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 126 | ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 127 | } else if (target_cpu == "x64") { |
| 128 | ndk_target = "x86_64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 129 | ndk_platform = "android-${ndk_api}/arch-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 130 | ndk_stdlib = "x86_64" |
| 131 | ndk_gccdir = ndk_stdlib |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 132 | ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 133 | } else if (target_cpu == "x86") { |
| 134 | ndk_target = "i686-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 135 | ndk_platform = "android-${ndk_api}/arch-x86" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 136 | ndk_stdlib = "x86" |
| 137 | ndk_gccdir = ndk_stdlib |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 138 | ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 142 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 143 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 144 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 145 | if (is_component_build) { |
| 146 | _component_mode = "shared_library" |
| 147 | } |
| 148 | |
| 149 | target(_component_mode, target_name) { |
| 150 | forward_variables_from(invoker, "*") |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | # Default configs |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 155 | default_configs = [ |
| 156 | "//gn:default", |
Mike Klein | 6e55fef | 2016-10-26 11:41:47 -0400 | [diff] [blame] | 157 | "//gn:no_exceptions", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 158 | "//gn:no_rtti", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 159 | "//gn:warnings", |
Mike Klein | 50500ad | 2016-11-16 12:13:44 -0500 | [diff] [blame] | 160 | "//gn:warnings_except_public_headers", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 161 | ] |
Mike Klein | 09008ff | 2017-01-21 15:35:10 +0000 | [diff] [blame] | 162 | if (!is_debug) { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 163 | default_configs += [ "//gn:release" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 164 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 165 | if (!is_official_build) { |
| 166 | default_configs += [ "//gn:debug_symbols" ] |
| 167 | } |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 168 | default_configs += [ "//gn:extra_flags" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 169 | |
| 170 | set_defaults("executable") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 171 | configs = [ "//gn:executable" ] + default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 175 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 179 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 183 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 187 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 188 | if (!is_component_build) { |
| 189 | complete_static_lib = true |
| 190 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 191 | } |
| 192 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 193 | if (is_win) { |
| 194 | # Windows tool chain |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 195 | set_default_toolchain("//gn/toolchain:msvc") |
| 196 | default_toolchain_name = "msvc" |
| 197 | host_toolchain = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 198 | } else { |
| 199 | # GCC-like toolchains, including Clang. |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 200 | set_default_toolchain("//gn/toolchain:gcc_like") |
| 201 | default_toolchain_name = "gcc_like" |
| 202 | host_toolchain = "gcc_like_host" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 203 | } |