• 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  clang_win_version = ""
32
33  ios_min_target = ""
34  ios_use_simulator =
35      target_os == "ios" && (target_cpu == "x86" || target_cpu == "x64")
36
37  # Enable -H, which prints the include tree during compilation.
38  # For use by external tools for analyzing include files.
39  show_includes = false
40}
41declare_args() {
42  is_debug = !is_official_build
43
44  # This affects Skia's ABI; must be set consistently for Skia and dependents.
45  is_trivial_abi = !is_official_build
46}
47
48assert(!(is_debug && is_official_build))
49
50if (target_cpu == "wasm") {
51  target_os = "wasm"
52}
53
54# Platform detection
55if (target_os == "") {
56  target_os = host_os
57  if (ndk != "") {
58    target_os = "android"
59  }
60}
61if (current_os == "") {
62  current_os = target_os
63}
64
65is_android = current_os == "android"
66is_fuchsia = current_os == "fuchsia"
67is_ios = current_os == "ios" || current_os == "tvos"
68is_tvos = current_os == "tvos"
69is_linux = current_os == "linux"
70is_mac = current_os == "mac"
71is_wasm = current_os == "wasm"
72is_win = current_os == "win"
73
74# This is just to make the Dawn build files happy. Skia itself uses target_os = "linux"
75# for ChromeOS, so this variable will not affect Skia proper.
76is_chromeos = false
77
78# This is to make the ANGLE build files happy. Skia always uses is_mac and/or is_ios.
79is_apple = is_mac || is_ios
80
81if (target_cpu == "") {
82  target_cpu = host_cpu
83  if (is_android || is_ios) {
84    target_cpu = "arm64"
85  }
86}
87if (target_cpu == "x86_64") {
88  target_cpu = "x64"
89}
90if (current_cpu == "") {
91  current_cpu = target_cpu
92}
93
94is_clang = is_android || is_ios || is_mac || is_fuchsia || is_wasm ||
95           (cc == "clang" && cxx == "clang++") || clang_win != ""
96if (!is_clang && !is_win) {
97  is_clang = exec_script("//gn/is_clang.py",
98                         [
99                           cc,
100                           cxx,
101                         ],
102                         "value")
103}
104
105if (is_android) {
106  ndk_host = ""
107  ndk_target = ""
108
109  if (host_os == "linux") {
110    ndk_host = "linux-x86_64"
111  } else if (host_os == "mac") {
112    ndk_host = "darwin-x86_64"
113  } else if (host_os == "win") {
114    ndk_host = "windows-x86_64"
115  }
116
117  if (target_cpu == "arm64") {
118    ndk_target = "aarch64-linux-android"
119  } else if (target_cpu == "arm") {
120    ndk_target = "armv7a-linux-androideabi"
121  } else if (target_cpu == "x64") {
122    ndk_target = "x86_64-linux-android"
123  } else if (target_cpu == "x86") {
124    ndk_target = "i686-linux-android"
125  }
126}
127
128if (target_os == "win") {
129  # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a
130  # non-default location, you can set win_vc to inform us where it is.
131
132  if (win_vc == "") {
133    win_vc = exec_script("//gn/find_msvc.py", [], "trim string")
134  }
135  assert(win_vc != "")  # Could not find VC installation. Set win_vc to your VC
136                        # directory.
137}
138
139if (target_os == "win") {
140  if (win_toolchain_version == "") {
141    win_toolchain_version = exec_script("//gn/highest_version_dir.py",
142                                        [
143                                          "$win_vc/Tools/MSVC",
144                                          "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
145                                        ],
146                                        "trim string")
147  }
148  if (win_sdk_version == "") {
149    win_sdk_version = exec_script("//gn/highest_version_dir.py",
150                                  [
151                                    "$win_sdk/Include",
152                                    "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
153                                  ],
154                                  "trim string")
155  }
156  if (clang_win != "" && clang_win_version == "") {
157    clang_win_version = exec_script("//gn/highest_version_dir.py",
158                                    [
159                                      "$clang_win/lib/clang",
160                                      "[0-9]+(\.[0-9]+\.[0-9]+)?",
161                                    ],
162                                    "trim string")
163  }
164}
165
166# A component is either a static or a shared library.
167template("component") {
168  _component_mode = "static_library"
169  if (is_component_build) {
170    _component_mode = "shared_library"
171  }
172
173  target(_component_mode, target_name) {
174    forward_variables_from(invoker, "*")
175  }
176}
177
178# Default configs
179default_configs = [
180  "//gn/skia:default",
181  "//gn/skia:no_exceptions",
182  "//gn/skia:no_rtti",
183]
184if (!is_debug) {
185  default_configs += [
186    "//gn/skia:optimize",
187    "//gn/skia:NDEBUG",
188  ]
189}
190if (is_trivial_abi) {
191  default_configs += [ "//gn/skia:trivial_abi" ]
192}
193if (!is_official_build) {
194  default_configs += [ "//gn/skia:debug_symbols" ]
195}
196default_configs += [ "//gn/skia:extra_flags" ]
197
198set_defaults("executable") {
199  configs = [ "//gn/skia:executable" ] + default_configs
200}
201
202set_defaults("source_set") {
203  configs = default_configs
204}
205
206set_defaults("static_library") {
207  configs = default_configs
208}
209
210set_defaults("shared_library") {
211  configs = default_configs
212}
213
214set_defaults("component") {
215  configs = default_configs
216  if (!is_component_build) {
217    complete_static_lib = true
218  }
219}
220
221skia_target_default_configs = []
222if (!is_official_build) {
223  skia_target_default_configs += [ "//gn/skia:warnings" ]
224}
225
226skia_header_target_default_configs = []
227if (!is_official_build) {
228  skia_header_target_default_configs +=
229      [ "//gn/skia:warnings_for_public_headers" ]
230}
231
232if (is_win) {
233  # Windows tool chain
234  set_default_toolchain("//gn/toolchain:msvc")
235  default_toolchain_name = "msvc"
236  host_toolchain = "msvc_host"
237} else if (is_wasm) {
238  set_default_toolchain("//gn/toolchain:wasm")
239  default_toolchain_name = "wasm"
240  host_toolchain = "wasm"
241} else {
242  # GCC-like toolchains, including Clang.
243  set_default_toolchain("//gn/toolchain:gcc_like")
244  default_toolchain_name = "gcc_like"
245  host_toolchain = "gcc_like_host"
246}
247