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 | |
Mike Klein | 5b52c52 | 2019-07-03 10:44:21 -0500 | [diff] [blame] | 15 | # Android 5.0, Lollipop |
| 16 | ndk_api = 21 |
Mike Klein | 9c1c892 | 2017-11-28 14:31:14 -0500 | [diff] [blame] | 17 | |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 18 | sanitize = "" |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 19 | |
| 20 | ar = "ar" |
| 21 | cc = "cc" |
| 22 | cxx = "c++" |
| 23 | |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 24 | win_sdk = "C:/Program Files (x86)/Windows Kits/10" |
| 25 | win_sdk_version = "" |
| 26 | |
| 27 | win_vc = "" |
| 28 | win_toolchain_version = "" |
| 29 | |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 30 | clang_win = "" |
Ben Wagner | b6f98ea | 2019-12-21 00:53:11 -0500 | [diff] [blame] | 31 | clang_win_version = "" |
Jim Van Verth | 2d36627 | 2020-11-18 15:44:04 -0500 | [diff] [blame] | 32 | |
| 33 | ios_min_target = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 34 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 35 | declare_args() { |
| 36 | is_debug = !is_official_build |
| 37 | } |
| 38 | |
| 39 | assert(!(is_debug && is_official_build)) |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 40 | |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 41 | if (target_cpu == "wasm") { |
| 42 | target_os = "wasm" |
| 43 | } |
| 44 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 45 | # Platform detection |
| 46 | if (target_os == "") { |
| 47 | target_os = host_os |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 48 | if (ndk != "") { |
| 49 | target_os = "android" |
| 50 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 51 | } |
| 52 | if (current_os == "") { |
| 53 | current_os = target_os |
| 54 | } |
| 55 | |
| 56 | is_android = current_os == "android" |
| 57 | is_fuchsia = current_os == "fuchsia" |
Matthew Leibowitz | 3150ec6 | 2017-03-14 16:22:32 -0400 | [diff] [blame] | 58 | is_ios = current_os == "ios" || current_os == "tvos" |
| 59 | is_tvos = current_os == "tvos" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 60 | is_linux = current_os == "linux" |
| 61 | is_mac = current_os == "mac" |
| 62 | is_win = current_os == "win" |
| 63 | |
Stephen White | 20c626a | 2019-10-15 13:35:37 -0400 | [diff] [blame] | 64 | # This is just to make the Dawn build files happy. Skia itself uses target_os = "linux" |
| 65 | # for ChromeOS, so this variable will not affect Skia proper. |
| 66 | is_chromeos = false |
| 67 | |
Brian Osman | 56ff5de | 2021-01-12 12:40:13 -0500 | [diff] [blame] | 68 | # This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios. |
| 69 | is_apple = is_mac || is_ios |
| 70 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 71 | if (target_cpu == "") { |
| 72 | target_cpu = host_cpu |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 73 | if (is_android || is_ios) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 74 | target_cpu = "arm64" |
| 75 | } |
| 76 | } |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 77 | if (target_cpu == "x86_64") { |
| 78 | target_cpu = "x64" |
| 79 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 80 | if (current_cpu == "") { |
| 81 | current_cpu = target_cpu |
| 82 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 83 | |
John Rosasco | 24cbdab | 2019-09-25 14:14:35 -0700 | [diff] [blame] | 84 | is_clang = is_android || is_ios || is_mac || is_fuchsia || |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 85 | (cc == "clang" && cxx == "clang++") || clang_win != "" |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 86 | if (!is_clang && !is_win) { |
John Rosasco | 1edd468 | 2019-11-08 12:22:06 -0800 | [diff] [blame] | 87 | is_clang = exec_script("//gn/is_clang.py", |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 88 | [ |
| 89 | cc, |
| 90 | cxx, |
| 91 | ], |
| 92 | "value") |
| 93 | } |
| 94 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 95 | if (is_android) { |
| 96 | ndk_host = "" |
| 97 | ndk_target = "" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 98 | ndk_gdbserver = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 99 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 100 | if (host_os == "linux") { |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 101 | ndk_host = "linux-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 102 | } else if (host_os == "mac") { |
| 103 | ndk_host = "darwin-x86_64" |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 104 | } else if (host_os == "win") { |
| 105 | ndk_host = "windows-x86_64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 106 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 107 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 108 | if (target_cpu == "arm64") { |
| 109 | ndk_target = "aarch64-linux-android" |
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") { |
Mike Klein | 5b52c52 | 2019-07-03 10:44:21 -0500 | [diff] [blame] | 112 | ndk_target = "armv7a-linux-androideabi" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 113 | ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 114 | } else if (target_cpu == "x64") { |
| 115 | ndk_target = "x86_64-linux-android" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 116 | ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 117 | } else if (target_cpu == "x86") { |
| 118 | ndk_target = "i686-linux-android" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 119 | ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 123 | if (target_os == "win") { |
Dawson Coleman | 3c88857 | 2019-01-08 17:37:43 -0600 | [diff] [blame] | 124 | # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a |
Brian Osman | c50f8e0 | 2018-02-08 10:24:09 -0500 | [diff] [blame] | 125 | # non-default location, you can set win_vc to inform us where it is. |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 126 | |
| 127 | if (win_vc == "") { |
Hal Canary | f72728e | 2019-07-10 11:24:52 -0400 | [diff] [blame] | 128 | win_vc = exec_script("//gn/find_msvc.py", [], "trim string") |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 129 | } |
Mike Klein | a01c6b0 | 2020-04-01 13:47:34 -0500 | [diff] [blame] | 130 | assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC |
| 131 | # directory. |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 132 | } |
| 133 | |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 134 | if (target_os == "win") { |
Hal Canary | f72728e | 2019-07-10 11:24:52 -0400 | [diff] [blame] | 135 | if (win_toolchain_version == "") { |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 136 | win_toolchain_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 137 | [ |
| 138 | "$win_vc/Tools/MSVC", |
| 139 | "[0-9]{2}\.[0-9]{2}\.[0-9]{5}", |
| 140 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 141 | "trim string") |
| 142 | } |
| 143 | if (win_sdk_version == "") { |
| 144 | win_sdk_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 145 | [ |
| 146 | "$win_sdk/Include", |
| 147 | "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", |
| 148 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 149 | "trim string") |
| 150 | } |
Ben Wagner | b6f98ea | 2019-12-21 00:53:11 -0500 | [diff] [blame] | 151 | if (clang_win != "" && clang_win_version == "") { |
| 152 | clang_win_version = exec_script("//gn/highest_version_dir.py", |
| 153 | [ |
| 154 | "$clang_win/lib/clang", |
| 155 | "[0-9]+\.[0-9]+\.[0-9]+", |
| 156 | ], |
| 157 | "trim string") |
| 158 | } |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 159 | } |
| 160 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 161 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 162 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 163 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 164 | if (is_component_build) { |
| 165 | _component_mode = "shared_library" |
| 166 | } |
| 167 | |
| 168 | target(_component_mode, target_name) { |
| 169 | forward_variables_from(invoker, "*") |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | # Default configs |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 174 | default_configs = [ |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 175 | "//gn/skia:default", |
| 176 | "//gn/skia:no_exceptions", |
| 177 | "//gn/skia:no_rtti", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 178 | ] |
Mike Klein | 09008ff | 2017-01-21 15:35:10 +0000 | [diff] [blame] | 179 | if (!is_debug) { |
Mike Klein | 7ea977b | 2018-09-19 13:44:43 -0400 | [diff] [blame] | 180 | default_configs += [ |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 181 | "//gn/skia:optimize", |
| 182 | "//gn/skia:NDEBUG", |
Mike Klein | 7ea977b | 2018-09-19 13:44:43 -0400 | [diff] [blame] | 183 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 184 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 185 | if (!is_official_build) { |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 186 | default_configs += [ "//gn/skia:debug_symbols" ] |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 187 | } |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 188 | default_configs += [ "//gn/skia:extra_flags" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 189 | |
| 190 | set_defaults("executable") { |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 191 | configs = [ "//gn/skia:executable" ] + default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 195 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 199 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 203 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 207 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 208 | if (!is_component_build) { |
| 209 | complete_static_lib = true |
| 210 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Ben Wagner | 3d9ab7e | 2021-03-16 14:29:20 -0400 | [diff] [blame] | 213 | skia_target_default_configs = [] |
| 214 | if (!is_official_build) { |
| 215 | skia_target_default_configs += [ "//gn/skia:warnings" ] |
| 216 | } |
| 217 | |
| 218 | skia_header_target_default_configs = [] |
| 219 | if (!is_official_build) { |
| 220 | skia_header_target_default_configs += |
| 221 | [ "//gn/skia:warnings_for_public_headers" ] |
| 222 | } |
| 223 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 224 | if (is_win) { |
| 225 | # Windows tool chain |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 226 | set_default_toolchain("//gn/toolchain:msvc") |
| 227 | default_toolchain_name = "msvc" |
| 228 | host_toolchain = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 229 | } else { |
| 230 | # GCC-like toolchains, including Clang. |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 231 | set_default_toolchain("//gn/toolchain:gcc_like") |
| 232 | default_toolchain_name = "gcc_like" |
| 233 | host_toolchain = "gcc_like_host" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 234 | } |