blob: 4ed566866e9ea1acedd1e43a151cb143948ac3e0 [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 = ""
Mike Klein4fdc5432016-10-11 11:21:36 -040014 ndk_api = 21
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
Mike Klein7d302882016-11-03 14:06:31 -040043 if (is_android || is_ios) {
mtklein349cece2016-08-26 08:13:04 -070044 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
mtklein349cece2016-08-26 08:13:04 -070058 if (host_os == "linux") {
mtklein7d6fb2c2016-08-25 14:50:44 -070059 ndk_host = "linux-x86_64"
mtklein349cece2016-08-26 08:13:04 -070060 } else if (host_os == "mac") {
61 ndk_host = "darwin-x86_64"
Mike Klein82364ba2016-10-24 16:49:15 -040062 } else if (host_os == "win") {
63 ndk_host = "windows-x86_64"
mtklein7d6fb2c2016-08-25 14:50:44 -070064 }
mtklein349cece2016-08-26 08:13:04 -070065
mtklein7d6fb2c2016-08-25 14:50:44 -070066 if (target_cpu == "arm64") {
67 ndk_target = "aarch64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070068 ndk_platform = "android-${ndk_api}/arch-arm64"
mtklein7d6fb2c2016-08-25 14:50:44 -070069 ndk_stdlib = "arm64-v8a"
mtklein349cece2016-08-26 08:13:04 -070070 ndk_gccdir = ndk_target
71 } else if (target_cpu == "arm") {
72 ndk_target = "arm-linux-androideabi"
mtklein6ef69992016-09-14 06:12:09 -070073 ndk_platform = "android-${ndk_api}/arch-arm"
mtklein349cece2016-08-26 08:13:04 -070074 ndk_stdlib = "armeabi-v7a"
75 ndk_gccdir = ndk_target
76 } else if (target_cpu == "mips64el") {
77 ndk_target = "mips64el-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070078 ndk_platform = "android-${ndk_api}/arch-mips64"
mtklein349cece2016-08-26 08:13:04 -070079 ndk_stdlib = "mips64"
80 ndk_gccdir = ndk_target
81 } else if (target_cpu == "mipsel") {
82 ndk_target = "mipsel-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070083 ndk_platform = "android-${ndk_api}/arch-mips"
mtklein349cece2016-08-26 08:13:04 -070084 ndk_stdlib = "mips"
85 ndk_gccdir = ndk_target
86 } else if (target_cpu == "x64") {
87 ndk_target = "x86_64-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070088 ndk_platform = "android-${ndk_api}/arch-x86_64"
mtklein349cece2016-08-26 08:13:04 -070089 ndk_stdlib = "x86_64"
90 ndk_gccdir = ndk_stdlib
91 } else if (target_cpu == "x86") {
92 ndk_target = "i686-linux-android"
mtklein6ef69992016-09-14 06:12:09 -070093 ndk_platform = "android-${ndk_api}/arch-x86"
mtklein349cece2016-08-26 08:13:04 -070094 ndk_stdlib = "x86"
95 ndk_gccdir = ndk_stdlib
mtklein7d6fb2c2016-08-25 14:50:44 -070096 }
97}
98
mtklein5db44aa2016-07-29 09:10:31 -070099# A component is either a static or a shared library.
mtklein7fbfbbe2016-07-21 12:25:45 -0700100template("component") {
mtklein5db44aa2016-07-29 09:10:31 -0700101 _component_mode = "static_library"
mtklein7fbfbbe2016-07-21 12:25:45 -0700102 if (is_component_build) {
103 _component_mode = "shared_library"
104 }
105
106 target(_component_mode, target_name) {
107 forward_variables_from(invoker, "*")
108 }
109}
110
111# Default configs
halcanary19a97202016-08-03 15:08:04 -0700112default_configs = [
113 "//gn:default",
Mike Klein6e55fef2016-10-26 11:41:47 -0400114 "//gn:no_exceptions",
halcanary19a97202016-08-03 15:08:04 -0700115 "//gn:no_rtti",
Mike Kleinc7165c22016-10-12 23:58:06 -0400116 "//gn:warnings",
halcanary19a97202016-08-03 15:08:04 -0700117]
mtklein7fbfbbe2016-07-21 12:25:45 -0700118if (!is_debug) {
halcanary19a97202016-08-03 15:08:04 -0700119 default_configs += [ "//gn:release" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700120}
mtklein88a7ac02016-09-14 11:16:49 -0700121if (!is_official_build) {
122 default_configs += [ "//gn:debug_symbols" ]
123}
Mike Klein121563e2016-10-04 17:09:13 -0400124default_configs += [ "//gn:extra_flags" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700125
126set_defaults("executable") {
Mike Klein121563e2016-10-04 17:09:13 -0400127 configs = [ "//gn:executable" ] + default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700128}
129
130set_defaults("source_set") {
halcanary19a97202016-08-03 15:08:04 -0700131 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700132}
133
134set_defaults("static_library") {
halcanary19a97202016-08-03 15:08:04 -0700135 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700136}
137
138set_defaults("shared_library") {
halcanary19a97202016-08-03 15:08:04 -0700139 configs = default_configs
mtklein7fbfbbe2016-07-21 12:25:45 -0700140}
141
142set_defaults("component") {
halcanary19a97202016-08-03 15:08:04 -0700143 configs = default_configs
mtklein9b8583d2016-08-24 17:32:30 -0700144 if (!is_component_build) {
145 complete_static_lib = true
146 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700147}
148
herbb6318bf2016-09-16 13:29:57 -0700149if (is_win) {
150 # Windows tool chain
151 set_default_toolchain("//gn:msvc")
152} else {
153 # GCC-like toolchains, including Clang.
154 set_default_toolchain("//gn:gcc_like")
155}