blob: 057bea1faf2e18102239dc61b841d154ebd922bb [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 = ""
Ethan Nicholas762466e2017-06-29 10:03:38 -040020
21 ar = "ar"
22 cc = "cc"
23 cxx = "c++"
24
25 msvc = 2015
Mike Kleinc722f792017-07-31 11:57:21 -040026 clang_win = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070027}
mtklein88a7ac02016-09-14 11:16:49 -070028declare_args() {
29 is_debug = !is_official_build
Ethan Nicholas762466e2017-06-29 10:03:38 -040030
31 if (msvc == 2015) {
32 windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0"
33 } else {
34 windk = "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional"
35 }
mtklein88a7ac02016-09-14 11:16:49 -070036}
37
38assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070039
Kevin Lubickebf648e2017-09-21 13:45:16 -040040if (target_cpu == "wasm") {
41 target_os = "wasm"
42}
43
mtklein7fbfbbe2016-07-21 12:25:45 -070044# Platform detection
45if (target_os == "") {
46 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070047 if (ndk != "") {
48 target_os = "android"
49 }
mtklein7fbfbbe2016-07-21 12:25:45 -070050}
51if (current_os == "") {
52 current_os = target_os
53}
54
55is_android = current_os == "android"
56is_fuchsia = current_os == "fuchsia"
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040057is_ios = current_os == "ios" || current_os == "tvos"
58is_tvos = current_os == "tvos"
mtklein7fbfbbe2016-07-21 12:25:45 -070059is_linux = current_os == "linux"
60is_mac = current_os == "mac"
61is_win = current_os == "win"
62
mtklein349cece2016-08-26 08:13:04 -070063if (target_cpu == "") {
64 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040065 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070066 target_cpu = "arm64"
67 }
68}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050069if (target_cpu == "x86_64") {
70 target_cpu = "x64"
71}
mtklein349cece2016-08-26 08:13:04 -070072if (current_cpu == "") {
73 current_cpu = target_cpu
74}
mtklein7fbfbbe2016-07-21 12:25:45 -070075
Kevin Lubickebf648e2017-09-21 13:45:16 -040076is_clang = is_android || is_ios || is_mac ||
77 (cc == "clang" && cxx == "clang++") || clang_win != ""
Mike Kleinc722f792017-07-31 11:57:21 -040078if (!is_clang && !is_win) {
79 is_clang = exec_script("gn/is_clang.py",
80 [
81 cc,
82 cxx,
83 ],
84 "value")
85}
86
mtklein7d6fb2c2016-08-25 14:50:44 -070087if (is_android) {
88 ndk_host = ""
89 ndk_target = ""
90 ndk_platform = ""
91 ndk_stdlib = ""
mtklein6ef69992016-09-14 06:12:09 -070092 ndk_gccdir = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050093 ndk_gdbserver = ""
mtklein6ef69992016-09-14 06:12:09 -070094
mtklein349cece2016-08-26 08:13:04 -070095 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070096 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070097 } else if (host_os == "mac") {
98 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -040099 } else if (host_os == "win") {
100 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700101 }
mtklein349cece2016-08-26 08:13:04 -0700102
mtklein7d6fb2c2016-08-25 14:50:44 -0700103 if (target_cpu == "arm64") {
104 ndk_target = "aarch64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700105 ndk_platform = "android-${ndk_api}/arch-arm64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700106 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -0700107 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500108 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700109 } else if (target_cpu == "arm") {
110 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -0700111 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -0700112 ndk_stdlib = "armeabi-v7a"
113 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500114 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700115 } else if (target_cpu == "mips64el") {
116 ndk_target = "mips64el-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700117 ndk_platform = "android-${ndk_api}/arch-mips64"
mtklein349cece2016-08-26 08:13:04 -0700118 ndk_stdlib = "mips64"
119 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500120 ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700121 } else if (target_cpu == "mipsel") {
122 ndk_target = "mipsel-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700123 ndk_platform = "android-${ndk_api}/arch-mips"
mtklein349cece2016-08-26 08:13:04 -0700124 ndk_stdlib = "mips"
125 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500126 ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700127 } else if (target_cpu == "x64") {
128 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700129 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700130 ndk_stdlib = "x86_64"
131 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500132 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700133 } else if (target_cpu == "x86") {
134 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700135 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -0700136 ndk_stdlib = "x86"
137 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500138 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700139 }
140}
141
mtklein5db44aa2016-07-29 09:10:31 -0700142# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700143template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700144 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700145 if (is_component_build) {
146 _component_mode = "shared_library"
147 }
148
149 target(_component_mode, target_name) {
150 forward_variables_from(invoker, "*")
151 }
152}
153
154# Default configs
halcanary19a97202016-08-03 15:08:04 -0700155default_configs = [
156 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400157 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700158 "//gn:no_rtti",
Mike Kleinc7165c22016-10-12 23:58:06 -0400159 "//gn:warnings",
Mike Klein50500ad2016-11-16 12:13:44 -0500160 "//gn:warnings_except_public_headers",
halcanary19a97202016-08-03 15:08:04 -0700161]
Mike Klein09008ff2017-01-21 15:35:10 +0000162if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700163 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700164}
mtklein88a7ac02016-09-14 11:16:49 -0700165if (!is_official_build) {
166 default_configs += [ "//gn:debug_symbols" ]
167}
Mike Klein121563e2016-10-04 17:09:13 -0400168default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700169
170set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400171 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700172}
173
174set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700175 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700176}
177
178set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700179 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700180}
181
182set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700183 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700184}
185
186set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700187 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700188 if (!is_component_build) {
189 complete_static_lib = true
190 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700191}
192
herbb6318bf2016-09-16 13:29:57 -0700193if (is_win) {
194 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400195 set_default_toolchain("//gn/toolchain:msvc")
196 default_toolchain_name = "msvc"
197 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700198} else {
199 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400200 set_default_toolchain("//gn/toolchain:gcc_like")
201 default_toolchain_name = "gcc_like"
202 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700203}