OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/sysroot.gni") | 5 import("//build/config/sysroot.gni") |
6 import("//build/config/mac/mac_sdk.gni") | 6 import("//build/config/mac/mac_sdk.gni") |
7 import("//build/config/mac/symbols.gni") | 7 import("//build/config/mac/symbols.gni") |
8 | 8 |
9 if (is_ios) { | |
10 # This needs to be imported after mac_sdk.gni as it overrides some of the | |
11 # variables defined by it. | |
12 import("//build/config/ios/ios_sdk.gni") | |
13 } | |
14 | |
15 # This is included by reference in the //build/config/compiler config that | 9 # This is included by reference in the //build/config/compiler config that |
16 # is applied to all targets. It is here to separate out the logic. | 10 # is applied to all targets. It is here to separate out the logic. |
17 # | |
18 # This is applied to BOTH desktop Mac and iOS targets. | |
19 config("compiler") { | 11 config("compiler") { |
20 # These flags are shared between the C compiler and linker. | 12 # These flags are shared between the C compiler and linker. |
21 common_mac_flags = [] | 13 common_mac_flags = [] |
22 | 14 |
23 # CPU architecture. | 15 # CPU architecture. |
24 if (current_cpu == "x64") { | 16 if (current_cpu == "x64") { |
25 common_mac_flags += [ | 17 common_mac_flags += [ |
26 "-arch", | 18 "-arch", |
27 "x86_64", | 19 "x86_64", |
28 ] | 20 ] |
29 } else if (current_cpu == "x86") { | 21 } else if (current_cpu == "x86") { |
30 common_mac_flags += [ | 22 common_mac_flags += [ |
31 "-arch", | 23 "-arch", |
32 "i386", | 24 "i386", |
33 ] | 25 ] |
34 } else if (current_cpu == "armv7" || current_cpu == "arm") { | |
35 common_mac_flags += [ | |
36 "-arch", | |
37 "armv7", | |
38 ] | |
39 } else if (current_cpu == "arm64") { | |
40 common_mac_flags += [ | |
41 "-arch", | |
42 "arm64", | |
43 ] | |
44 } | 26 } |
45 | 27 |
46 # This is here so that all files get recompiled after an Xcode update. | 28 # This is here so that all files get recompiled after an Xcode update. |
47 # (defines are passed via the command line, and build system rebuild things | 29 # (defines are passed via the command line, and build system rebuild things |
48 # when their commandline changes). Nothing should ever read this define. | 30 # when their commandline changes). Nothing should ever read this define. |
49 defines = [ "CR_XCODE_VERSION=$xcode_version" ] | 31 defines = [ "CR_XCODE_VERSION=$xcode_version" ] |
50 | 32 |
51 asmflags = common_mac_flags | 33 asmflags = common_mac_flags |
52 cflags = common_mac_flags | 34 cflags = common_mac_flags |
53 | 35 |
54 # Without this, the constructors and destructors of a C++ object inside | 36 # Without this, the constructors and destructors of a C++ object inside |
55 # an Objective C struct won't be called, which is very bad. | 37 # an Objective C struct won't be called, which is very bad. |
56 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] | 38 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] |
57 | 39 |
58 cflags_c = [ "-std=c99" ] | 40 cflags_c = [ "-std=c99" ] |
59 cflags_objc = cflags_c | 41 cflags_objc = cflags_c |
60 | 42 |
61 ldflags = common_mac_flags | 43 ldflags = common_mac_flags |
62 | 44 |
63 if (is_ios && additional_toolchains != []) { | 45 if (save_unstripped_output) { |
64 # For fat build, the generation of the dSYM happens after the fat binary has | |
65 # been created with "lipo" thus the stripping cannot happen at link time but | |
66 # after running "lipo" too. | |
67 _save_unstripped_output = false | |
68 } else { | |
69 _save_unstripped_output = save_unstripped_output | |
70 } | |
71 | |
72 if (_save_unstripped_output) { | |
73 ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ] | 46 ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ] |
74 } | 47 } |
75 } | 48 } |
76 | 49 |
77 # This is included by reference in the //build/config/compiler:runtime_library | 50 # This is included by reference in the //build/config/compiler:runtime_library |
78 # config that is applied to all targets. It is here to separate out the logic | 51 # config that is applied to all targets. It is here to separate out the logic |
79 # that is Mac-only. Please see that target for advice on what should go in | 52 # that is Mac-only. Please see that target for advice on what should go in |
80 # :runtime_library vs. :compiler. | 53 # :runtime_library vs. :compiler. |
81 config("runtime_library") { | 54 config("runtime_library") { |
82 common_flags = [ | 55 common_flags = [ |
83 "-isysroot", | 56 "-isysroot", |
84 sysroot, | 57 sysroot, |
85 "-mmacosx-version-min=$mac_deployment_target", | 58 "-mmacosx-version-min=$mac_deployment_target", |
86 ] | 59 ] |
87 | 60 |
88 asmflags = common_flags | 61 asmflags = common_flags |
89 cflags = common_flags | 62 cflags = common_flags |
90 ldflags = common_flags | 63 ldflags = common_flags |
91 | 64 |
92 if (is_mac) { | 65 # Prevent Mac OS X AssertMacros.h (included by system header) from defining |
93 # Prevent Mac OS X AssertMacros.h from defining macros that collide | 66 # macros that collide with common names, like 'check', 'require', and |
94 # with common names, like 'check', 'require', and 'verify'. | 67 # 'verify'. |
95 # (Included by system header. Also exists on iOS but not included.) | 68 # http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMa
cros.h |
96 # http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Assert
Macros.h | 69 defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ] |
97 defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ] | |
98 } | |
99 } | 70 } |
100 | 71 |
101 # On Mac, this is used for everything except static libraries. | 72 # On Mac, this is used for everything except static libraries. |
102 config("mac_dynamic_flags") { | 73 config("mac_dynamic_flags") { |
103 ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and classes. | 74 ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and classes. |
104 | 75 |
105 if (is_component_build) { | 76 if (is_component_build) { |
106 ldflags += [ | 77 ldflags += [ |
107 # Path for loading shared libraries for unbundled binaries. | 78 # Path for loading shared libraries for unbundled binaries. |
108 "-Wl,-rpath,@loader_path/.", | 79 "-Wl,-rpath,@loader_path/.", |
(...skipping 11 matching lines...) Expand all Loading... |
120 ldflags = [ "-Wl,-pie" ] # Position independent. | 91 ldflags = [ "-Wl,-pie" ] # Position independent. |
121 } | 92 } |
122 | 93 |
123 # The ldflags referenced below are handled by | 94 # The ldflags referenced below are handled by |
124 # //build/toolchain/mac/linker_driver.py. | 95 # //build/toolchain/mac/linker_driver.py. |
125 # Remove this config if a target wishes to change the arguments passed to the | 96 # Remove this config if a target wishes to change the arguments passed to the |
126 # strip command during linking. This config by default strips all symbols | 97 # strip command during linking. This config by default strips all symbols |
127 # from a binary, but some targets may wish to specify a saves file to preserve | 98 # from a binary, but some targets may wish to specify a saves file to preserve |
128 # specific symbols. | 99 # specific symbols. |
129 config("strip_all") { | 100 config("strip_all") { |
130 # On iOS, the final applications are assembled using lipo (to support fat | 101 if (enable_stripping) { |
131 # builds). This configuration is thus always empty and the correct flags | |
132 # are passed to the linker_driver.py script directly during the lipo call. | |
133 if (enable_stripping && !is_ios) { | |
134 ldflags = [ "-Wcrl,strip,-x,-S" ] | 102 ldflags = [ "-Wcrl,strip,-x,-S" ] |
135 } | 103 } |
136 } | 104 } |
OLD | NEW |