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 |
| 11 | } |
| 12 | |
| 13 | # Platform detection |
| 14 | if (target_os == "") { |
| 15 | target_os = host_os |
| 16 | } |
| 17 | if (current_os == "") { |
| 18 | current_os = target_os |
| 19 | } |
| 20 | |
| 21 | is_android = current_os == "android" |
| 22 | is_fuchsia = current_os == "fuchsia" |
| 23 | is_ios = current_os == "ios" |
| 24 | is_linux = current_os == "linux" |
| 25 | is_mac = current_os == "mac" |
| 26 | is_win = current_os == "win" |
| 27 | |
| 28 | is_posix = !is_win |
| 29 | |
| 30 | # A component is either a source_set or a shared_library. |
| 31 | template("component") { |
| 32 | _component_mode = "source_set" |
| 33 | if (is_component_build) { |
| 34 | _component_mode = "shared_library" |
| 35 | } |
| 36 | |
| 37 | target(_component_mode, target_name) { |
| 38 | forward_variables_from(invoker, "*") |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | # Default configs |
| 43 | _default_configs = [ "//gn:default" ] |
| 44 | if (!is_debug) { |
| 45 | _default_configs += [ "//gn:release" ] |
| 46 | } |
| 47 | |
| 48 | set_defaults("executable") { |
| 49 | configs = _default_configs + [ "//gn:executable" ] |
| 50 | } |
| 51 | |
| 52 | set_defaults("source_set") { |
| 53 | configs = _default_configs |
| 54 | } |
| 55 | |
| 56 | set_defaults("static_library") { |
| 57 | configs = _default_configs |
| 58 | } |
| 59 | |
| 60 | set_defaults("shared_library") { |
| 61 | configs = _default_configs |
| 62 | } |
| 63 | |
| 64 | set_defaults("component") { |
| 65 | configs = _default_configs |
| 66 | } |
| 67 | |
| 68 | # For now, we support GCC-like toolchains, including Clang. |
| 69 | set_default_toolchain("//gn:gcc_like") |