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 = "" |
Greg Daniel | 91dfa3b | 2018-05-22 13:25:15 -0400 | [diff] [blame] | 32 | |
Shachar Langbeheim | db610b3 | 2019-06-11 21:26:28 +0300 | [diff] [blame] | 33 | werror = false |
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 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 68 | if (target_cpu == "") { |
| 69 | target_cpu = host_cpu |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 70 | if (is_android || is_ios) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 71 | target_cpu = "arm64" |
| 72 | } |
| 73 | } |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 74 | if (target_cpu == "x86_64") { |
| 75 | target_cpu = "x64" |
| 76 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 77 | if (current_cpu == "") { |
| 78 | current_cpu = target_cpu |
| 79 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 80 | |
John Rosasco | 24cbdab | 2019-09-25 14:14:35 -0700 | [diff] [blame] | 81 | is_clang = is_android || is_ios || is_mac || is_fuchsia || |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 82 | (cc == "clang" && cxx == "clang++") || clang_win != "" |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 83 | if (!is_clang && !is_win) { |
John Rosasco | 1edd468 | 2019-11-08 12:22:06 -0800 | [diff] [blame] | 84 | is_clang = exec_script("//gn/is_clang.py", |
Mike Klein | c722f79 | 2017-07-31 11:57:21 -0400 | [diff] [blame] | 85 | [ |
| 86 | cc, |
| 87 | cxx, |
| 88 | ], |
| 89 | "value") |
| 90 | } |
| 91 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 92 | if (is_android) { |
| 93 | ndk_host = "" |
| 94 | ndk_target = "" |
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" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 107 | ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 108 | } else if (target_cpu == "arm") { |
Mike Klein | 5b52c52 | 2019-07-03 10:44:21 -0500 | [diff] [blame] | 109 | ndk_target = "armv7a-linux-androideabi" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 110 | ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 111 | } else if (target_cpu == "x64") { |
| 112 | ndk_target = "x86_64-linux-android" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 113 | ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 114 | } else if (target_cpu == "x86") { |
| 115 | ndk_target = "i686-linux-android" |
Derek Sollenberger | 70120c7 | 2017-01-05 11:39:04 -0500 | [diff] [blame] | 116 | ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 120 | if (target_os == "win") { |
Dawson Coleman | 3c88857 | 2019-01-08 17:37:43 -0600 | [diff] [blame] | 121 | # 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] | 122 | # 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] | 123 | |
| 124 | if (win_vc == "") { |
Hal Canary | f72728e | 2019-07-10 11:24:52 -0400 | [diff] [blame] | 125 | win_vc = exec_script("//gn/find_msvc.py", [], "trim string") |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 126 | } |
Mike Klein | a01c6b0 | 2020-04-01 13:47:34 -0500 | [diff] [blame] | 127 | assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC |
| 128 | # directory. |
Brian Osman | 852ca31 | 2017-12-07 16:16:21 -0500 | [diff] [blame] | 129 | } |
| 130 | |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 131 | if (target_os == "win") { |
Hal Canary | f72728e | 2019-07-10 11:24:52 -0400 | [diff] [blame] | 132 | if (win_toolchain_version == "") { |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 133 | win_toolchain_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 134 | [ |
| 135 | "$win_vc/Tools/MSVC", |
| 136 | "[0-9]{2}\.[0-9]{2}\.[0-9]{5}", |
| 137 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 138 | "trim string") |
| 139 | } |
| 140 | if (win_sdk_version == "") { |
| 141 | win_sdk_version = exec_script("//gn/highest_version_dir.py", |
Brian Osman | 5c54892 | 2017-12-11 14:59:03 -0500 | [diff] [blame] | 142 | [ |
| 143 | "$win_sdk/Include", |
| 144 | "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", |
| 145 | ], |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 146 | "trim string") |
| 147 | } |
Ben Wagner | b6f98ea | 2019-12-21 00:53:11 -0500 | [diff] [blame] | 148 | if (clang_win != "" && clang_win_version == "") { |
| 149 | clang_win_version = exec_script("//gn/highest_version_dir.py", |
| 150 | [ |
| 151 | "$clang_win/lib/clang", |
| 152 | "[0-9]+\.[0-9]+\.[0-9]+", |
| 153 | ], |
| 154 | "trim string") |
| 155 | } |
Mike Klein | 409506c | 2017-12-06 16:47:41 -0500 | [diff] [blame] | 156 | } |
| 157 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 158 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 159 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 160 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 161 | if (is_component_build) { |
| 162 | _component_mode = "shared_library" |
| 163 | } |
| 164 | |
| 165 | target(_component_mode, target_name) { |
| 166 | forward_variables_from(invoker, "*") |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | # Default configs |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 171 | default_configs = [ |
| 172 | "//gn:default", |
Mike Klein | 6e55fef | 2016-10-26 11:41:47 -0400 | [diff] [blame] | 173 | "//gn:no_exceptions", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 174 | "//gn:no_rtti", |
| 175 | ] |
Mike Klein | 09008ff | 2017-01-21 15:35:10 +0000 | [diff] [blame] | 176 | if (!is_debug) { |
Mike Klein | 7ea977b | 2018-09-19 13:44:43 -0400 | [diff] [blame] | 177 | default_configs += [ |
| 178 | "//gn:optimize", |
| 179 | "//gn:NDEBUG", |
| 180 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 181 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 182 | if (!is_official_build) { |
Mike Klein | d84c1e6 | 2018-09-04 10:15:58 -0400 | [diff] [blame] | 183 | default_configs += [ |
| 184 | "//gn:debug_symbols", |
| 185 | "//gn:warnings", |
| 186 | ] |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 187 | } |
Mike Klein | d84c1e6 | 2018-09-04 10:15:58 -0400 | [diff] [blame] | 188 | default_configs += [ |
| 189 | "//gn:warnings_except_public_headers", |
| 190 | "//gn:extra_flags", |
| 191 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 192 | |
| 193 | set_defaults("executable") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 194 | configs = [ "//gn:executable" ] + default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 198 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 202 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 206 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 210 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 211 | if (!is_component_build) { |
| 212 | complete_static_lib = true |
| 213 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 214 | } |
| 215 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 216 | if (is_win) { |
| 217 | # Windows tool chain |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 218 | set_default_toolchain("//gn/toolchain:msvc") |
| 219 | default_toolchain_name = "msvc" |
| 220 | host_toolchain = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 221 | } else { |
| 222 | # GCC-like toolchains, including Clang. |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 223 | set_default_toolchain("//gn/toolchain:gcc_like") |
| 224 | default_toolchain_name = "gcc_like" |
| 225 | host_toolchain = "gcc_like_host" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 226 | } |