Skip to content

Commit

Permalink
Remove overwrite_args parser argument
Browse files Browse the repository at this point in the history
  • Loading branch information
niranjanyardi committed Nov 15, 2024
1 parent 9b6a247 commit ea63900
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions cobalt/build/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,24 @@ def write_build_args(build_args_path, original_lines, dict_settings,


def main(out_directory: str, platform: str, build_type: str,
overwrite_args: bool, gn_gen_args: List[str]):
gn_gen_args: List[str]):
platform_path = f'cobalt/build/configs/{platform}'
dst_args_gn_file = os.path.join(out_directory, 'args.gn')
src_args_gn_file = os.path.join(platform_path, 'args.gn')
Path(out_directory).mkdir(parents=True, exist_ok=True)

if overwrite_args or not os.path.exists(dst_args_gn_file):
build_args = get_build_args(src_args_gn_file)
build_args = get_build_args(src_args_gn_file)
if not os.path.exists(dst_args_gn_file):
write_build_args(dst_args_gn_file, build_args[0], build_args[1], build_type)
else:
print(f'{dst_args_gn_file} already exists.' +
' Running ninja will regenerate build files automatically.')
# Overwrite args.gn, copy the stale args.gn file to stale_args.gn
stale_dst_args_gn_file = dst_args_gn_file.replace('args', 'stale_args')
os.rename(dst_args_gn_file, stale_dst_args_gn_file)
print(f' Warning: {dst_args_gn_file} is rewritten.' +
' Old file is copied to {stale_dst_args_gn_file}.' +
'In general, if the file exists, you should run' +
' `gn args <out_directory>` to edit it instead.')
write_build_args(dst_args_gn_file, build_args[0], build_args[1], build_type)

gn_command = ['gn', 'gen', out_directory] + gn_gen_args
print(' '.join(gn_command))
Expand Down Expand Up @@ -145,13 +151,6 @@ def main(out_directory: str, platform: str, build_type: str,
default='devel',
choices=_BUILD_TYPES.keys(),
help='The build_type (configuration) to build with.')
parser.add_argument(
'--overwrite_args',
default=False,
action='store_true',
help='Whether or not to overwrite an existing args.gn file if one exists '
'in the out directory. In general, if the file exists, you should run '
'`gn args <out_directory>` to edit it instead.')
parser.add_argument(
'--no-check',
# TODO: b/377295011 - Enable gn --check
Expand All @@ -173,4 +172,4 @@ def main(out_directory: str, platform: str, build_type: str,
builds_out_directory = os.path.join(
BUILDS_DIRECTORY, f'{script_args.platform}_{script_args.build_type}')
main(builds_out_directory, script_args.platform, script_args.build_type,
script_args.overwrite_args, gen_args)
gen_args)

0 comments on commit ea63900

Please sign in to comment.