blob: a89931b43203f3506a15d9ea47d78b4c3a50800f [file] [log] [blame]
mtklein7fbfbbe2016-07-21 12:25:45 -07001# 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
mtklein3e8012e2016-09-21 09:14:19 -07006is_skia_standalone = true
7
mtklein7fbfbbe2016-07-21 12:25:45 -07008# It's best to keep the names and defaults of is_foo flags consistent with Chrome.
9
10declare_args() {
mtklein88a7ac02016-09-14 11:16:49 -070011 is_official_build = false
mtklein7fbfbbe2016-07-21 12:25:45 -070012 is_component_build = false
mtklein7d6fb2c2016-08-25 14:50:44 -070013 ndk = ""
Mike Kleinb7ce80b2016-12-14 13:17:53 -050014 if (target_cpu == "x86" || target_cpu == "mipsel" || target_cpu == "arm") {
15 ndk_api = 18
16 } else {
17 ndk_api = 21
18 }
mtklein2b3c2a32016-09-08 08:39:34 -070019 sanitize = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070020}
mtklein88a7ac02016-09-14 11:16:49 -070021declare_args() {
22 is_debug = !is_official_build
23}
24
25assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070026
27# Platform detection
28if (target_os == "") {
29 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070030 if (ndk != "") {
31 target_os = "android"
32 }
mtklein7fbfbbe2016-07-21 12:25:45 -070033}
34if (current_os == "") {
35 current_os = target_os
36}
37
38is_android = current_os == "android"
39is_fuchsia = current_os == "fuchsia"
40is_ios = current_os == "ios"
41is_linux = current_os == "linux"
42is_mac = current_os == "mac"
43is_win = current_os == "win"
44
mtklein349cece2016-08-26 08:13:04 -070045if (target_cpu == "") {
46 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040047 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070048 target_cpu = "arm64"
49 }
50}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050051if (target_cpu == "x86_64") {
52 target_cpu = "x64"
53}
mtklein349cece2016-08-26 08:13:04 -070054if (current_cpu == "") {
55 current_cpu = target_cpu
56}
mtklein7fbfbbe2016-07-21 12:25:45 -070057
mtklein7d6fb2c2016-08-25 14:50:44 -070058if (is_android) {
59 ndk_host = ""
60 ndk_target = ""
61 ndk_platform = ""
62 ndk_stdlib = ""
mtklein6ef69992016-09-14 06:12:09 -070063 ndk_gccdir = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050064 ndk_gdbserver = ""
65 ndk_simpleperf = ""
mtklein6ef69992016-09-14 06:12:09 -070066
mtklein349cece2016-08-26 08:13:04 -070067 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070068 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070069 } else if (host_os == "mac") {
70 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -040071 } else if (host_os == "win") {
72 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -070073 }
mtklein349cece2016-08-26 08:13:04 -070074
mtklein7d6fb2c2016-08-25 14:50:44 -070075 if (target_cpu == "arm64") {
76 ndk_target = "aarch64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070077 ndk_platform = "android-${ndk_api}/arch-arm64"
mtklein7d6fb2c2016-08-25 14:50:44 -070078 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -070079 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050080 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
81 ndk_simpleperf = "simpleperf/android/arm64/simpleperf"
mtklein349cece2016-08-26 08:13:04 -070082 } else if (target_cpu == "arm") {
83 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -070084 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -070085 ndk_stdlib = "armeabi-v7a"
86 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050087 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
88 ndk_simpleperf = "simpleperf/android/arm/simpleperf"
mtklein349cece2016-08-26 08:13:04 -070089 } else if (target_cpu == "mips64el") {
90 ndk_target = "mips64el-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070091 ndk_platform = "android-${ndk_api}/arch-mips64"
mtklein349cece2016-08-26 08:13:04 -070092 ndk_stdlib = "mips64"
93 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050094 ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -070095 } else if (target_cpu == "mipsel") {
96 ndk_target = "mipsel-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070097 ndk_platform = "android-${ndk_api}/arch-mips"
mtklein349cece2016-08-26 08:13:04 -070098 ndk_stdlib = "mips"
99 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500100 ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700101 } else if (target_cpu == "x64") {
102 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700103 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700104 ndk_stdlib = "x86_64"
105 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500106 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
107 ndk_simpleperf = "simpleperf/android/x86_64/simpleperf"
mtklein349cece2016-08-26 08:13:04 -0700108 } else if (target_cpu == "x86") {
109 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700110 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -0700111 ndk_stdlib = "x86"
112 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500113 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
114 ndk_simpleperf = "simpleperf/android/x86/simpleperf"
mtklein7d6fb2c2016-08-25 14:50:44 -0700115 }
116}
117
mtklein5db44aa2016-07-29 09:10:31 -0700118# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700119template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700120 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700121 if (is_component_build) {
122 _component_mode = "shared_library"
123 }
124
125 target(_component_mode, target_name) {
126 forward_variables_from(invoker, "*")
127 }
128}
129
130# Default configs
halcanary19a97202016-08-03 15:08:04 -0700131default_configs = [
132 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400133 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700134 "//gn:no_rtti",
Mike Kleinc7165c22016-10-12 23:58:06 -0400135 "//gn:warnings",
Mike Klein50500ad2016-11-16 12:13:44 -0500136 "//gn:warnings_except_public_headers",
halcanary19a97202016-08-03 15:08:04 -0700137]
Mike Klein09008ff2017-01-21 15:35:10 +0000138if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700139 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700140}
mtklein88a7ac02016-09-14 11:16:49 -0700141if (!is_official_build) {
142 default_configs += [ "//gn:debug_symbols" ]
143}
Mike Klein121563e2016-10-04 17:09:13 -0400144default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700145
146set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400147 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700148}
149
150set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700151 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700152}
153
154set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700155 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700156}
157
158set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700159 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700160}
161
162set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700163 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700164 if (!is_component_build) {
165 complete_static_lib = true
166 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700167}
168
herbb6318bf2016-09-16 13:29:57 -0700169if (is_win) {
170 # Windows tool chain
171 set_default_toolchain("//gn:msvc")
172} else {
173 # GCC-like toolchains, including Clang.
174 set_default_toolchain("//gn:gcc_like")
175}