• 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  # It's nice to keep ndk_api set to what Clank targets, but probably no big deal if we can't.
16  if (target_cpu == "x86" || target_cpu == "arm") {
17    ndk_api = 16
18  } else {
19    ndk_api = 21
20  }
21
22  sanitize = ""
23
24  ar = "ar"
25  cc = "cc"
26  cxx = "c++"
27
28  win_sdk = "C:/Program Files (x86)/Windows Kits/10"
29  win_sdk_version = ""
30
31  win_vc = ""
32  win_toolchain_version = ""
33
34  clang_win = ""
35}
36declare_args() {
37  is_debug = !is_official_build
38}
39
40assert(!(is_debug && is_official_build))
41
42if (target_cpu == "wasm") {
43  target_os = "wasm"
44}
45
46# Platform detection
47if (target_os == "") {
48  target_os = host_os
49  if (ndk != "") {
50    target_os = "android"
51  }
52}
53if (current_os == "") {
54  current_os = target_os
55}
56
57is_android = current_os == "android"
58is_fuchsia = current_os == "fuchsia"
59is_ios = current_os == "ios" || current_os == "tvos"
60is_tvos = current_os == "tvos"
61is_linux = current_os == "linux"
62is_mac = current_os == "mac"
63is_win = current_os == "win"
64
65if (target_cpu == "") {
66  target_cpu = host_cpu
67  if (is_android || is_ios) {
68    target_cpu = "arm64"
69  }
70}
71if (target_cpu == "x86_64") {
72  target_cpu = "x64"
73}
74if (current_cpu == "") {
75  current_cpu = target_cpu
76}
77
78is_clang = is_android || is_ios || is_mac ||
79           (cc == "clang" && cxx == "clang++") || clang_win != ""
80if (!is_clang && !is_win) {
81  is_clang = exec_script("gn/is_clang.py",
82                         [
83                           cc,
84                           cxx,
85                         ],
86                         "value")
87}
88
89if (is_android) {
90  ndk_host = ""
91  ndk_target = ""
92  ndk_platform = ""
93  ndk_stdlib = ""
94  ndk_gccdir = ""
95  ndk_gdbserver = ""
96
97  if (host_os == "linux") {
98    ndk_host = "linux-x86_64"
99  } else if (host_os == "mac") {
100    ndk_host = "darwin-x86_64"
101  } else if (host_os == "win") {
102    ndk_host = "windows-x86_64"
103  }
104
105  if (target_cpu == "arm64") {
106    ndk_target = "aarch64-linux-android"
107    ndk_platform = "android-${ndk_api}/arch-arm64"
108    ndk_stdlib = "arm64-v8a"
109    ndk_gccdir = ndk_target
110    ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
111  } else if (target_cpu == "arm") {
112    ndk_target = "arm-linux-androideabi"
113    ndk_platform = "android-${ndk_api}/arch-arm"
114    ndk_stdlib = "armeabi-v7a"
115    ndk_gccdir = ndk_target
116    ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
117  } else if (target_cpu == "x64") {
118    ndk_target = "x86_64-linux-android"
119    ndk_platform = "android-${ndk_api}/arch-x86_64"
120    ndk_stdlib = "x86_64"
121    ndk_gccdir = ndk_stdlib
122    ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
123  } else if (target_cpu == "x86") {
124    ndk_target = "i686-linux-android"
125    ndk_platform = "android-${ndk_api}/arch-x86"
126    ndk_stdlib = "x86"
127    ndk_gccdir = ndk_stdlib
128    ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
129  }
130}
131
132msvc = ""
133if (target_os == "win") {
134  # By default we look for 2017 (Pro & Community), then 2015. If MSVC is installed in a
135  # non-default location, you can set win_vc to inform us where it is.
136  vc_2017_pro_default =
137      "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC"
138  vc_2017_com_default =
139      "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC"
140  vc_2017_bt_default =
141      "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC"
142  vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
143
144  if (win_vc == "") {
145    if ("True" == exec_script("//gn/checkdir.py",
146                              [ "$vc_2017_pro_default" ],
147                              "trim string")) {
148      win_vc = vc_2017_pro_default
149      msvc = 2017
150    } else if ("True" == exec_script("//gn/checkdir.py",
151                                     [ "$vc_2017_com_default" ],
152                                     "trim string")) {
153      win_vc = vc_2017_com_default
154      msvc = 2017
155    } else if ("True" == exec_script("//gn/checkdir.py",
156                                     [ "$vc_2017_bt_default" ],
157                                     "trim string")) {
158      win_vc = vc_2017_bt_default
159      msvc = 2017
160    } else if ("True" == exec_script("//gn/checkdir.py",
161                                     [ "$vc_2015_default" ],
162                                     "trim string")) {
163      win_vc = vc_2015_default
164      msvc = 2015
165    }
166  }
167  assert(win_vc != "")  # Could not find VC installation. Set win_vc to your VC directory.
168
169  if (msvc == "") {
170    if ("True" ==
171        exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) {
172      msvc = 2017
173    } else {
174      msvc = 2015
175    }
176  }
177}
178
179if (target_os == "win") {
180  if (msvc == 2017 && win_toolchain_version == "") {
181    win_toolchain_version = exec_script("//gn/highest_version_dir.py",
182                                        [
183                                          "$win_vc/Tools/MSVC",
184                                          "[0-9]{2}\.[0-9]{2}\.[0-9]{5}",
185                                        ],
186                                        "trim string")
187  }
188  if (win_sdk_version == "") {
189    win_sdk_version = exec_script("//gn/highest_version_dir.py",
190                                  [
191                                    "$win_sdk/Include",
192                                    "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]",
193                                  ],
194                                  "trim string")
195  }
196}
197
198# A component is either a static or a shared library.
199template("component") {
200  _component_mode = "static_library"
201  if (is_component_build) {
202    _component_mode = "shared_library"
203  }
204
205  target(_component_mode, target_name) {
206    forward_variables_from(invoker, "*")
207  }
208}
209
210# Default configs
211default_configs = [
212  "//gn:default",
213  "//gn:no_exceptions",
214  "//gn:no_rtti",
215  "//gn:warnings",
216  "//gn:warnings_except_public_headers",
217]
218if (!is_debug) {
219  default_configs += [ "//gn:release" ]
220}
221if (!is_official_build) {
222  default_configs += [ "//gn:debug_symbols" ]
223}
224default_configs += [ "//gn:extra_flags" ]
225
226set_defaults("executable") {
227  configs = [ "//gn:executable" ] + default_configs
228}
229
230set_defaults("source_set") {
231  configs = default_configs
232}
233
234set_defaults("static_library") {
235  configs = default_configs
236}
237
238set_defaults("shared_library") {
239  configs = default_configs
240}
241
242set_defaults("component") {
243  configs = default_configs
244  if (!is_component_build) {
245    complete_static_lib = true
246  }
247}
248
249if (is_win) {
250  # Windows tool chain
251  set_default_toolchain("//gn/toolchain:msvc")
252  default_toolchain_name = "msvc"
253  host_toolchain = "msvc"
254} else {
255  # GCC-like toolchains, including Clang.
256  set_default_toolchain("//gn/toolchain:gcc_like")
257  default_toolchain_name = "gcc_like"
258  host_toolchain = "gcc_like_host"
259}
260