Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: tools/gn.py

Issue 2871683002: [infra] Cleanup buildfile generation scripts a bit (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/generate_buildfiles.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Dart project authors. All rights reserved. 2 # Copyright 2016 The Dart project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import multiprocessing 7 import multiprocessing
8 import os 8 import os
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 # Where string_map is formatted as X1=Y1,X2=Y2 etc. 104 # Where string_map is formatted as X1=Y1,X2=Y2 etc.
105 # If key is X1, returns Y1. 105 # If key is X1, returns Y1.
106 def ParseStringMap(key, string_map): 106 def ParseStringMap(key, string_map):
107 for m in string_map.split(','): 107 for m in string_map.split(','):
108 l = m.split('=') 108 l = m.split('=')
109 if l[0] == key: 109 if l[0] == key:
110 return l[1] 110 return l[1]
111 return None 111 return None
112 112
113 113
114 def UseSanitizer(args):
115 return args.asan or args.msan or args.tsan
116
117
118 def DontUseClang(args, target_os, host_cpu, target_cpu):
119 # We don't have clang on Windows.
120 return (target_os == 'win'
121 # TODO(zra): Experiment with using clang for the arm cross-builds.
122 or (target_os == 'linux'
123 and (target_cpu.startswith('arm') or
124 target_cpu.startswith('mips'))
125 # TODO(zra): Only use clang when a sanitizer build is specified until
126 # clang bugs in inline assembly for ia32 are fixed.
rmacnak 2017/05/08 18:04:53 Consider: inline assembly -> tcmalloc's inline ass
zra 2017/05/08 18:37:10 Done.
127 or (target_os == 'linux')
128 and host_cpu == 'x86'
129 and not UseSanitizer(args)))
130
131
114 def ToGnArgs(args, mode, arch, target_os): 132 def ToGnArgs(args, mode, arch, target_os):
115 gn_args = {} 133 gn_args = {}
116 134
117 host_os = HostOsForGn(HOST_OS) 135 host_os = HostOsForGn(HOST_OS)
118 if target_os == 'host': 136 if target_os == 'host':
119 gn_args['target_os'] = host_os 137 gn_args['target_os'] = host_os
120 else: 138 else:
121 gn_args['target_os'] = target_os 139 gn_args['target_os'] = target_os
122 140
123 gn_args['dart_target_arch'] = arch 141 gn_args['dart_target_arch'] = arch
124 gn_args['target_cpu'] = TargetCpuForArch(arch, target_os) 142 gn_args['target_cpu'] = TargetCpuForArch(arch, target_os)
125 gn_args['host_cpu'] = HostCpuForArch(arch) 143 gn_args['host_cpu'] = HostCpuForArch(arch)
126 144
127 # See: runtime/observatory/BUILD.gn. 145 # See: runtime/observatory/BUILD.gn.
128 # This allows the standalone build of the observatory to fall back on 146 # This allows the standalone build of the observatory to fall back on
129 # dart_bootstrap if the prebuilt SDK doesn't work. 147 # dart_bootstrap if the prebuilt SDK doesn't work.
130 gn_args['dart_host_pub_exe'] = "" 148 gn_args['dart_host_pub_exe'] = ""
131 149
132 # We only want the fallback root certs in the standalone VM on 150 # We only want the fallback root certs in the standalone VM on
133 # Linux and Windows. 151 # Linux and Windows.
134 if gn_args['target_os'] in ['linux', 'win']: 152 if gn_args['target_os'] in ['linux', 'win']:
135 gn_args['dart_use_fallback_root_certificates'] = True 153 gn_args['dart_use_fallback_root_certificates'] = True
136 154
137 gn_args['dart_zlib_path'] = "//runtime/bin/zlib" 155 gn_args['dart_zlib_path'] = "//runtime/bin/zlib"
138 156
139 # Use tcmalloc only when targeting Linux and when not using ASAN. 157 # Use tcmalloc only when targeting Linux and when not using ASAN.
140 gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux') 158 gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux')
141 and not args.asan 159 and not UseSanitizer(args))
142 and not args.msan
143 and not args.tsan)
144 160
145 if gn_args['target_os'] == 'linux': 161 if gn_args['target_os'] == 'linux':
146 if gn_args['target_cpu'] == 'arm': 162 if gn_args['target_cpu'] == 'arm':
147 # Force -mfloat-abi=hard and -mfpu=neon for arm on Linux as we're 163 # Force -mfloat-abi=hard and -mfpu=neon for arm on Linux as we're
148 # specifying a gnueabihf compiler in //build/toolchain/linux BUILD.gn. 164 # specifying a gnueabihf compiler in //build/toolchain/linux BUILD.gn.
149 gn_args['arm_arch'] = 'armv7' 165 gn_args['arm_arch'] = 'armv7'
150 gn_args['arm_float_abi'] = 'hard' 166 gn_args['arm_float_abi'] = 'hard'
151 gn_args['arm_use_neon'] = True 167 gn_args['arm_use_neon'] = True
152 elif gn_args['target_cpu'] == 'armv6': 168 elif gn_args['target_cpu'] == 'armv6':
153 raise Exception("GN support for armv6 unimplemented") 169 raise Exception("GN support for armv6 unimplemented")
154 elif gn_args['target_cpu'] == 'armv5te': 170 elif gn_args['target_cpu'] == 'armv5te':
155 raise Exception("GN support for armv5te unimplemented") 171 raise Exception("GN support for armv5te unimplemented")
156 172
157 gn_args['is_debug'] = mode == 'debug' 173 gn_args['is_debug'] = mode == 'debug'
158 gn_args['is_release'] = mode == 'release' 174 gn_args['is_release'] = mode == 'release'
159 gn_args['is_product'] = mode == 'product' 175 gn_args['is_product'] = mode == 'product'
160 gn_args['dart_debug'] = mode == 'debug' 176 gn_args['dart_debug'] = mode == 'debug'
161 177
162 # This setting is only meaningful for Flutter. Standalone builds of the VM 178 # This setting is only meaningful for Flutter. Standalone builds of the VM
163 # should leave this set to 'develop', which causes the build to defer to 179 # should leave this set to 'develop', which causes the build to defer to
164 # 'is_debug', 'is_release' and 'is_product'. 180 # 'is_debug', 'is_release' and 'is_product'.
165 gn_args['dart_runtime_mode'] = 'develop' 181 gn_args['dart_runtime_mode'] = 'develop'
166 182
167 # TODO(zra): Investigate using clang with these configurations. 183 dont_use_clang = DontUseClang(args, gn_args['target_os'],
168 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we 184 gn_args['host_cpu'],
169 # don't use clang in that configuration. Thus, we use gcc for ia32 *unless* 185 gn_args['target_cpu'])
170 # a clang-based sanitizer is specified. 186 gn_args['is_clang'] = args.clang and not dont_use_clang
171 has_clang = (host_os != 'win'
172 and not gn_args['target_cpu'].startswith('mips')
173 and not ((gn_args['target_os'] == 'linux') and
174 (gn_args['target_cpu'] == 'arm64'))
175 and not ((gn_args['target_os'] == 'linux')
176 and (gn_args['host_cpu'] == 'x86')
177 and not args.asan
178 and not args.msan
179 and not args.tsan)) # Use clang for sanitizer builds.
180 gn_args['is_clang'] = args.clang and has_clang
181 187
182 gn_args['is_asan'] = args.asan and gn_args['is_clang'] 188 gn_args['is_asan'] = args.asan and gn_args['is_clang']
183 gn_args['is_msan'] = args.msan and gn_args['is_clang'] 189 gn_args['is_msan'] = args.msan and gn_args['is_clang']
184 gn_args['is_tsan'] = args.tsan and gn_args['is_clang'] 190 gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
185 191
186 # Setup the user-defined sysroot. 192 # Setup the user-defined sysroot.
187 if gn_args['target_os'] == 'linux' and args.wheezy: 193 if gn_args['target_os'] == 'linux' and args.wheezy:
188 gn_args['dart_use_wheezy_sysroot'] = True 194 gn_args['dart_use_wheezy_sysroot'] = True
189 else: 195 else:
190 sysroot = TargetSysroot(args) 196 sysroot = TargetSysroot(args)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return 1 433 return 1
428 434
429 endtime = time.time() 435 endtime = time.time()
430 if args.verbose: 436 if args.verbose:
431 print ("GN Time: %.3f seconds" % (endtime - starttime)) 437 print ("GN Time: %.3f seconds" % (endtime - starttime))
432 return 0 438 return 0
433 439
434 440
435 if __name__ == '__main__': 441 if __name__ == '__main__':
436 sys.exit(Main(sys.argv)) 442 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « tools/generate_buildfiles.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698