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 ndk = "" 14 if (target_cpu == "x86" || target_cpu == "mipsel" || target_cpu == "arm") { 15 ndk_api = 18 16 } else { 17 ndk_api = 21 18 } 19 sanitize = "" 20 21 ar = "ar" 22 cc = "cc" 23 cxx = "c++" 24 25 msvc = 2015 26} 27declare_args() { 28 is_debug = !is_official_build 29 30 if (msvc == 2015) { 31 windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0" 32 } else { 33 windk = "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional" 34 } 35} 36 37assert(!(is_debug && is_official_build)) 38 39# Platform detection 40if (target_os == "") { 41 target_os = host_os 42 if (ndk != "") { 43 target_os = "android" 44 } 45} 46if (current_os == "") { 47 current_os = target_os 48} 49 50is_android = current_os == "android" 51is_fuchsia = current_os == "fuchsia" 52is_ios = current_os == "ios" || current_os == "tvos" 53is_tvos = current_os == "tvos" 54is_linux = current_os == "linux" 55is_mac = current_os == "mac" 56is_win = current_os == "win" 57 58if (target_cpu == "") { 59 target_cpu = host_cpu 60 if (is_android || is_ios) { 61 target_cpu = "arm64" 62 } 63} 64if (target_cpu == "x86_64") { 65 target_cpu = "x64" 66} 67if (current_cpu == "") { 68 current_cpu = target_cpu 69} 70 71if (is_android) { 72 ndk_host = "" 73 ndk_target = "" 74 ndk_platform = "" 75 ndk_stdlib = "" 76 ndk_gccdir = "" 77 ndk_gdbserver = "" 78 79 if (host_os == "linux") { 80 ndk_host = "linux-x86_64" 81 } else if (host_os == "mac") { 82 ndk_host = "darwin-x86_64" 83 } else if (host_os == "win") { 84 ndk_host = "windows-x86_64" 85 } 86 87 if (target_cpu == "arm64") { 88 ndk_target = "aarch64-linux-android" 89 ndk_platform = "android-${ndk_api}/arch-arm64" 90 ndk_stdlib = "arm64-v8a" 91 ndk_gccdir = ndk_target 92 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver" 93 } else if (target_cpu == "arm") { 94 ndk_target = "arm-linux-androideabi" 95 ndk_platform = "android-${ndk_api}/arch-arm" 96 ndk_stdlib = "armeabi-v7a" 97 ndk_gccdir = ndk_target 98 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver" 99 } else if (target_cpu == "mips64el") { 100 ndk_target = "mips64el-linux-android" 101 ndk_platform = "android-${ndk_api}/arch-mips64" 102 ndk_stdlib = "mips64" 103 ndk_gccdir = ndk_target 104 ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver" 105 } else if (target_cpu == "mipsel") { 106 ndk_target = "mipsel-linux-android" 107 ndk_platform = "android-${ndk_api}/arch-mips" 108 ndk_stdlib = "mips" 109 ndk_gccdir = ndk_target 110 ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver" 111 } else if (target_cpu == "x64") { 112 ndk_target = "x86_64-linux-android" 113 ndk_platform = "android-${ndk_api}/arch-x86_64" 114 ndk_stdlib = "x86_64" 115 ndk_gccdir = ndk_stdlib 116 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver" 117 } else if (target_cpu == "x86") { 118 ndk_target = "i686-linux-android" 119 ndk_platform = "android-${ndk_api}/arch-x86" 120 ndk_stdlib = "x86" 121 ndk_gccdir = ndk_stdlib 122 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver" 123 } 124} 125 126# A component is either a static or a shared library. 127template("component") { 128 _component_mode = "static_library" 129 if (is_component_build) { 130 _component_mode = "shared_library" 131 } 132 133 target(_component_mode, target_name) { 134 forward_variables_from(invoker, "*") 135 } 136} 137 138# Default configs 139default_configs = [ 140 "//gn:default", 141 "//gn:no_exceptions", 142 "//gn:no_rtti", 143 "//gn:warnings", 144 "//gn:warnings_except_public_headers", 145] 146if (!is_debug) { 147 default_configs += [ "//gn:release" ] 148} 149if (!is_official_build) { 150 default_configs += [ "//gn:debug_symbols" ] 151} 152default_configs += [ "//gn:extra_flags" ] 153 154set_defaults("executable") { 155 configs = [ "//gn:executable" ] + default_configs 156} 157 158set_defaults("source_set") { 159 configs = default_configs 160} 161 162set_defaults("static_library") { 163 configs = default_configs 164} 165 166set_defaults("shared_library") { 167 configs = default_configs 168} 169 170set_defaults("component") { 171 configs = default_configs 172 if (!is_component_build) { 173 complete_static_lib = true 174 } 175} 176 177if (is_win) { 178 # Windows tool chain 179 set_default_toolchain("//gn/toolchain:msvc") 180 default_toolchain_name = "msvc" 181 host_toolchain = "msvc" 182} else { 183 # GCC-like toolchains, including Clang. 184 set_default_toolchain("//gn/toolchain:gcc_like") 185 default_toolchain_name = "gcc_like" 186 host_toolchain = "gcc_like_host" 187} 188