1# Copyright (C) 2017 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15declare_args() { 16 is_debug = true 17 is_clang = true 18 is_system_compiler = false 19 is_lto = false 20 21 # This is defined here because it's needed below for determining the value of 22 # |is_cross_compiling|. 23 target_triplet = "" 24} 25 26# Platform detection 27if (target_os == "") { 28 target_os = host_os 29} 30if (current_os == "") { 31 current_os = target_os 32} 33 34is_android = current_os == "android" 35is_chromeos = current_os == "chromeos" 36is_linux = current_os == "linux" 37is_linux_host = host_os == "linux" 38is_mac = current_os == "mac" 39is_mac_host = host_os == "mac" 40is_win = current_os == "win" 41is_win_host = host_os == "win" 42 43# Building with Windows/Fuchsia/nacl is currently only supported in the Chromium 44# tree so always set this to false. 45is_fuchsia = false 46is_nacl = false 47 48if (target_cpu == "") { 49 target_cpu = host_cpu 50 if (is_android) { 51 target_cpu = "arm" 52 } 53} 54if (current_cpu == "") { 55 current_cpu = target_cpu 56} 57 58is_cross_compiling = 59 target_cpu != host_cpu || target_os != host_os || target_triplet != "" 60 61default_configs = [ 62 "//gn/standalone:debug_symbols", 63 "//gn/standalone:default", 64 "//gn/standalone:c++11", 65 "//gn/standalone:extra_warnings", 66 "//gn/standalone:no_exceptions", 67 "//gn/standalone:no_rtti", 68 "//gn/standalone:visibility_hidden", 69 "//gn/standalone/libc++:config", 70 "//gn/standalone/sanitizers:sanitizers_cflags", 71] 72 73if (is_win) { 74 default_configs += [ "//gn/standalone:win32_lean_and_mean" ] 75} 76 77if (!is_debug) { 78 default_configs -= [ "//gn/standalone:debug_symbols" ] 79 default_configs += [ "//gn/standalone:release" ] 80} 81 82set_defaults("source_set") { 83 configs = default_configs 84} 85 86set_defaults("static_library") { 87 configs = default_configs 88} 89 90# Realistically the only shared_library that we build right now is libc++.so 91# when use_custom_libcxx=true (on Linux). Hence don't add a dependency on 92# libc++ itself on these targets. 93set_defaults("shared_library") { 94 configs = default_configs 95 configs += [ "//gn/standalone:shared_library" ] 96 97 # note: the following is not a nested config to be removable. 98 configs += [ "//gn/standalone:android_liblog" ] 99} 100 101set_defaults("executable") { 102 configs = default_configs 103 configs += [ "//gn/standalone:executable" ] 104 105 # note: the following is not a nested config to be removable. 106 configs += [ "//gn/standalone:android_liblog" ] 107} 108 109if (is_win) { 110 _default_toolchain = "//gn/standalone/toolchain:msvc" 111} else { 112 _default_toolchain = "//gn/standalone/toolchain:gcc_like" 113} 114set_default_toolchain(_default_toolchain) 115 116if (is_cross_compiling) { 117 host_toolchain = "//gn/standalone/toolchain:gcc_like_host" 118} else { 119 host_toolchain = _default_toolchain 120} 121