Skip to content

Commit

Permalink
Clean up gn script goma logic a bit (flutter#40817)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanderso authored Mar 31, 2023
1 parent 0776f38 commit 571baf1
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -208,52 +208,59 @@ def get_target_cpu(args):
return 'x64'


def to_gn_args(args):
if args.simulator:
if args.target_os != 'ios':
raise Exception('--simulator is only supported for iOS')

runtime_mode = args.runtime_mode

gn_args = {}

gn_args['is_debug'] = args.unoptimized
def setup_goma(args):
goma_gn_args = {}

goma_dir = os.environ.get('GOMA_DIR')
goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma')
depot_tools_bin_dir = os.path.join(args.depot_tools, '.cipd_bin')

# GOMA has a different default (home) path on gWindows.
if not os.path.exists(goma_home_dir) and sys.platform.startswith(
('cygwin', 'win')):
goma_home_dir = os.path.join('c:\\', 'src', 'goma', 'goma-win64')

if args.target_os == 'wasm' or args.web:
gn_args['use_goma'] = False
gn_args['goma_dir'] = None
goma_gn_args['use_goma'] = False
goma_gn_args['goma_dir'] = None
print('Disabling GOMA for wasm builds, it is not supported yet.')
elif args.goma and goma_dir:
gn_args['use_goma'] = True
gn_args['goma_dir'] = goma_dir
elif args.goma and goma_dir and os.path.exists(goma_dir):
goma_gn_args['use_goma'] = True
goma_gn_args['goma_dir'] = goma_dir
elif args.goma and os.path.exists(goma_home_dir):
gn_args['use_goma'] = True
gn_args['goma_dir'] = goma_home_dir
elif args.goma and os.path.exists(depot_tools_bin_dir):
gn_args['use_goma'] = True
gn_args['goma_dir'] = depot_tools_bin_dir
goma_gn_args['use_goma'] = True
goma_gn_args['goma_dir'] = goma_home_dir
elif args.goma:
raise Exception(
'GOMA was specified but was not found. Set the GOMA_DIR environment '
'variable, install goma at $HOME/goma following the instructions at '
'https://github.com/flutter/flutter/wiki/Compiling-the-engine, or '
'run this script with the --no-goma flag to do a non-goma-enabled '
'build.',
)
else:
if args.goma:
print(
"GOMA usage was specified but can't be found, falling back to local "
'builds. Set the GOMA_DIR environment variable to fix GOMA.'
)
gn_args['use_goma'] = False
gn_args['goma_dir'] = None
goma_gn_args['use_goma'] = False
goma_gn_args['goma_dir'] = None

if goma_gn_args['use_goma'] and sys.platform == 'darwin':
if (os.environ.get('LUCI_CONTEXT') is None or args.xcode_symlinks or
os.getenv('FLUTTER_GOMA_CREATE_XCODE_SYMLINKS', '0') == '1'):
goma_gn_args['create_xcode_symlinks'] = True

return goma_gn_args


def to_gn_args(args):
if args.simulator:
if args.target_os != 'ios':
raise Exception('--simulator is only supported for iOS')

runtime_mode = args.runtime_mode

gn_args = {}

gn_args['is_debug'] = args.unoptimized

if gn_args['use_goma']:
if args.xcode_symlinks or os.getenv('FLUTTER_GOMA_CREATE_XCODE_SYMLINKS',
'0') == '1':
gn_args['create_xcode_symlinks'] = True
gn_args.update(setup_goma(args))

# If building for WASM, set the GN args using 'to_gn_wasm_args' as most
# of the Flutter SDK specific arguments are unused.
Expand Down

0 comments on commit 571baf1

Please sign in to comment.