blob: e5440b9b7666518c5ca4a84a788fa953bcc5bb07 [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 Klein9c1c8922017-11-28 14:31:14 -050014
15 # It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't.
Mike Kleinf32b27d2017-12-05 08:50:20 -050016 if (target_cpu == "x86" || target_cpu == "arm") {
Mike Klein9c1c8922017-11-28 14:31:14 -050017 ndk_api = 16
Mike Kleinb7ce80b2016-12-14 13:17:53 -050018 } else {
19 ndk_api = 21
20 }
Mike Klein9c1c8922017-11-28 14:31:14 -050021
mtklein2b3c2a32016-09-08 08:39:34 -070022 sanitize = ""
Kevin Lubickd0950402018-03-20 10:10:58 -040023 fyi_sanitize = ""
Ethan Nicholas762466e2017-06-29 10:03:38 -040024
25 ar = "ar"
26 cc = "cc"
27 cxx = "c++"
28
Brian Osman852ca312017-12-07 16:16:21 -050029 win_sdk = "C:/Program Files (x86)/Windows Kits/10"
30 win_sdk_version = ""
31
32 win_vc = ""
33 win_toolchain_version = ""
34
Mike Kleinc722f792017-07-31 11:57:21 -040035 clang_win = ""
Greg Daniel91dfa3b2018-05-22 13:25:15 -040036
37 skia_vulkan_sdk = getenv("VULKAN_SDK")
38 skia_moltenvk_path = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070039}
mtklein88a7ac02016-09-14 11:16:49 -070040declare_args() {
41 is_debug = !is_official_build
42}
43
44assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070045
Kevin Lubickebf648e2017-09-21 13:45:16 -040046if (target_cpu == "wasm") {
47 target_os = "wasm"
48}
49
mtklein7fbfbbe2016-07-21 12:25:45 -070050# Platform detection
51if (target_os == "") {
52 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070053 if (ndk != "") {
54 target_os = "android"
55 }
mtklein7fbfbbe2016-07-21 12:25:45 -070056}
57if (current_os == "") {
58 current_os = target_os
59}
60
61is_android = current_os == "android"
62is_fuchsia = current_os == "fuchsia"
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040063is_ios = current_os == "ios" || current_os == "tvos"
64is_tvos = current_os == "tvos"
mtklein7fbfbbe2016-07-21 12:25:45 -070065is_linux = current_os == "linux"
66is_mac = current_os == "mac"
67is_win = current_os == "win"
68
mtklein349cece2016-08-26 08:13:04 -070069if (target_cpu == "") {
70 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040071 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070072 target_cpu = "arm64"
73 }
74}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050075if (target_cpu == "x86_64") {
76 target_cpu = "x64"
77}
mtklein349cece2016-08-26 08:13:04 -070078if (current_cpu == "") {
79 current_cpu = target_cpu
80}
mtklein7fbfbbe2016-07-21 12:25:45 -070081
Kevin Lubickebf648e2017-09-21 13:45:16 -040082is_clang = is_android || is_ios || is_mac ||
83 (cc == "clang" && cxx == "clang++") || clang_win != ""
Mike Kleinc722f792017-07-31 11:57:21 -040084if (!is_clang && !is_win) {
85 is_clang = exec_script("gn/is_clang.py",
86 [
87 cc,
88 cxx,
89 ],
90 "value")
91}
92
mtklein7d6fb2c2016-08-25 14:50:44 -070093if (is_android) {
94 ndk_host = ""
95 ndk_target = ""
96 ndk_platform = ""
97 ndk_stdlib = ""
mtklein6ef69992016-09-14 06:12:09 -070098 ndk_gccdir = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050099 ndk_gdbserver = ""
mtklein6ef69992016-09-14 06:12:09 -0700100
mtklein349cece2016-08-26 08:13:04 -0700101 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -0700102 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700103 } else if (host_os == "mac") {
104 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -0400105 } else if (host_os == "win") {
106 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700107 }
mtklein349cece2016-08-26 08:13:04 -0700108
mtklein7d6fb2c2016-08-25 14:50:44 -0700109 if (target_cpu == "arm64") {
110 ndk_target = "aarch64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700111 ndk_platform = "android-${ndk_api}/arch-arm64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700112 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -0700113 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500114 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700115 } else if (target_cpu == "arm") {
116 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -0700117 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -0700118 ndk_stdlib = "armeabi-v7a"
119 ndk_gccdir = ndk_target
Derek Sollenberger70120c72017-01-05 11:39:04 -0500120 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700121 } else if (target_cpu == "x64") {
122 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700123 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700124 ndk_stdlib = "x86_64"
125 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500126 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700127 } else if (target_cpu == "x86") {
128 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -0700129 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -0700130 ndk_stdlib = "x86"
131 ndk_gccdir = ndk_stdlib
Derek Sollenberger70120c72017-01-05 11:39:04 -0500132 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700133 }
134}
135
Brian Osman852ca312017-12-07 16:16:21 -0500136msvc = ""
137if (target_os == "win") {
Brian Osmanc50f8e02018-02-08 10:24:09 -0500138 # By default we look for 2017 (Pro & Community), then 2015. If MSVC is installed in a
139 # non-default location, you can set win_vc to inform us where it is.
140 vc_2017_pro_default =
Brian Osman852ca312017-12-07 16:16:21 -0500141 "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC"
Brian Osmanc50f8e02018-02-08 10:24:09 -0500142 vc_2017_com_default =
143 "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC"
Hal Canary28728e42018-02-14 11:25:31 -0500144 vc_2017_bt_default =
145 "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC"
Brian Osman852ca312017-12-07 16:16:21 -0500146 vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
147
148 if (win_vc == "") {
Brian Osmanc50f8e02018-02-08 10:24:09 -0500149 if ("True" == exec_script("//gn/checkdir.py",
150 [ "$vc_2017_pro_default" ],
151 "trim string")) {
152 win_vc = vc_2017_pro_default
153 msvc = 2017
154 } else if ("True" == exec_script("//gn/checkdir.py",
155 [ "$vc_2017_com_default" ],
156 "trim string")) {
157 win_vc = vc_2017_com_default
Brian Osman852ca312017-12-07 16:16:21 -0500158 msvc = 2017
159 } else if ("True" == exec_script("//gn/checkdir.py",
Hal Canary28728e42018-02-14 11:25:31 -0500160 [ "$vc_2017_bt_default" ],
161 "trim string")) {
162 win_vc = vc_2017_bt_default
163 msvc = 2017
164 } else if ("True" == exec_script("//gn/checkdir.py",
Brian Osman852ca312017-12-07 16:16:21 -0500165 [ "$vc_2015_default" ],
166 "trim string")) {
167 win_vc = vc_2015_default
168 msvc = 2015
169 }
170 }
171 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory.
172
173 if (msvc == "") {
174 if ("True" ==
175 exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) {
176 msvc = 2017
177 } else {
178 msvc = 2015
179 }
180 }
181}
182
Mike Klein409506c2017-12-06 16:47:41 -0500183if (target_os == "win") {
184 if (msvc == 2017 && win_toolchain_version == "") {
185 win_toolchain_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500186 [
187 "$win_vc/Tools/MSVC",
188 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
189 ],
Mike Klein409506c2017-12-06 16:47:41 -0500190 "trim string")
191 }
192 if (win_sdk_version == "") {
193 win_sdk_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500194 [
195 "$win_sdk/Include",
196 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
197 ],
Mike Klein409506c2017-12-06 16:47:41 -0500198 "trim string")
199 }
200}
201
mtklein5db44aa2016-07-29 09:10:31 -0700202# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700203template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700204 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700205 if (is_component_build) {
206 _component_mode = "shared_library"
207 }
208
209 target(_component_mode, target_name) {
210 forward_variables_from(invoker, "*")
211 }
212}
213
214# Default configs
halcanary19a97202016-08-03 15:08:04 -0700215default_configs = [
216 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400217 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700218 "//gn:no_rtti",
Mike Kleinc7165c22016-10-12 23:58:06 -0400219 "//gn:warnings",
Mike Klein50500ad2016-11-16 12:13:44 -0500220 "//gn:warnings_except_public_headers",
halcanary19a97202016-08-03 15:08:04 -0700221]
Mike Klein09008ff2017-01-21 15:35:10 +0000222if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700223 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700224}
mtklein88a7ac02016-09-14 11:16:49 -0700225if (!is_official_build) {
226 default_configs += [ "//gn:debug_symbols" ]
227}
Mike Klein121563e2016-10-04 17:09:13 -0400228default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700229
230set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400231 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700232}
233
234set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700235 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700236}
237
238set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700239 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700240}
241
242set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700243 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700244}
245
246set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700247 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700248 if (!is_component_build) {
249 complete_static_lib = true
250 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700251}
252
herbb6318bf2016-09-16 13:29:57 -0700253if (is_win) {
254 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400255 set_default_toolchain("//gn/toolchain:msvc")
256 default_toolchain_name = "msvc"
257 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700258} else {
259 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400260 set_default_toolchain("//gn/toolchain:gcc_like")
261 default_toolchain_name = "gcc_like"
262 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700263}