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 | |
mtklein | 3e8012e | 2016-09-21 09:14:19 -0700 | [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 | 4fdc543 | 2016-10-11 11:21:36 -0400 | [diff] [blame] | 14 | ndk_api = 21 |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 15 | sanitize = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 16 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 17 | declare_args() { |
| 18 | is_debug = !is_official_build |
| 19 | } |
| 20 | |
| 21 | assert(!(is_debug && is_official_build)) |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 22 | |
| 23 | # Platform detection |
| 24 | if (target_os == "") { |
| 25 | target_os = host_os |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 26 | if (ndk != "") { |
| 27 | target_os = "android" |
| 28 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 29 | } |
| 30 | if (current_os == "") { |
| 31 | current_os = target_os |
| 32 | } |
| 33 | |
| 34 | is_android = current_os == "android" |
| 35 | is_fuchsia = current_os == "fuchsia" |
| 36 | is_ios = current_os == "ios" |
| 37 | is_linux = current_os == "linux" |
| 38 | is_mac = current_os == "mac" |
| 39 | is_win = current_os == "win" |
| 40 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 41 | if (target_cpu == "") { |
| 42 | target_cpu = host_cpu |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 43 | if (is_android || is_ios) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 44 | target_cpu = "arm64" |
| 45 | } |
| 46 | } |
| 47 | if (current_cpu == "") { |
| 48 | current_cpu = target_cpu |
| 49 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 50 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 51 | if (is_android) { |
| 52 | ndk_host = "" |
| 53 | ndk_target = "" |
| 54 | ndk_platform = "" |
| 55 | ndk_stdlib = "" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 56 | ndk_gccdir = "" |
| 57 | |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 58 | if (host_os == "linux") { |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 59 | ndk_host = "linux-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 60 | } else if (host_os == "mac") { |
| 61 | ndk_host = "darwin-x86_64" |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 62 | } else if (host_os == "win") { |
| 63 | ndk_host = "windows-x86_64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 64 | } |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 65 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 66 | if (target_cpu == "arm64") { |
| 67 | ndk_target = "aarch64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 68 | ndk_platform = "android-${ndk_api}/arch-arm64" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 69 | ndk_stdlib = "arm64-v8a" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 70 | ndk_gccdir = ndk_target |
| 71 | } else if (target_cpu == "arm") { |
| 72 | ndk_target = "arm-linux-androideabi" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 73 | ndk_platform = "android-${ndk_api}/arch-arm" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 74 | ndk_stdlib = "armeabi-v7a" |
| 75 | ndk_gccdir = ndk_target |
| 76 | } else if (target_cpu == "mips64el") { |
| 77 | ndk_target = "mips64el-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 78 | ndk_platform = "android-${ndk_api}/arch-mips64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 79 | ndk_stdlib = "mips64" |
| 80 | ndk_gccdir = ndk_target |
| 81 | } else if (target_cpu == "mipsel") { |
| 82 | ndk_target = "mipsel-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 83 | ndk_platform = "android-${ndk_api}/arch-mips" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 84 | ndk_stdlib = "mips" |
| 85 | ndk_gccdir = ndk_target |
| 86 | } else if (target_cpu == "x64") { |
| 87 | ndk_target = "x86_64-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 88 | ndk_platform = "android-${ndk_api}/arch-x86_64" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 89 | ndk_stdlib = "x86_64" |
| 90 | ndk_gccdir = ndk_stdlib |
| 91 | } else if (target_cpu == "x86") { |
| 92 | ndk_target = "i686-linux-android" |
mtklein | 6ef6999 | 2016-09-14 06:12:09 -0700 | [diff] [blame] | 93 | ndk_platform = "android-${ndk_api}/arch-x86" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 94 | ndk_stdlib = "x86" |
| 95 | ndk_gccdir = ndk_stdlib |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 99 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 100 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 101 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 102 | if (is_component_build) { |
| 103 | _component_mode = "shared_library" |
| 104 | } |
| 105 | |
| 106 | target(_component_mode, target_name) { |
| 107 | forward_variables_from(invoker, "*") |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | # Default configs |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 112 | default_configs = [ |
| 113 | "//gn:default", |
Mike Klein | 6e55fef | 2016-10-26 11:41:47 -0400 | [diff] [blame] | 114 | "//gn:no_exceptions", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 115 | "//gn:no_rtti", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 116 | "//gn:warnings", |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 117 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 118 | if (!is_debug) { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 119 | default_configs += [ "//gn:release" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 120 | } |
mtklein | 88a7ac0 | 2016-09-14 11:16:49 -0700 | [diff] [blame] | 121 | if (!is_official_build) { |
| 122 | default_configs += [ "//gn:debug_symbols" ] |
| 123 | } |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 124 | default_configs += [ "//gn:extra_flags" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 125 | |
| 126 | set_defaults("executable") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 127 | configs = [ "//gn:executable" ] + default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 131 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 135 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 139 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 143 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 144 | if (!is_component_build) { |
| 145 | complete_static_lib = true |
| 146 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 147 | } |
| 148 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 149 | if (is_win) { |
| 150 | # Windows tool chain |
| 151 | set_default_toolchain("//gn:msvc") |
| 152 | } else { |
| 153 | # GCC-like toolchains, including Clang. |
| 154 | set_default_toolchain("//gn:gcc_like") |
| 155 | } |