blob: 5fb933aa81f3ea136db59d7b4745a9327db270cd [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 = ""
Greg Daniel91dfa3b2018-05-22 13:25:15 -040032
Shachar Langbeheimdb610b32019-06-11 21:26:28 +030033 werror = false
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
mtklein349cece2016-08-26 08:13:04 -070068if (target_cpu == "") {
69 target_cpu = host_cpu
Mike Klein7d302882016-11-03 14:06:31 -040070 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070071 target_cpu = "arm64"
72 }
73}
Mike Kleinb48fd3c2017-01-23 11:58:53 -050074if (target_cpu == "x86_64") {
75 target_cpu = "x64"
76}
mtklein349cece2016-08-26 08:13:04 -070077if (current_cpu == "") {
78 current_cpu = target_cpu
79}
mtklein7fbfbbe2016-07-21 12:25:45 -070080
John Rosasco24cbdab2019-09-25 14:14:35 -070081is_clang = is_android || is_ios || is_mac || is_fuchsia ||
Kevin Lubickebf648e2017-09-21 13:45:16 -040082 (cc == "clang" && cxx == "clang++") || clang_win != ""
Mike Kleinc722f792017-07-31 11:57:21 -040083if (!is_clang && !is_win) {
John Rosasco1edd4682019-11-08 12:22:06 -080084 is_clang = exec_script("//gn/is_clang.py",
Mike Kleinc722f792017-07-31 11:57:21 -040085 [
86 cc,
87 cxx,
88 ],
89 "value")
90}
91
mtklein7d6fb2c2016-08-25 14:50:44 -070092if (is_android) {
93 ndk_host = ""
94 ndk_target = ""
Derek Sollenberger70120c72017-01-05 11:39:04 -050095 ndk_gdbserver = ""
mtklein6ef69992016-09-14 06:12:09 -070096
mtklein349cece2016-08-26 08:13:04 -070097 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070098 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070099 } else if (host_os == "mac") {
100 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -0400101 } else if (host_os == "win") {
102 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -0700103 }
mtklein349cece2016-08-26 08:13:04 -0700104
mtklein7d6fb2c2016-08-25 14:50:44 -0700105 if (target_cpu == "arm64") {
106 ndk_target = "aarch64-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500107 ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700108 } else if (target_cpu == "arm") {
Mike Klein5b52c522019-07-03 10:44:21 -0500109 ndk_target = "armv7a-linux-androideabi"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500110 ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700111 } else if (target_cpu == "x64") {
112 ndk_target = "x86_64-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500113 ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
mtklein349cece2016-08-26 08:13:04 -0700114 } else if (target_cpu == "x86") {
115 ndk_target = "i686-linux-android"
Derek Sollenberger70120c72017-01-05 11:39:04 -0500116 ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
mtklein7d6fb2c2016-08-25 14:50:44 -0700117 }
118}
119
Brian Osman852ca312017-12-07 16:16:21 -0500120if (target_os == "win") {
Dawson Coleman3c888572019-01-08 17:37:43 -0600121 # 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 -0500122 # non-default location, you can set win_vc to inform us where it is.
Brian Osman852ca312017-12-07 16:16:21 -0500123
124 if (win_vc == "") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400125 win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
Brian Osman852ca312017-12-07 16:16:21 -0500126 }
Mike Kleina01c6b02020-04-01 13:47:34 -0500127 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC
128 # directory.
Brian Osman852ca312017-12-07 16:16:21 -0500129}
130
Mike Klein409506c2017-12-06 16:47:41 -0500131if (target_os == "win") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400132 if (win_toolchain_version == "") {
Mike Klein409506c2017-12-06 16:47:41 -0500133 win_toolchain_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500134 [
135 "$win_vc/Tools/MSVC",
136 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
137 ],
Mike Klein409506c2017-12-06 16:47:41 -0500138 "trim string")
139 }
140 if (win_sdk_version == "") {
141 win_sdk_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500142 [
143 "$win_sdk/Include",
144 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
145 ],
Mike Klein409506c2017-12-06 16:47:41 -0500146 "trim string")
147 }
Ben Wagnerb6f98ea2019-12-21 00:53:11 -0500148 if (clang_win != "" && clang_win_version == "") {
149 clang_win_version = exec_script("//gn/highest_version_dir.py",
150 [
151 "$clang_win/lib/clang",
152 "[0-9]+\.[0-9]+\.[0-9]+",
153 ],
154 "trim string")
155 }
Mike Klein409506c2017-12-06 16:47:41 -0500156}
157
mtklein5db44aa2016-07-29 09:10:31 -0700158# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700159template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700160 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700161 if (is_component_build) {
162 _component_mode = "shared_library"
163 }
164
165 target(_component_mode, target_name) {
166 forward_variables_from(invoker, "*")
167 }
168}
169
170# Default configs
halcanary19a97202016-08-03 15:08:04 -0700171default_configs = [
172 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400173 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700174 "//gn:no_rtti",
175]
Mike Klein09008ff2017-01-21 15:35:10 +0000176if (!is_debug) {
Mike Klein7ea977b2018-09-19 13:44:43 -0400177 default_configs += [
178 "//gn:optimize",
179 "//gn:NDEBUG",
180 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700181}
mtklein88a7ac02016-09-14 11:16:49 -0700182if (!is_official_build) {
Mike Kleind84c1e62018-09-04 10:15:58 -0400183 default_configs += [
184 "//gn:debug_symbols",
185 "//gn:warnings",
186 ]
mtklein88a7ac02016-09-14 11:16:49 -0700187}
Mike Kleind84c1e62018-09-04 10:15:58 -0400188default_configs += [
189 "//gn:warnings_except_public_headers",
190 "//gn:extra_flags",
191]
mtklein7fbfbbe2016-07-21 12:25:45 -0700192
193set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400194 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700195}
196
197set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700198 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700199}
200
201set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700202 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700203}
204
205set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700206 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700207}
208
209set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700210 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700211 if (!is_component_build) {
212 complete_static_lib = true
213 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700214}
215
herbb6318bf2016-09-16 13:29:57 -0700216if (is_win) {
217 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400218 set_default_toolchain("//gn/toolchain:msvc")
219 default_toolchain_name = "msvc"
220 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700221} else {
222 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400223 set_default_toolchain("//gn/toolchain:gcc_like")
224 default_toolchain_name = "gcc_like"
225 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700226}