1# Copyright (c) 2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14config("executable_config") { 15 configs = [] 16 17 if (!is_mac) { 18 if (!is_mingw) { 19 cflags = [ "-fPIE" ] 20 asmflags = [ "-fPIE" ] 21 ldflags = [ 22 "-Wl,-rpath=\$ORIGIN/", 23 "-Wl,-rpath-link=", 24 ] 25 if (current_os == "linux") { 26 ldflags += [ "-lpthread" ] 27 } 28 } 29 if (is_ohos) { 30 ldflags += [ "-lpthread" ] 31 configs += [ "$build_root/config/ohos:executable_config" ] 32 } else if (is_android) { 33 configs += [ "$build_root/config/aosp:executable_config" ] 34 } 35 } else if (is_mac) { 36 configs += [ "$build_root/config/mac:mac_dynamic_flags" ] 37 } 38} 39 40# This config defines the configs applied to all shared libraries. 41config("shared_library_config") { 42 configs = [] 43 44 if (is_mac) { 45 configs += [ "$build_root/config/mac:mac_dynamic_flags" ] 46 } 47} 48 49config("default_libs") { 50 if (is_win) { 51 libs = [ 52 "advapi32.lib", 53 "comdlg32.lib", 54 "dbghelp.lib", 55 "dnsapi.lib", 56 "gdi32.lib", 57 "msimg32.lib", 58 "odbc32.lib", 59 "odbccp32.lib", 60 "oleaut32.lib", 61 "psapi.lib", 62 "shell32.lib", 63 "shlwapi.lib", 64 "user32.lib", 65 "usp10.lib", 66 "uuid.lib", 67 "version.lib", 68 "wininet.lib", 69 "winmm.lib", 70 "winspool.lib", 71 "ws2_32.lib", 72 73 # Please don't add more stuff here. We should actually be making this 74 # list smaller, since all common things should be covered. If you need 75 # some extra libraries, please just add a libs = [ "foo.lib" ] to your 76 # target that needs it. 77 ] 78 if (current_os == "winuwp") { 79 # These libraries are needed for Windows UWP (i.e. store apps). 80 libs += [ 81 "dloadhelper.lib", 82 "WindowsApp.lib", 83 ] 84 } else { 85 # These libraries are not compatible with Windows UWP (i.e. store apps.) 86 libs += [ 87 "delayimp.lib", 88 "kernel32.lib", 89 "ole32.lib", 90 ] 91 } 92 } else if (is_ohos || is_android) { 93 libs = [ 94 "dl", 95 "m", 96 ] 97 } else if (is_mac) { 98 # Targets should choose to explicitly link frameworks they require. Since 99 # linking can have run-time side effects, nothing should be listed here. 100 libs = [] 101 } else if (is_linux) { 102 libs = [ 103 "dl", 104 "pthread", 105 "rt", 106 ] 107 } 108} 109 110group("common_deps") { 111 public_deps = [] 112 if (use_musl && is_ohos) { 113 public_deps += [ "$build_root/third_party_gn/musl:soft_shared_libs" ] 114 } 115} 116 117group("executable_deps") { 118 public_deps = [ ":common_deps" ] 119} 120 121group("shared_library_deps") { 122 public_deps = [ ":common_deps" ] 123} 124 125group("static_library_deps") { 126 public_deps = [ ":common_deps" ] 127} 128 129group("source_set_deps") { 130 public_deps = [ ":common_deps" ] 131} 132