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 | 9c1c892 | 2017-11-28 14:31:14 -0500 | [diff] [blame] | 14 | |
| 15 | # It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't. |
Mike Klein | f32b27d | 2017-12-05 08:50:20 -0500 | [diff] [blame] | 16 | if (target_cpu == "x86" || target_cpu == "arm") { |
Mike Klein | 9c1c892 | 2017-11-28 14:31:14 -0500 | [diff] [blame] | 17 | ndk_api = 16 |
Mike Klein | b7ce80b | 2016-12-14 13:17:53 -0500 | [diff] [blame] | 18 | } else { |
| 19 | ndk_api = 21 |
| 20 | } |
Mike Klein | 9c1c892 | 2017-11-28 14:31:14 -0500 | [diff] [blame] | 21 | |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 22 | sanitize = "" |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 23 | |
| 24 | ar = "ar" |
| 25 | cc = "cc" |
| 26 | cxx = "c++" |
| 27 | |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 28 | win_sdk = "C:/Program Files (x86)/Windows Kits/10" |
| 29 | win_sdk_version = "" |
| 30 | |
| 31 | win_vc = "" |
| 32 | win_toolchain_version = "" |
| 33 | |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 34 | clang_win = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 35 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 36 | declare_args() { |
| 37 | is_debug = !is_official_build |
| 38 | } |
| 39 | |
| 40 | assert(!(is_debug && is_official_build)) |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 41 | |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 42 | if (target_cpu == "wasm") { |
| 43 | target_os = "wasm" |
| 44 | } |
| 45 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 46 | # Platform detection |
| 47 | if (target_os == "") { |
| 48 | target_os = host_os |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 49 | if (ndk != "") { |
| 50 | target_os = "android" |
| 51 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 52 | } |
| 53 | if (current_os == "") { |
| 54 | current_os = target_os |
| 55 | } |
| 56 | |
| 57 | is_android = current_os == "android" |
| 58 | is_fuchsia = current_os == "fuchsia" |
Matthew Leibowitz | 3150ec6 | 2017-03-14 16:22:32 -0400 | [diff] [blame] | 59 | is_ios = current_os == "ios" || current_os == "tvos" |
| 60 | is_tvos = current_os == "tvos" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 61 | is_linux = current_os == "linux" |
| 62 | is_mac = current_os == "mac" |
| 63 | is_win = current_os == "win" |
| 64 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 65 | if (target_cpu == "") { |
| 66 | target_cpu = host_cpu |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 67 | if (is_android || is_ios) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 68 | target_cpu = "arm64" |
| 69 | } |
| 70 | } |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 71 | if (target_cpu == "x86_64") { |
| 72 | target_cpu = "x64" |
| 73 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 74 | if (current_cpu == "") { |
| 75 | current_cpu = target_cpu |
| 76 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 77 | |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 78 | is_clang = is_android || is_ios || is_mac || |
| 79 | (cc == "clang" && cxx == "clang++") || clang_win != "" |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 80 | if (!is_clang && !is_win) { |
| 81 | is_clang = exec_script("gn/is_clang.py", |
| 82 | [ |
| 83 | cc, |
| 84 | cxx, |
| 85 | ], |
| 86 | "value") |
| 87 | } |
| 88 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 89 | if (is_android) { |
| 90 | ndk_host = "" |
| 91 | ndk_target = "" |
| 92 | ndk_platform = "" |
| 93 | ndk_stdlib = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 94 | ndk_gccdir = "" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 95 | ndk_gdbserver = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 96 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 97 | if (host_os == "linux") { |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 98 | ndk_host = "linux-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 99 | } else if (host_os == "mac") { |
| 100 | ndk_host = "darwin-x86_64" |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 101 | } else if (host_os == "win") { |
| 102 | ndk_host = "windows-x86_64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 103 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 104 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 105 | if (target_cpu == "arm64") { |
| 106 | ndk_target = "aarch64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 107 | ndk_platform = "android-${ndk_api}/arch-arm64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 108 | ndk_stdlib = "arm64-v8a" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 109 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 110 | ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 111 | } else if (target_cpu == "arm") { |
| 112 | ndk_target = "arm-linux-androideabi" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 113 | ndk_platform = "android-${ndk_api}/arch-arm" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 114 | ndk_stdlib = "armeabi-v7a" |
| 115 | ndk_gccdir = ndk_target |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 116 | ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 117 | } else if (target_cpu == "x64") { |
| 118 | ndk_target = "x86_64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 119 | ndk_platform = "android-${ndk_api}/arch-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 120 | ndk_stdlib = "x86_64" |
| 121 | ndk_gccdir = ndk_stdlib |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 122 | ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 123 | } else if (target_cpu == "x86") { |
| 124 | ndk_target = "i686-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 125 | ndk_platform = "android-${ndk_api}/arch-x86" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 126 | ndk_stdlib = "x86" |
| 127 | ndk_gccdir = ndk_stdlib |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 128 | ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 132 | msvc = "" |
| 133 | if (target_os == "win") { |
Brian Osman | c50f8e0 | 2018-02-08 10:24:09 -0500 | [diff] [blame] | 134 | # By default we look for 2017 (Pro & Community), then 2015. If MSVC is installed in a |
| 135 | # non-default location, you can set win_vc to inform us where it is. |
| 136 | vc_2017_pro_default = |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 137 | "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC" |
Brian Osman | c50f8e0 | 2018-02-08 10:24:09 -0500 | [diff] [blame] | 138 | vc_2017_com_default = |
| 139 | "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC" |
Hal Canary | 28728e4 | 2018-02-14 11:25:31 -0500 | [diff] [blame] | 140 | vc_2017_bt_default = |
| 141 | "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC" |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 142 | vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC" |
| 143 | |
| 144 | if (win_vc == "") { |
Brian Osman | c50f8e0 | 2018-02-08 10:24:09 -0500 | [diff] [blame] | 145 | if ("True" == exec_script("//gn/checkdir.py", |
| 146 | [ "$vc_2017_pro_default" ], |
| 147 | "trim string")) { |
| 148 | win_vc = vc_2017_pro_default |
| 149 | msvc = 2017 |
| 150 | } else if ("True" == exec_script("//gn/checkdir.py", |
| 151 | [ "$vc_2017_com_default" ], |
| 152 | "trim string")) { |
| 153 | win_vc = vc_2017_com_default |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 154 | msvc = 2017 |
| 155 | } else if ("True" == exec_script("//gn/checkdir.py", |
Hal Canary | 28728e4 | 2018-02-14 11:25:31 -0500 | [diff] [blame] | 156 | [ "$vc_2017_bt_default" ], |
| 157 | "trim string")) { |
| 158 | win_vc = vc_2017_bt_default |
| 159 | msvc = 2017 |
| 160 | } else if ("True" == exec_script("//gn/checkdir.py", |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 161 | [ "$vc_2015_default" ], |
| 162 | "trim string")) { |
| 163 | win_vc = vc_2015_default |
| 164 | msvc = 2015 |
| 165 | } |
| 166 | } |
| 167 | assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory. |
| 168 | |
| 169 | if (msvc == "") { |
| 170 | if ("True" == |
| 171 | exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) { |
| 172 | msvc = 2017 |
| 173 | } else { |
| 174 | msvc = 2015 |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 179 | if (target_os == "win") { |
| 180 | if (msvc == 2017 && win_toolchain_version == "") { |
| 181 | win_toolchain_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 182 | [ |
| 183 | "$win_vc/Tools/MSVC", |
| 184 | "[0-9]{2}\.[0-9]{2}\.[0-9]{5}", |
| 185 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 186 | "trim string") |
| 187 | } |
| 188 | if (win_sdk_version == "") { |
| 189 | win_sdk_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 190 | [ |
| 191 | "$win_sdk/Include", |
| 192 | "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", |
| 193 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 194 | "trim string") |
| 195 | } |
| 196 | } |
| 197 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 198 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 199 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 200 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 201 | if (is_component_build) { |
| 202 | _component_mode = "shared_library" |
| 203 | } |
| 204 | |
| 205 | target(_component_mode, target_name) { |
| 206 | forward_variables_from(invoker, "*") |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | # Default configs |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 211 | default_configs = [ |
| 212 | "//gn:default", |
Mike Klein | 6e55fef | 2016-10-26 11:41:47 -0400 | [diff] [blame] | 213 | "//gn:no_exceptions", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 214 | "//gn:no_rtti", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 215 | "//gn:warnings", |
Mike Klein | 50500ad | 2016-11-16 12:13:44 -0500 | [diff] [blame] | 216 | "//gn:warnings_except_public_headers", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 217 | ] |
Mike Klein | 09008ff | 2017-01-21 15:35:10 +0000 | [diff] [blame] | 218 | if (!is_debug) { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 219 | default_configs += [ "//gn:release" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 220 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 221 | if (!is_official_build) { |
| 222 | default_configs += [ "//gn:debug_symbols" ] |
| 223 | } |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 224 | default_configs += [ "//gn:extra_flags" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 225 | |
| 226 | set_defaults("executable") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 227 | configs = [ "//gn:executable" ] + default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 231 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 235 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 239 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 243 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 244 | if (!is_component_build) { |
| 245 | complete_static_lib = true |
| 246 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 247 | } |
| 248 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 249 | if (is_win) { |
| 250 | # Windows tool chain |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 251 | set_default_toolchain("//gn/toolchain:msvc") |
| 252 | default_toolchain_name = "msvc" |
| 253 | host_toolchain = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 254 | } else { |
| 255 | # GCC-like toolchains, including Clang. |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 256 | set_default_toolchain("//gn/toolchain:gcc_like") |
| 257 | default_toolchain_name = "gcc_like" |
| 258 | host_toolchain = "gcc_like_host" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 259 | } |