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 58declare_args() { 59 # the ossfuzz sanitizer overrides this to true. In that config the 60 # host/target cpu and arch are identical, but we want to build only the 61 # targets with the sanitizer/fuzzer flags 62 is_cross_compiling = 63 target_cpu != host_cpu || target_os != host_os || target_triplet != "" 64} 65default_configs = [ 66 "//gn/standalone:default", 67 "//gn/standalone:extra_warnings", 68 "//gn/standalone:no_exceptions", 69 "//gn/standalone:no_rtti", 70 "//gn/standalone:visibility_hidden", 71 "//gn/standalone/libc++:config", 72 "//gn/standalone/sanitizers:sanitizers_cflags", 73 "//gn/standalone:c++17", 74] 75 76if (is_debug) { 77 default_configs += [ "//gn/standalone:debug_noopt" ] 78} else { 79 default_configs += [ "//gn/standalone:release" ] 80} 81 82if (is_win) { 83 default_configs += [ "//gn/standalone:win32_lean_and_mean" ] 84} 85 86set_defaults("source_set") { 87 configs = default_configs 88} 89 90set_defaults("static_library") { 91 configs = default_configs 92} 93 94# Realistically the only shared_library that we build right now is libc++.so 95# when use_custom_libcxx=true (on Linux). Hence don't add a dependency on 96# libc++ itself on these targets. 97set_defaults("shared_library") { 98 configs = default_configs 99 configs += [ "//gn/standalone:shared_library" ] 100 101 # note: the following is not a nested config to be removable. 102 configs += [ "//gn/standalone:android_liblog" ] 103} 104 105set_defaults("executable") { 106 configs = default_configs 107 configs += [ "//gn/standalone:executable" ] 108 109 # note: the following is not a nested config to be removable. 110 configs += [ "//gn/standalone:android_liblog" ] 111} 112 113if (is_win) { 114 _default_toolchain = "//gn/standalone/toolchain:msvc" 115} else { 116 _default_toolchain = "//gn/standalone/toolchain:gcc_like" 117} 118set_default_toolchain(_default_toolchain) 119 120if (is_cross_compiling) { 121 host_toolchain = "//gn/standalone/toolchain:gcc_like_host" 122} else { 123 host_toolchain = _default_toolchain 124} 125