@@ -167,9 +167,10 @@ def CopyIcuDepsToBucket(src, dst):
167167 deps_bucket_path = os .path .join (_bucket_directory , dst )
168168 FindFileAndCopyTo ('icudtl.dat' , source_root , deps_bucket_path )
169169
170- def BuildBucket (runtime_mode , arch , product ):
171- out_dir = 'fuchsia_%s_%s/' % (runtime_mode , arch )
172- bucket_dir = 'flutter/%s/%s/' % (arch , runtime_mode )
170+ def BuildBucket (runtime_mode , arch , optimized , product ):
171+ unopt = "_unopt" if not optimized else ""
172+ out_dir = 'fuchsia_%s%s_%s/' % (runtime_mode , unopt , arch )
173+ bucket_dir = 'flutter/%s/%s%s/' % (arch , runtime_mode , unopt )
173174 deps_dir = 'flutter/%s/deps/' % (arch )
174175 CopyToBucket (out_dir , bucket_dir , product )
175176 CopyVulkanDepsToBucket (out_dir , deps_dir , arch )
@@ -244,8 +245,9 @@ def GetRunnerTarget(runner_type, product, aot):
244245 target += 'runner'
245246 return base + target
246247
247- def BuildTarget (runtime_mode , arch , enable_lto , additional_targets = []):
248- out_dir = 'fuchsia_%s_%s' % (runtime_mode , arch )
248+ def BuildTarget (runtime_mode , arch , optimized , enable_lto , asan , additional_targets = []):
249+ unopt = "_unopt" if not optimized else ""
250+ out_dir = 'fuchsia_%s%s_%s' % (runtime_mode , unopt , arch )
249251 flags = [
250252 '--fuchsia' ,
251253 '--fuchsia-cpu' ,
@@ -254,8 +256,13 @@ def BuildTarget(runtime_mode, arch, enable_lto, additional_targets=[]):
254256 runtime_mode ,
255257 ]
256258
259+ if not optimized :
260+ flags .append ('--unoptimized' )
261+
257262 if not enable_lto :
258263 flags .append ('--no-lto' )
264+ if asan :
265+ flags .append ('--asan' )
259266
260267 RunGN (out_dir , flags )
261268 BuildNinjaTargets (out_dir , [ 'flutter' ] + additional_targets )
@@ -277,6 +284,12 @@ def main():
277284 required = False ,
278285 help = 'Specifies the flutter engine SHA.' )
279286
287+ parser .add_argument (
288+ '--unoptimized' ,
289+ action = 'store_true' ,
290+ default = False ,
291+ help = 'If set, disables compiler optimization for the build.' )
292+
280293 parser .add_argument (
281294 '--runtime-mode' ,
282295 type = str ,
@@ -286,6 +299,12 @@ def main():
286299 parser .add_argument (
287300 '--archs' , type = str , choices = ['x64' , 'arm64' , 'all' ], default = 'all' )
288301
302+ parser .add_argument (
303+ '--asan' ,
304+ action = 'store_true' ,
305+ default = False ,
306+ help = 'If set, enables address sanitization (including leak sanitization) for the build.' )
307+
289308 parser .add_argument (
290309 '--no-lto' ,
291310 action = 'store_true' ,
@@ -312,6 +331,7 @@ def main():
312331 runtime_modes = ['debug' , 'profile' , 'release' ]
313332 product_modes = [False , False , True ]
314333
334+ optimized = not args .unoptimized
315335 enable_lto = not args .no_lto
316336
317337 for arch in archs :
@@ -320,8 +340,8 @@ def main():
320340 product = product_modes [i ]
321341 if build_mode == 'all' or runtime_mode == build_mode :
322342 if not args .skip_build :
323- BuildTarget (runtime_mode , arch , enable_lto , args .targets .split ("," ))
324- BuildBucket (runtime_mode , arch , product )
343+ BuildTarget (runtime_mode , arch , optimized , enable_lto , args . asan , args .targets .split ("," ))
344+ BuildBucket (runtime_mode , arch , optimized , product )
325345
326346 if args .upload :
327347 if args .engine_version is None :
0 commit comments