• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
6is_skia_standalone = true
7
8# It's best to keep the names and defaults of is_foo flags consistent with Chrome.
9
10declare_args() {
11  is_official_build = false
12  is_component_build = false
13  ndk = ""
14
15  # Android 5.0, Lollipop
16  ndk_api = 21
17
18  sanitize = ""
19
20  ar = "ar"
21  cc = "cc"
22  cxx = "c++"
23
24  win_sdk = "C:/Program Files (x86)/Windows Kits/10"
25  win_sdk_version = ""
26
27  win_vc = ""
28  win_toolchain_version = ""
29
30  clang_win = ""
31
32  skia_moltenvk_path = ""
33  werror = false
34}
35declare_args() {
36  is_debug = !is_official_build
37}
38
39assert(!(is_debug && is_official_build))
40
41if (target_cpu == "wasm") {
42  target_os = "wasm"
43}
44
45# Platform detection
46if (target_os == "") {
47  target_os = host_os
48  if (ndk != "") {
49    target_os = "android"
50  }
51}
52if (current_os == "") {
53  current_os = target_os
54}
55
56is_android = current_os == "android"
57is_fuchsia = current_os == "fuchsia"
58is_ios = current_os == "ios" || current_os == "tvos"
59is_tvos = current_os == "tvos"
60is_linux = current_os == "linux"
61is_mac = current_os == "mac"
62is_win = current_os == "win"
63
64if (target_cpu == "") {
65  target_cpu = host_cpu
66  if (is_android || is_ios) {
67    target_cpu = "arm64"
68  }
69}
70if (target_cpu == "x86_64") {
71  target_cpu = "x64"
72}
73if (current_cpu == "") {
74  current_cpu = target_cpu
75}
76
77is_clang = is_android || is_ios || is_mac ||
78           (cc == "clang" && cxx == "clang++") || clang_win != ""
79if (!is_clang && !is_win) {
80  is_clang = exec_script("gn/is_clang.py",
81                         [
82                           cc,
83                           cxx,
84                         ],
85                         "value")
86}
87
88if (is_android) {
89  ndk_host = ""
90  ndk_target = ""
91  ndk_gdbserver = ""
92
93  if (host_os == "linux") {
94    ndk_host = "linux-x86_64"
95  } else if (host_os == "mac") {
96    ndk_host = "darwin-x86_64"
97  } else if (host_os == "win") {
98    ndk_host = "windows-x86_64"
99  }
100
101  if (target_cpu == "arm64") {
102    ndk_target = "aarch64-linux-android"
103    ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
104  } else if (target_cpu == "arm") {
105    ndk_target = "armv7a-linux-androideabi"
106    ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
107  } else if (target_cpu == "x64") {
108    ndk_target = "x86_64-linux-android"
109    ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
110  } else if (target_cpu == "x86") {
111    ndk_target = "i686-linux-android"
112    ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
113  }
114}
115
116if (target_os == "win") {
117  # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
118  # non-default location, you can set win_vc to inform us where it is.
119
120  if (win_vc == "") {
121    win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
122  }
123  assert(win_vc != "")  # Could not find VC installation. Set win_vc to your VC directory.
124}
125
126if (target_os == "win") {
127  if (win_toolchain_version == "") {
128    win_toolchain_version = exec_script("//gn/highest_version_dir.py",
129                                        [
130                                          "$win_vc/Tools/MSVC",
131                                          "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
132                                        ],
133                                        "trim string")
134  }
135  if (win_sdk_version == "") {
136    win_sdk_version = exec_script("//gn/highest_version_dir.py",
137                                  [
138                                    "$win_sdk/Include",
139                                    "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
140                                  ],
141                                  "trim string")
142  }
143}
144
145# A component is either a static or a shared library.
146template("component") {
147  _component_mode = "static_library"
148  if (is_component_build) {
149    _component_mode = "shared_library"
150  }
151
152  target(_component_mode, target_name) {
153    forward_variables_from(invoker, "*")
154  }
155}
156
157# Default configs
158default_configs = [
159  "//gn:default",
160  "//gn:no_exceptions",
161  "//gn:no_rtti",
162]
163if (!is_debug) {
164  default_configs += [
165    "//gn:optimize",
166    "//gn:NDEBUG",
167  ]
168}
169if (!is_official_build) {
170  default_configs += [
171    "//gn:debug_symbols",
172    "//gn:warnings",
173  ]
174}
175default_configs += [
176  "//gn:warnings_except_public_headers",
177  "//gn:extra_flags",
178]
179if (sanitize == "MSVC") {
180  default_configs += [ "//gn:msvc_rtc" ]
181}
182
183set_defaults("executable") {
184  configs = [ "//gn:executable" ] + default_configs
185}
186
187set_defaults("source_set") {
188  configs = default_configs
189}
190
191set_defaults("static_library") {
192  configs = default_configs
193}
194
195set_defaults("shared_library") {
196  configs = default_configs
197}
198
199set_defaults("component") {
200  configs = default_configs
201  if (!is_component_build) {
202    complete_static_lib = true
203  }
204}
205
206if (is_win) {
207  # Windows tool chain
208  set_default_toolchain("//gn/toolchain:msvc")
209  default_toolchain_name = "msvc"
210  host_toolchain = "msvc"
211} else {
212  # GCC-like toolchains, including Clang.
213  set_default_toolchain("//gn/toolchain:gcc_like")
214  default_toolchain_name = "gcc_like"
215  host_toolchain = "gcc_like_host"
216}
217