blob: 10f3244f55f8376d09464b438989b9b3f231da8c [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
25is_android = current_os == "android"
26is_fuchsia = current_os == "fuchsia"
27is_ios = current_os == "ios"
28is_linux = current_os == "linux"
29is_mac = current_os == "mac"
30is_win = current_os == "win"
31
mtklein349cece2016-08-26 08:13:04 -070032if (target_cpu == "") {
33 target_cpu = host_cpu
34 if (is_android) {
35 target_cpu = "arm64"
36 }
37}
38if (current_cpu == "") {
39 current_cpu = target_cpu
40}
mtklein7fbfbbe2016-07-21 12:25:45 -070041
mtklein7d6fb2c2016-08-25 14:50:44 -070042if (is_android) {
43 ndk_host = ""
44 ndk_target = ""
45 ndk_platform = ""
46 ndk_stdlib = ""
mtklein349cece2016-08-26 08:13:04 -070047 nkd_gccdir = ""
mtklein7d6fb2c2016-08-25 14:50:44 -070048
mtklein349cece2016-08-26 08:13:04 -070049 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070050 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070051 } else if (host_os == "mac") {
52 ndk_host = "darwin-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -070053 }
mtklein349cece2016-08-26 08:13:04 -070054
mtklein7d6fb2c2016-08-25 14:50:44 -070055 if (target_cpu == "arm64") {
56 ndk_target = "aarch64-linux-android"
57 ndk_platform = "android-21/arch-arm64"
58 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -070059 ndk_gccdir = ndk_target
60 } else if (target_cpu == "arm") {
61 ndk_target = "arm-linux-androideabi"
62 ndk_platform = "android-18/arch-arm"
63 ndk_stdlib = "armeabi-v7a"
64 ndk_gccdir = ndk_target
65 } else if (target_cpu == "mips64el") {
66 ndk_target = "mips64el-linux-android"
67 ndk_platform = "android-21/arch-mips64"
68 ndk_stdlib = "mips64"
69 ndk_gccdir = ndk_target
70 } else if (target_cpu == "mipsel") {
71 ndk_target = "mipsel-linux-android"
72 ndk_platform = "android-18/arch-mips"
73 ndk_stdlib = "mips"
74 ndk_gccdir = ndk_target
75 } else if (target_cpu == "x64") {
76 ndk_target = "x86_64-linux-android"
77 ndk_platform = "android-21/arch-x86_64"
78 ndk_stdlib = "x86_64"
79 ndk_gccdir = ndk_stdlib
80 } else if (target_cpu == "x86") {
81 ndk_target = "i686-linux-android"
82 ndk_platform = "android-18/arch-x86"
83 ndk_stdlib = "x86"
84 ndk_gccdir = ndk_stdlib
mtklein7d6fb2c2016-08-25 14:50:44 -070085 }
86}
87
mtklein5db44aa2016-07-29 09:10:31 -070088# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -070089template("component") {
mtklein5db44aa2016-07-29 09:10:31 -070090 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -070091 if (is_component_build) {
92 _component_mode = "shared_library"
93 }
94
95 target(_component_mode, target_name) {
96 forward_variables_from(invoker, "*")
97 }
98}
99
100# Default configs
halcanary19a97202016-08-03 15:08:04 -0700101default_configs = [
102 "//gn:default",
103 "//gn:no_rtti",
104]
mtklein7fbfbbe2016-07-21 12:25:45 -0700105if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700106 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700107}
108
109set_defaults("executable") {
halcanary19a97202016-08-03 15:08:04 -0700110 configs = default_configs + [ "//gn:executable" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700111}
112
113set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700114 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700115}
116
117set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700118 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700119}
120
121set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700122 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700123}
124
125set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700126 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700127 if (!is_component_build) {
128 complete_static_lib = true
129 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700130}
131
132# For now, we support GCC-like toolchains, including Clang.
133set_default_toolchain("//gn:gcc_like")