blob: 2f8670a563624e191845bf72603fa96cf959884f [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
mtklein3e8012e2016-09-21 09:14:19 -07006is_skia_standalone = true
7
mtklein7fbfbbe2016-07-21 12:25:45 -07008# It's best to keep the names and defaults of is_foo flags consistent with Chrome.
9
10declare_args() {
mtklein88a7ac02016-09-14 11:16:49 -070011 is_official_build = false
mtklein7fbfbbe2016-07-21 12:25:45 -070012 is_component_build = false
mtklein7d6fb2c2016-08-25 14:50:44 -070013 ndk = ""
mtklein6ef69992016-09-14 06:12:09 -070014 ndk_api = 0 # 0 == picked automatically for target_cpu.
mtklein2b3c2a32016-09-08 08:39:34 -070015 sanitize = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070016}
mtklein88a7ac02016-09-14 11:16:49 -070017declare_args() {
18 is_debug = !is_official_build
19}
20
21assert(!(is_debug && is_official_build))
mtklein7fbfbbe2016-07-21 12:25:45 -070022
23# Platform detection
24if (target_os == "") {
25 target_os = host_os
mtklein7d6fb2c2016-08-25 14:50:44 -070026 if (ndk != "") {
27 target_os = "android"
28 }
mtklein7fbfbbe2016-07-21 12:25:45 -070029}
30if (current_os == "") {
31 current_os = target_os
32}
33
34is_android = current_os == "android"
35is_fuchsia = current_os == "fuchsia"
36is_ios = current_os == "ios"
37is_linux = current_os == "linux"
38is_mac = current_os == "mac"
39is_win = current_os == "win"
40
mtklein349cece2016-08-26 08:13:04 -070041if (target_cpu == "") {
42 target_cpu = host_cpu
43 if (is_android) {
44 target_cpu = "arm64"
45 }
46}
47if (current_cpu == "") {
48 current_cpu = target_cpu
49}
mtklein7fbfbbe2016-07-21 12:25:45 -070050
mtklein7d6fb2c2016-08-25 14:50:44 -070051if (is_android) {
52 ndk_host = ""
53 ndk_target = ""
54 ndk_platform = ""
55 ndk_stdlib = ""
mtklein6ef69992016-09-14 06:12:09 -070056 ndk_gccdir = ""
57
58 if (ndk_api == 0) {
59 ndk_api = 18
60 if (target_cpu == "arm64" || target_cpu == "mips64el" ||
61 target_cpu == "x64") {
62 ndk_api = 21
63 }
64 }
mtklein7d6fb2c2016-08-25 14:50:44 -070065
mtklein349cece2016-08-26 08:13:04 -070066 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070067 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070068 } else if (host_os == "mac") {
69 ndk_host = "darwin-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -070070 }
mtklein349cece2016-08-26 08:13:04 -070071
mtklein7d6fb2c2016-08-25 14:50:44 -070072 if (target_cpu == "arm64") {
73 ndk_target = "aarch64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070074 ndk_platform = "android-${ndk_api}/arch-arm64"
mtklein7d6fb2c2016-08-25 14:50:44 -070075 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -070076 ndk_gccdir = ndk_target
77 } else if (target_cpu == "arm") {
78 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -070079 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -070080 ndk_stdlib = "armeabi-v7a"
81 ndk_gccdir = ndk_target
82 } else if (target_cpu == "mips64el") {
83 ndk_target = "mips64el-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070084 ndk_platform = "android-${ndk_api}/arch-mips64"
mtklein349cece2016-08-26 08:13:04 -070085 ndk_stdlib = "mips64"
86 ndk_gccdir = ndk_target
87 } else if (target_cpu == "mipsel") {
88 ndk_target = "mipsel-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070089 ndk_platform = "android-${ndk_api}/arch-mips"
mtklein349cece2016-08-26 08:13:04 -070090 ndk_stdlib = "mips"
91 ndk_gccdir = ndk_target
92 } else if (target_cpu == "x64") {
93 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070094 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -070095 ndk_stdlib = "x86_64"
96 ndk_gccdir = ndk_stdlib
97 } else if (target_cpu == "x86") {
98 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070099 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -0700100 ndk_stdlib = "x86"
101 ndk_gccdir = ndk_stdlib
mtklein7d6fb2c2016-08-25 14:50:44 -0700102 }
103}
104
mtklein5db44aa2016-07-29 09:10:31 -0700105# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700106template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700107 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700108 if (is_component_build) {
109 _component_mode = "shared_library"
110 }
111
112 target(_component_mode, target_name) {
113 forward_variables_from(invoker, "*")
114 }
115}
116
117# Default configs
halcanary19a97202016-08-03 15:08:04 -0700118default_configs = [
119 "//gn:default",
120 "//gn:no_rtti",
121]
mtklein7fbfbbe2016-07-21 12:25:45 -0700122if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700123 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700124}
mtklein88a7ac02016-09-14 11:16:49 -0700125if (!is_official_build) {
126 default_configs += [ "//gn:debug_symbols" ]
127}
Mike Klein121563e2016-10-04 17:09:13 -0400128default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700129
130set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400131 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700132}
133
134set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700135 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700136}
137
138set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700139 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700140}
141
142set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700143 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700144}
145
146set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700147 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700148 if (!is_component_build) {
149 complete_static_lib = true
150 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700151}
152
herbb6318bf2016-09-16 13:29:57 -0700153if (is_win) {
154 # Windows tool chain
155 set_default_toolchain("//gn:msvc")
156} else {
157 # GCC-like toolchains, including Clang.
158 set_default_toolchain("//gn:gcc_like")
159}