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 6is_skia_standalone = true 7 8# It's best to keep the names and defaults of is_foo flags consistent with Chrome. 9 10declare_args() { 11 is_official_build = false 12 is_component_build = false 13 use_libfuzzer = false 14 ndk = "" 15 16 # Android 5.0, Lollipop 17 ndk_api = 21 18 19 sanitize = "" 20 21 ar = "ar" 22 cc = "cc" 23 cxx = "c++" 24 25 win_sdk = "C:/Program Files (x86)/Windows Kits/10" 26 win_sdk_version = "" 27 28 win_vc = "" 29 win_toolchain_version = "" 30 31 clang_win = "" 32 clang_win_version = "" 33 34 ios_min_target = "" 35 ios_use_simulator = 36 target_os == "ios" && (target_cpu == "x86" || target_cpu == "x64") 37 38 # Enable -H, which prints the include tree during compilation. 39 # For use by external tools for analyzing include files. 40 show_includes = false 41} 42declare_args() { 43 is_debug = !is_official_build 44 45 # This affects Skia's ABI; must be set consistently for Skia and dependents. 46 is_trivial_abi = !is_official_build 47} 48 49assert(!(is_debug && is_official_build)) 50 51if (target_cpu == "wasm") { 52 target_os = "wasm" 53} 54 55# Platform detection 56if (target_os == "") { 57 target_os = host_os 58 if (ndk != "") { 59 target_os = "android" 60 } 61} 62if (current_os == "") { 63 current_os = target_os 64} 65 66is_android = current_os == "android" 67is_fuchsia = current_os == "fuchsia" 68is_ios = current_os == "ios" || current_os == "tvos" 69is_tvos = current_os == "tvos" 70is_linux = current_os == "linux" 71is_mac = current_os == "mac" 72is_wasm = current_os == "wasm" 73is_win = current_os == "win" 74 75# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux" 76# for ChromeOS, so this variable will not affect Skia proper. 77is_chromeos = false 78 79# This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios. 80is_apple = is_mac || is_ios 81 82if (target_cpu == "") { 83 target_cpu = host_cpu 84 if (is_android || is_ios) { 85 target_cpu = "arm64" 86 } 87} 88if (target_cpu == "x86_64") { 89 target_cpu = "x64" 90} 91if (current_cpu == "") { 92 current_cpu = target_cpu 93} 94 95is_clang = is_android || is_ios || is_mac || is_fuchsia || is_wasm || 96 (cc == "clang" && cxx == "clang++") || clang_win != "" 97if (!is_clang && !is_win) { 98 is_clang = exec_script("//gn/is_clang.py", 99 [ 100 cc, 101 cxx, 102 ], 103 "value") 104} 105 106if (is_android) { 107 ndk_host = "" 108 ndk_target = "" 109 110 if (host_os == "linux") { 111 ndk_host = "linux-x86_64" 112 } else if (host_os == "mac") { 113 ndk_host = "darwin-x86_64" 114 } else if (host_os == "win") { 115 ndk_host = "windows-x86_64" 116 } 117 118 if (target_cpu == "arm64") { 119 ndk_target = "aarch64-linux-android" 120 } else if (target_cpu == "arm") { 121 ndk_target = "armv7a-linux-androideabi" 122 } else if (target_cpu == "x64") { 123 ndk_target = "x86_64-linux-android" 124 } else if (target_cpu == "x86") { 125 ndk_target = "i686-linux-android" 126 } 127} 128 129if (target_os == "win") { 130 # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a 131 # non-default location, you can set win_vc to inform us where it is. 132 133 if (win_vc == "") { 134 win_vc = exec_script("//gn/find_msvc.py", [], "trim string") 135 } 136 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC 137 # directory. 138} 139 140if (target_os == "win") { 141 if (win_toolchain_version == "") { 142 win_toolchain_version = exec_script("//gn/highest_version_dir.py", 143 [ 144 "$win_vc/Tools/MSVC", 145 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}", 146 ], 147 "trim string") 148 } 149 if (win_sdk_version == "") { 150 win_sdk_version = exec_script("//gn/highest_version_dir.py", 151 [ 152 "$win_sdk/Include", 153 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", 154 ], 155 "trim string") 156 } 157 if (clang_win != "" && clang_win_version == "") { 158 clang_win_version = exec_script("//gn/highest_version_dir.py", 159 [ 160 "$clang_win/lib/clang", 161 "[0-9]+(\.[0-9]+\.[0-9]+)?", 162 ], 163 "trim string") 164 } 165} 166 167# A component is either a static or a shared library. 168template("component") { 169 _component_mode = "static_library" 170 if (is_component_build) { 171 _component_mode = "shared_library" 172 } 173 174 target(_component_mode, target_name) { 175 forward_variables_from(invoker, "*") 176 } 177} 178 179# Default configs 180default_configs = [ 181 "//gn/skia:default", 182 "//gn/skia:no_exceptions", 183 "//gn/skia:no_rtti", 184 "//gn/skia:strict_aliasing", 185] 186if (!is_debug) { 187 default_configs += [ 188 "//gn/skia:optimize", 189 "//gn/skia:NDEBUG", 190 ] 191} 192if (is_trivial_abi) { 193 default_configs += [ "//gn/skia:trivial_abi" ] 194} 195if (!is_official_build) { 196 default_configs += [ "//gn/skia:debug_symbols" ] 197} 198default_configs += [ "//gn/skia:extra_flags" ] 199 200set_defaults("executable") { 201 configs = [ "//gn/skia:executable" ] + default_configs 202} 203 204set_defaults("source_set") { 205 configs = default_configs 206} 207 208set_defaults("static_library") { 209 configs = default_configs 210} 211 212set_defaults("shared_library") { 213 configs = default_configs 214} 215 216set_defaults("component") { 217 configs = default_configs 218 if (!is_component_build) { 219 complete_static_lib = true 220 } 221} 222 223skia_target_default_configs = [] 224if (!is_official_build) { 225 skia_target_default_configs += [ "//gn/skia:warnings" ] 226} 227 228skia_header_target_default_configs = [] 229if (!is_official_build) { 230 skia_header_target_default_configs += 231 [ "//gn/skia:warnings_for_public_headers" ] 232} 233 234if (is_win) { 235 # Windows tool chain 236 set_default_toolchain("//gn/toolchain:msvc") 237 default_toolchain_name = "msvc" 238 host_toolchain = "msvc_host" 239} else if (is_wasm) { 240 set_default_toolchain("//gn/toolchain:wasm") 241 default_toolchain_name = "wasm" 242 host_toolchain = "wasm" 243} else { 244 # GCC-like toolchains, including Clang. 245 set_default_toolchain("//gn/toolchain:gcc_like") 246 default_toolchain_name = "gcc_like" 247 host_toolchain = "gcc_like_host" 248} 249