blob: cc2e16e25f2ed94b4432fe417e66c278a2cb8849 [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
Mike Klein5b52c522019-07-03 10:44:21 -050015 # Android 5.0, Lollipop
16 ndk_api = 21
Mike Klein9c1c8922017-11-28 14:31:14 -050017
mtklein2b3c2a32016-09-08 08:39:34 -070018 sanitize = ""
Ethan Nicholas762466e2017-06-29 10:03:38 -040019
20 ar = "ar"
21 cc = "cc"
22 cxx = "c++"
23
Brian Osman852ca312017-12-07 16:16:21 -050024 win_sdk = "C:/Program Files (x86)/Windows Kits/10"
25 win_sdk_version = ""
26
27 win_vc = ""
28 win_toolchain_version = ""
29
Mike Kleinc722f792017-07-31 11:57:21 -040030 clang_win = ""
Ben Wagnerb6f98ea2019-12-21 00:53:11 -050031 clang_win_version = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070032}
mtklein88a7ac02016-09-14 11:16:49 -070033declare_args() {
34 is_debug = !is_official_build
35}
36
37assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070038
Kevin Lubickebf648e2017-09-21 13:45:16 -040039if (target_cpu == "wasm") {
40 target_os = "wasm"
41}
42
mtklein7fbfbbe2016-07-21 12:25:45 -070043# Platform detection
44if (target_os == "") {
45 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070046 if (ndk != "") {
47 target_os = "android"
48 }
mtklein7fbfbbe2016-07-21 12:25:45 -070049}
50if (current_os == "") {
51 current_os = target_os
52}
53
54is_android = current_os == "android"
55is_fuchsia = current_os == "fuchsia"
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040056is_ios = current_os == "ios" || current_os == "tvos"
57is_tvos = current_os == "tvos"
mtklein7fbfbbe2016-07-21 12:25:45 -070058is_linux = current_os == "linux"
59is_mac = current_os == "mac"
60is_win = current_os == "win"
61
Stephen White20c626a2019-10-15 13:35:37 -040062# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux"
63# for ChromeOS, so this variable will not affect Skia proper.
64is_chromeos = false
65
mtklein349cece2016-08-26 08:13:04 -070066if (target_cpu == "") {
67 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040068 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070069 target_cpu = "arm64"
70 }
71}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050072if (target_cpu == "x86_64") {
73 target_cpu = "x64"
74}
mtklein349cece2016-08-26 08:13:04 -070075if (current_cpu == "") {
76 current_cpu = target_cpu
77}
mtklein7fbfbbe2016-07-21 12:25:45 -070078
John Rosasco24cbdab2019-09-25 14:14:35 -070079is_clang = is_android || is_ios || is_mac || is_fuchsia ||
Kevin Lubickebf648e2017-09-21 13:45:16 -040080 (cc == "clang" && cxx == "clang++") || clang_win != ""
Mike Kleinc722f792017-07-31 11:57:21 -040081if (!is_clang && !is_win) {
John Rosasco1edd4682019-11-08 12:22:06 -080082 is_clang = exec_script("//gn/is_clang.py",
Mike Kleinc722f792017-07-31 11:57:21 -040083 [
84 cc,
85 cxx,
86 ],
87 "value")
88}
89
mtklein7d6fb2c2016-08-25 14:50:44 -070090if (is_android) {
91 ndk_host = ""
92 ndk_target = ""
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"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500105 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700106 } else if (target_cpu == "arm") {
Mike Klein5b52c522019-07-03 10:44:21 -0500107 ndk_target = "armv7a-linux-androideabi"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500108 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700109 } else if (target_cpu == "x64") {
110 ndk_target = "x86_64-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500111 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700112 } else if (target_cpu == "x86") {
113 ndk_target = "i686-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500114 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700115 }
116}
117
Brian Osman852ca312017-12-07 16:16:21 -0500118if (target_os == "win") {
Dawson Coleman3c888572019-01-08 17:37:43 -0600119 # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
Brian Osmanc50f8e02018-02-08 10:24:09 -0500120 # non-default location, you can set win_vc to inform us where it is.
Brian Osman852ca312017-12-07 16:16:21 -0500121
122 if (win_vc == "") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400123 win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
Brian Osman852ca312017-12-07 16:16:21 -0500124 }
Mike Kleina01c6b02020-04-01 13:47:34 -0500125 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC
126 # directory.
Brian Osman852ca312017-12-07 16:16:21 -0500127}
128
Mike Klein409506c2017-12-06 16:47:41 -0500129if (target_os == "win") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400130 if (win_toolchain_version == "") {
Mike Klein409506c2017-12-06 16:47:41 -0500131 win_toolchain_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500132 [
133 "$win_vc/Tools/MSVC",
134 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
135 ],
Mike Klein409506c2017-12-06 16:47:41 -0500136 "trim string")
137 }
138 if (win_sdk_version == "") {
139 win_sdk_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500140 [
141 "$win_sdk/Include",
142 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
143 ],
Mike Klein409506c2017-12-06 16:47:41 -0500144 "trim string")
145 }
Ben Wagnerb6f98ea2019-12-21 00:53:11 -0500146 if (clang_win != "" && clang_win_version == "") {
147 clang_win_version = exec_script("//gn/highest_version_dir.py",
148 [
149 "$clang_win/lib/clang",
150 "[0-9]+\.[0-9]+\.[0-9]+",
151 ],
152 "trim string")
153 }
Mike Klein409506c2017-12-06 16:47:41 -0500154}
155
mtklein5db44aa2016-07-29 09:10:31 -0700156# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700157template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700158 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700159 if (is_component_build) {
160 _component_mode = "shared_library"
161 }
162
163 target(_component_mode, target_name) {
164 forward_variables_from(invoker, "*")
165 }
166}
167
168# Default configs
halcanary19a97202016-08-03 15:08:04 -0700169default_configs = [
170 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400171 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700172 "//gn:no_rtti",
173]
Mike Klein09008ff2017-01-21 15:35:10 +0000174if (!is_debug) {
Mike Klein7ea977b2018-09-19 13:44:43 -0400175 default_configs += [
176 "//gn:optimize",
177 "//gn:NDEBUG",
178 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700179}
mtklein88a7ac02016-09-14 11:16:49 -0700180if (!is_official_build) {
Mike Kleind84c1e62018-09-04 10:15:58 -0400181 default_configs += [
182 "//gn:debug_symbols",
183 "//gn:warnings",
184 ]
mtklein88a7ac02016-09-14 11:16:49 -0700185}
Mike Kleind84c1e62018-09-04 10:15:58 -0400186default_configs += [
187 "//gn:warnings_except_public_headers",
188 "//gn:extra_flags",
189]
mtklein7fbfbbe2016-07-21 12:25:45 -0700190
191set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400192 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700193}
194
195set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700196 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700197}
198
199set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700200 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700201}
202
203set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700204 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700205}
206
207set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700208 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700209 if (!is_component_build) {
210 complete_static_lib = true
211 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700212}
213
herbb6318bf2016-09-16 13:29:57 -0700214if (is_win) {
215 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400216 set_default_toolchain("//gn/toolchain:msvc")
217 default_toolchain_name = "msvc"
218 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700219} else {
220 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400221 set_default_toolchain("//gn/toolchain:gcc_like")
222 default_toolchain_name = "gcc_like"
223 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700224}