blob: 6aa4451e598d6b5714369055df51bf67614b31af [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
6# It's best to keep the names and defaults of is_foo flags consistent with Chrome.
7
8declare_args() {
9 is_debug = true
10 is_component_build = false
mtklein7d6fb2c2016-08-25 14:50:44 -070011 ndk = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070012}
13
14# Platform detection
15if (target_os == "") {
16 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070017 if (ndk != "") {
18 target_os = "android"
19 }
mtklein7fbfbbe2016-07-21 12:25:45 -070020}
21if (current_os == "") {
22 current_os = target_os
23}
24
mtklein422310d2016-08-16 18:28:43 -070025if (target_cpu == "") {
26 target_cpu = host_cpu
mtklein7d6fb2c2016-08-25 14:50:44 -070027 if (ndk != "") {
28 target_cpu = "arm64"
29 }
mtklein422310d2016-08-16 18:28:43 -070030}
31if (current_cpu == "") {
32 current_cpu = target_cpu
33}
34
mtklein7fbfbbe2016-07-21 12:25:45 -070035is_android = current_os == "android"
36is_fuchsia = current_os == "fuchsia"
37is_ios = current_os == "ios"
38is_linux = current_os == "linux"
39is_mac = current_os == "mac"
40is_win = current_os == "win"
41
42is_posix = !is_win
43
mtklein7d6fb2c2016-08-25 14:50:44 -070044if (is_android) {
45 ndk_host = ""
46 ndk_target = ""
47 ndk_platform = ""
48 ndk_stdlib = ""
49
50 if (host_os == "linux" && host_cpu == "x64") {
51 ndk_host = "linux-x86_64"
52 }
53 if (target_cpu == "arm64") {
54 ndk_target = "aarch64-linux-android"
55 ndk_platform = "android-21/arch-arm64"
56 ndk_stdlib = "arm64-v8a"
57 }
58}
59
mtklein5db44aa2016-07-29 09:10:31 -070060# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -070061template("component") {
mtklein5db44aa2016-07-29 09:10:31 -070062 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -070063 if (is_component_build) {
64 _component_mode = "shared_library"
65 }
66
67 target(_component_mode, target_name) {
68 forward_variables_from(invoker, "*")
69 }
70}
71
72# Default configs
halcanary19a97202016-08-03 15:08:04 -070073default_configs = [
74 "//gn:default",
75 "//gn:no_rtti",
76]
mtklein7fbfbbe2016-07-21 12:25:45 -070077if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -070078 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -070079}
80
81set_defaults("executable") {
halcanary19a97202016-08-03 15:08:04 -070082 configs = default_configs + [ "//gn:executable" ]
mtklein7fbfbbe2016-07-21 12:25:45 -070083}
84
85set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -070086 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -070087}
88
89set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -070090 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -070091}
92
93set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -070094 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -070095}
96
97set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -070098 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -070099 if (!is_component_build) {
100 complete_static_lib = true
101 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700102}
103
104# For now, we support GCC-like toolchains, including Clang.
105set_default_toolchain("//gn:gcc_like")