blob: 2b3ae33292831080208824550418f6052141eb24 [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
Mike Klein3669a822017-03-03 10:55:02 -05006is_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"
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040040is_ios = current_os == "ios" || current_os == "tvos"
41is_tvos = current_os == "tvos"
mtklein7fbfbbe2016-07-21 12:25:45 -070042is_linux = current_os == "linux"
43is_mac = current_os == "mac"
44is_win = current_os == "win"
45
mtklein349cece2016-08-26 08:13:04 -070046if (target_cpu == "") {
47 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040048 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070049 target_cpu = "arm64"
50 }
51}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050052if (target_cpu == "x86_64") {
53 target_cpu = "x64"
54}
mtklein349cece2016-08-26 08:13:04 -070055if (current_cpu == "") {
56 current_cpu = target_cpu
57}
mtklein7fbfbbe2016-07-21 12:25:45 -070058
mtklein7d6fb2c2016-08-25 14:50:44 -070059if (is_android) {
60 ndk_host = ""
61 ndk_target = ""
62 ndk_platform = ""
63 ndk_stdlib = ""
mtklein6ef69992016-09-14 06:12:09 -070064 ndk_gccdir = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050065 ndk_gdbserver = ""
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"
mtklein349cece2016-08-26 08:13:04 -070081 } else if (target_cpu == "arm") {
82 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -070083 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -070084 ndk_stdlib = "armeabi-v7a"
85 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050086 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -070087 } else if (target_cpu == "mips64el") {
88 ndk_target = "mips64el-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070089 ndk_platform = "android-${ndk_api}/arch-mips64"
mtklein349cece2016-08-26 08:13:04 -070090 ndk_stdlib = "mips64"
91 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050092 ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -070093 } else if (target_cpu == "mipsel") {
94 ndk_target = "mipsel-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070095 ndk_platform = "android-${ndk_api}/arch-mips"
mtklein349cece2016-08-26 08:13:04 -070096 ndk_stdlib = "mips"
97 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -050098 ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -070099 } else if (target_cpu == "x64") {
100 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700101 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700102 ndk_stdlib = "x86_64"
103 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500104 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700105 } else if (target_cpu == "x86") {
106 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700107 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -0700108 ndk_stdlib = "x86"
109 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500110 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700111 }
112}
113
mtklein5db44aa2016-07-29 09:10:31 -0700114# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700115template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700116 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700117 if (is_component_build) {
118 _component_mode = "shared_library"
119 }
120
121 target(_component_mode, target_name) {
122 forward_variables_from(invoker, "*")
123 }
124}
125
126# Default configs
halcanary19a97202016-08-03 15:08:04 -0700127default_configs = [
128 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400129 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700130 "//gn:no_rtti",
Mike Kleinc7165c22016-10-12 23:58:06 -0400131 "//gn:warnings",
Mike Klein50500ad2016-11-16 12:13:44 -0500132 "//gn:warnings_except_public_headers",
halcanary19a97202016-08-03 15:08:04 -0700133]
Mike Klein09008ff2017-01-21 15:35:10 +0000134if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700135 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700136}
mtklein88a7ac02016-09-14 11:16:49 -0700137if (!is_official_build) {
138 default_configs += [ "//gn:debug_symbols" ]
139}
Mike Klein121563e2016-10-04 17:09:13 -0400140default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700141
142set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400143 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700144}
145
146set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700147 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700148}
149
150set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700151 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700152}
153
154set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700155 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700156}
157
158set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700159 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700160 if (!is_component_build) {
161 complete_static_lib = true
162 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700163}
164
herbb6318bf2016-09-16 13:29:57 -0700165if (is_win) {
166 # Windows tool chain
167 set_default_toolchain("//gn:msvc")
168} else {
169 # GCC-like toolchains, including Clang.
170 set_default_toolchain("//gn:gcc_like")
171}