Skip to content

Commit a4a8ee8

Browse files
committed
Address gemini-code-assist review on tools/gn
Two style/readability fixes flagged on #187591: 1. Factor out the assignments that are identical in both branches of the `is_host_build(args)` check (`host_cpu`, `target_cpu`, `dart_target_arch`). The if/else now only differs in how it sets `host_os` and `target_os`. Behavior is unchanged -- `get_target_cpu(args)` reads `args.target_os`, not the partially-built `gn_args` dict, so ordering doesn't matter. 2. Wrap the new `--host-cpu` argparse help string to fit the 80-character line limit from the Google Python Style Guide (referenced by Flutter's `.gemini/styleguide.md`). No functional change.
1 parent ad6f0a0 commit a4a8ee8

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • engine/src/flutter/tools

‎engine/src/flutter/tools/gn‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,14 @@ def to_gn_args(args):
520520
gn_args['enable_lto'] = enable_lto
521521

522522
# Set OS, CPU arch for host or target build.
523+
gn_args['host_cpu'] = args.host_cpu or get_host_cpu()
524+
gn_args['target_cpu'] = get_target_cpu(args)
525+
gn_args['dart_target_arch'] = gn_args['target_cpu']
523526
if is_host_build(args):
524527
gn_args['host_os'] = get_host_os()
525-
gn_args['host_cpu'] = args.host_cpu or get_host_cpu()
526528
gn_args['target_os'] = gn_args['host_os']
527-
gn_args['target_cpu'] = get_target_cpu(args)
528-
gn_args['dart_target_arch'] = gn_args['target_cpu']
529529
else:
530-
gn_args['host_cpu'] = args.host_cpu or get_host_cpu()
531530
gn_args['target_os'] = args.target_os
532-
gn_args['target_cpu'] = get_target_cpu(args)
533-
gn_args['dart_target_arch'] = gn_args['target_cpu']
534531

535532
# Cross-compiling host binaries: clang toolchain + build-time Dart SDK must
536533
# match the build machine, not the (overridden) target host_cpu.
@@ -991,7 +988,9 @@ def parse_args(args):
991988

992989
parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm'])
993990
parser.add_argument('--host-cpu', type=str, choices=['x64', 'arm64'],
994-
help='Override the auto-detected host CPU. Use to cross-compile host binaries (e.g., gen_snapshot for linux-arm64 from a linux-x64 builder).')
991+
help='Override the auto-detected host CPU. Use to cross-compile '
992+
'host binaries (e.g., gen_snapshot for linux-arm64 from a '
993+
'linux-x64 builder).')
995994
parser.add_argument('--fuchsia-cpu', type=str, choices=['x64', 'arm64'], default='x64')
996995
parser.add_argument('--windows-cpu', type=str, choices=['x64', 'arm64', 'x86'], default='x64')
997996
parser.add_argument('--simulator-cpu', type=str, choices=['x64', 'arm64'], default='x64')

0 commit comments

Comments
 (0)