mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 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 | |
| 6 | # It's best to keep the names and defaults of is_foo flags consistent with Chrome. |
| 7 | |
| 8 | declare_args() { |
| 9 | is_debug = true |
| 10 | is_component_build = false |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame^] | 11 | ndk = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | # Platform detection |
| 15 | if (target_os == "") { |
| 16 | target_os = host_os |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame^] | 17 | if (ndk != "") { |
| 18 | target_os = "android" |
| 19 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 20 | } |
| 21 | if (current_os == "") { |
| 22 | current_os = target_os |
| 23 | } |
| 24 | |
mtklein | 422310d | 2016-08-16 18:28:43 -0700 | [diff] [blame] | 25 | if (target_cpu == "") { |
| 26 | target_cpu = host_cpu |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame^] | 27 | if (ndk != "") { |
| 28 | target_cpu = "arm64" |
| 29 | } |
mtklein | 422310d | 2016-08-16 18:28:43 -0700 | [diff] [blame] | 30 | } |
| 31 | if (current_cpu == "") { |
| 32 | current_cpu = target_cpu |
| 33 | } |
| 34 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 35 | is_android = current_os == "android" |
| 36 | is_fuchsia = current_os == "fuchsia" |
| 37 | is_ios = current_os == "ios" |
| 38 | is_linux = current_os == "linux" |
| 39 | is_mac = current_os == "mac" |
| 40 | is_win = current_os == "win" |
| 41 | |
| 42 | is_posix = !is_win |
| 43 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame^] | 44 | if (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 | |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 60 | # A component is either a static or a shared library. |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 61 | template("component") { |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 62 | _component_mode = "static_library" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 63 | 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 |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 73 | default_configs = [ |
| 74 | "//gn:default", |
| 75 | "//gn:no_rtti", |
| 76 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 77 | if (!is_debug) { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 78 | default_configs += [ "//gn:release" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | set_defaults("executable") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 82 | configs = default_configs + [ "//gn:executable" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | set_defaults("source_set") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 86 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | set_defaults("static_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 90 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | set_defaults("shared_library") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 94 | configs = default_configs |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | set_defaults("component") { |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 98 | configs = default_configs |
mtklein | 9b8583d | 2016-08-24 17:32:30 -0700 | [diff] [blame] | 99 | if (!is_component_build) { |
| 100 | complete_static_lib = true |
| 101 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | # For now, we support GCC-like toolchains, including Clang. |
| 105 | set_default_toolchain("//gn:gcc_like") |