blob: 6ffe637056d81f7dd7939f1a55539f9a3fdaab39 [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 = ""
Greg Daniel91dfa3b2018-05-22 13:25:15 -040031
Greg Daniel91dfa3b2018-05-22 13:25:15 -040032 skia_moltenvk_path = ""
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 }
127 assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory.
Brian Osman852ca312017-12-07 16:16:21 -0500128}
129
Mike Klein409506c2017-12-06 16:47:41 -0500130if (target_os == "win") {
Hal Canaryf72728e2019-07-10 11:24:52 -0400131 if (win_toolchain_version == "") {
Mike Klein409506c2017-12-06 16:47:41 -0500132 win_toolchain_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500133 [
134 "$win_vc/Tools/MSVC",
135 "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
136 ],
Mike Klein409506c2017-12-06 16:47:41 -0500137 "trim string")
138 }
139 if (win_sdk_version == "") {
140 win_sdk_version = exec_script("//gn/highest_version_dir.py",
Brian Osman5c548922017-12-11 14:59:03 -0500141 [
142 "$win_sdk/Include",
143 "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
144 ],
Mike Klein409506c2017-12-06 16:47:41 -0500145 "trim string")
146 }
147}
148
mtklein5db44aa2016-07-29 09:10:31 -0700149# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700150template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700151 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700152 if (is_component_build) {
153 _component_mode = "shared_library"
154 }
155
156 target(_component_mode, target_name) {
157 forward_variables_from(invoker, "*")
158 }
159}
160
161# Default configs
halcanary19a97202016-08-03 15:08:04 -0700162default_configs = [
163 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400164 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700165 "//gn:no_rtti",
166]
Mike Klein09008ff2017-01-21 15:35:10 +0000167if (!is_debug) {
Mike Klein7ea977b2018-09-19 13:44:43 -0400168 default_configs += [
169 "//gn:optimize",
170 "//gn:NDEBUG",
171 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700172}
mtklein88a7ac02016-09-14 11:16:49 -0700173if (!is_official_build) {
Mike Kleind84c1e62018-09-04 10:15:58 -0400174 default_configs += [
175 "//gn:debug_symbols",
176 "//gn:warnings",
177 ]
mtklein88a7ac02016-09-14 11:16:49 -0700178}
Mike Kleind84c1e62018-09-04 10:15:58 -0400179default_configs += [
180 "//gn:warnings_except_public_headers",
181 "//gn:extra_flags",
182]
mtklein7fbfbbe2016-07-21 12:25:45 -0700183
184set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400185 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700186}
187
188set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700189 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700190}
191
192set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700193 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700194}
195
196set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700197 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700198}
199
200set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700201 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700202 if (!is_component_build) {
203 complete_static_lib = true
204 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700205}
206
herbb6318bf2016-09-16 13:29:57 -0700207if (is_win) {
208 # Windows tool chain
Ethan Nicholas762466e2017-06-29 10:03:38 -0400209 set_default_toolchain("//gn/toolchain:msvc")
210 default_toolchain_name = "msvc"
211 host_toolchain = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700212} else {
213 # GCC-like toolchains, including Clang.
Ethan Nicholas762466e2017-06-29 10:03:38 -0400214 set_default_toolchain("//gn/toolchain:gcc_like")
215 default_toolchain_name = "gcc_like"
216 host_toolchain = "gcc_like_host"
herbb6318bf2016-09-16 13:29:57 -0700217}