blob: 5f800a67cab15cc60d0556b052e7f284f00343c8 [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 = ""
Jim Van Verth2d366272020-11-18 15:44:04 -050032
33 ios_min_target = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070034}
mtklein88a7ac02016-09-14 11:16:49 -070035declare_args() {
36 is_debug = !is_official_build
37}
38
39assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070040
Kevin Lubickebf648e2017-09-21 13:45:16 -040041if (target_cpu == "wasm") {
42 target_os = "wasm"
43}
44
mtklein7fbfbbe2016-07-21 12:25:45 -070045# Platform detection
46if (target_os == "") {
47 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070048 if (ndk != "") {
49 target_os = "android"
50 }
mtklein7fbfbbe2016-07-21 12:25:45 -070051}
52if (current_os == "") {
53 current_os = target_os
54}
55
56is_android = current_os == "android"
57is_fuchsia = current_os == "fuchsia"
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040058is_ios = current_os == "ios" || current_os == "tvos"
59is_tvos = current_os == "tvos"
mtklein7fbfbbe2016-07-21 12:25:45 -070060is_linux = current_os == "linux"
61is_mac = current_os == "mac"
62is_win = current_os == "win"
63
Stephen White20c626a2019-10-15 13:35:37 -040064# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux"
65# for ChromeOS, so this variable will not affect Skia proper.
66is_chromeos = false
67
Brian Osman56ff5de2021-01-12 12:40:13 -050068# This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios.
69is_apple = is_mac || is_ios
70
mtklein349cece2016-08-26 08:13:04 -070071if (target_cpu == "") {
72 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040073 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070074 target_cpu = "arm64"
75 }
76}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050077if (target_cpu == "x86_64") {
78 target_cpu = "x64"
79}
mtklein349cece2016-08-26 08:13:04 -070080if (current_cpu == "") {
81 current_cpu = target_cpu
82}
mtklein7fbfbbe2016-07-21 12:25:45 -070083
John Rosasco24cbdab2019-09-25 14:14:35 -070084is_clang = is_android || is_ios || is_mac || is_fuchsia ||
Kevin Lubickebf648e2017-09-21 13:45:16 -040085 (cc == "clang" && cxx == "clang++") || clang_win != ""
Mike Kleinc722f792017-07-31 11:57:21 -040086if (!is_clang && !is_win) {
John Rosasco1edd4682019-11-08 12:22:06 -080087 is_clang = exec_script("//gn/is_clang.py",
Mike Kleinc722f792017-07-31 11:57:21 -040088 [
89 cc,
90 cxx,
91 ],
92 "value")
93}
94
mtklein7d6fb2c2016-08-25 14:50:44 -070095if (is_android) {
96 ndk_host = ""
97 ndk_target = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050098 ndk_gdbserver = ""
mtklein6ef69992016-09-14 06:12:09 -070099
mtklein349cece2016-08-26 08:13:04 -0700100 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -0700101 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -0700102 } else if (host_os == "mac") {
103 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -0400104 } else if (host_os == "win") {
105 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700106 }
mtklein349cece2016-08-26 08:13:04 -0700107
mtklein7d6fb2c2016-08-25 14:50:44 -0700108 if (target_cpu == "arm64") {
109 ndk_target = "aarch64-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500110 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700111 } else if (target_cpu == "arm") {
Mike Klein5b52c522019-07-03 10:44:21 -0500112 ndk_target = "armv7a-linux-androideabi"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500113 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700114 } else if (target_cpu == "x64") {
115 ndk_target = "x86_64-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500116 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700117 } else if (target_cpu == "x86") {
118 ndk_target = "i686-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500119 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700120 }
121}
122
Brian Osman852ca312017-12-07 16:16:21 -0500123if (target_os == "win") {
Dawson Coleman3c888572019-01-08 17:37:43 -0600124 # 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 -0500125 # non-default location, you can set win_vc to inform us where it is.
Brian Osman852ca312017-12-07 16:16:21 -0500126
127 if (win_vc == "") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400128 win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
Brian Osman852ca312017-12-07 16:16:21 -0500129 }
Mike Kleina01c6b02020-04-01 13:47:34 -0500130 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC
131 # directory.
Brian Osman852ca312017-12-07 16:16:21 -0500132}
133
Mike Klein409506c2017-12-06 16:47:41 -0500134if (target_os == "win") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400135 if (win_toolchain_version == "") {
Mike Klein409506c2017-12-06 16:47:41 -0500136 win_toolchain_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500137 [
138 "$win_vc/Tools/MSVC",
139 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
140 ],
Mike Klein409506c2017-12-06 16:47:41 -0500141 "trim string")
142 }
143 if (win_sdk_version == "") {
144 win_sdk_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500145 [
146 "$win_sdk/Include",
147 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
148 ],
Mike Klein409506c2017-12-06 16:47:41 -0500149 "trim string")
150 }
Ben Wagnerb6f98ea2019-12-21 00:53:11 -0500151 if (clang_win != "" && clang_win_version == "") {
152 clang_win_version = exec_script("//gn/highest_version_dir.py",
153 [
154 "$clang_win/lib/clang",
155 "[0-9]+\.[0-9]+\.[0-9]+",
156 ],
157 "trim string")
158 }
Mike Klein409506c2017-12-06 16:47:41 -0500159}
160
mtklein5db44aa2016-07-29 09:10:31 -0700161# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700162template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700163 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700164 if (is_component_build) {
165 _component_mode = "shared_library"
166 }
167
168 target(_component_mode, target_name) {
169 forward_variables_from(invoker, "*")
170 }
171}
172
173# Default configs
halcanary19a97202016-08-03 15:08:04 -0700174default_configs = [
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400175 "//gn/skia:default",
176 "//gn/skia:no_exceptions",
177 "//gn/skia:no_rtti",
halcanary19a97202016-08-03 15:08:04 -0700178]
Mike Klein09008ff2017-01-21 15:35:10 +0000179if (!is_debug) {
Mike Klein7ea977b2018-09-19 13:44:43 -0400180 default_configs += [
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400181 "//gn/skia:optimize",
182 "//gn/skia:NDEBUG",
Mike Klein7ea977b2018-09-19 13:44:43 -0400183 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700184}
mtklein88a7ac02016-09-14 11:16:49 -0700185if (!is_official_build) {
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400186 default_configs += [ "//gn/skia:debug_symbols" ]
mtklein88a7ac02016-09-14 11:16:49 -0700187}
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400188default_configs += [ "//gn/skia:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700189
190set_defaults("executable") {
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400191 configs = [ "//gn/skia:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700192}
193
194set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700195 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700196}
197
198set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700199 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700200}
201
202set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700203 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700204}
205
206set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700207 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700208 if (!is_component_build) {
209 complete_static_lib = true
210 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700211}
212
Ben Wagner3d9ab7e2021-03-16 14:29:20 -0400213skia_target_default_configs = []
214if (!is_official_build) {
215 skia_target_default_configs += [ "//gn/skia:warnings" ]
216}
217
218skia_header_target_default_configs = []
219if (!is_official_build) {
220 skia_header_target_default_configs +=
221 [ "//gn/skia:warnings_for_public_headers" ]
222}
223
herbb6318bf2016-09-16 13:29:57 -0700224if (is_win) {
225 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400226 set_default_toolchain("//gn/toolchain:msvc")
227 default_toolchain_name = "msvc"
228 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700229} else {
230 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400231 set_default_toolchain("//gn/toolchain:gcc_like")
232 default_toolchain_name = "gcc_like"
233 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700234}