1# Copyright 2019 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/ios/deployment_target.gni") 6 7config("compiler") { 8 configs = [ 9 ":include_dirs", 10 ":cpp_standard", 11 ":objc_use_arc", 12 ":objc_abi_version", 13 ] 14 cflags = [ "-g" ] 15 swiftflags = [ "-g" ] 16} 17 18config("shared_binary") { 19 if (current_os == "ios" || current_os == "mac") { 20 configs = [ 21 ":rpath_config", 22 ":swift_libdir", 23 ] 24 } 25} 26 27config("objc_abi_version") { 28 cflags_objc = [ "-fobjc-abi-version=2" ] 29 cflags_objcc = cflags_objc 30 ldflags = [ 31 "-Xlinker", 32 "-objc_abi_version", 33 "-Xlinker", 34 "2", 35 ] 36} 37 38config("include_dirs") { 39 include_dirs = [ 40 "//", 41 root_gen_dir, 42 ] 43} 44 45config("objc_use_arc") { 46 cflags_objc = [ 47 "-fobjc-arc", 48 "-fobjc-weak", 49 ] 50 cflags_objcc = cflags_objc 51} 52 53config("cpp_standard") { 54 cflags_c = [ "--std=c11" ] 55 cflags_cc = [ 56 "--std=c++17", 57 "--stdlib=libc++", 58 ] 59 ldflags = [ "--stdlib=libc++" ] 60} 61 62if (current_os == "ios" || current_os == "mac") { 63 config("rpath_config") { 64 ldflags = [ 65 "-Xlinker", 66 "-rpath", 67 "-Xlinker", 68 "@executable_path/Frameworks", 69 "-Xlinker", 70 "-rpath", 71 "-Xlinker", 72 "@loader_path/Frameworks", 73 ] 74 } 75 76 _sdk_info = exec_script("//build/config/ios/scripts/sdk_info.py", 77 [ 78 "--target-cpu", 79 current_cpu, 80 "--target-environment", 81 target_environment, 82 "--deployment-target", 83 ios_deployment_target, 84 ], 85 "json") 86 87 _lib_swift_dir = "${_sdk_info.toolchain_path}/usr/lib/swift" 88 if (current_os == "ios") { 89 if (_sdk_info.is_simulator) { 90 _system_lib_swift_dir = "$_lib_swift_dir/iphonesimulator" 91 } else { 92 _system_lib_swift_dir = "$_lib_swift_dir/iphoneos" 93 } 94 } else { 95 _system_lib_swift_dir = "$_lib_swift_dir/macosx" 96 } 97 98 config("swift_libdir") { 99 lib_dirs = [ 100 "${_sdk_info.sdk_path}/usr/lib/swift", 101 _system_lib_swift_dir, 102 ] 103 } 104} 105