Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove overwrite_args parser argument #4439

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions cobalt/build/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,22 @@ 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)
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.')

if os.path.exists(dst_args_gn_file):
# Copy the stale args.gn into stale_args.gn
stale_dst_args_gn_file = dst_args_gn_file.replace('args', 'stale_args')
niranjanyardi marked this conversation as resolved.
Show resolved Hide resolved
os.rename(dst_args_gn_file, stale_dst_args_gn_file)
print(f' Warning: {dst_args_gn_file} is rewritten.'
f' 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.')
build_args = get_build_args(src_args_gn_file)
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))
subprocess.check_call(gn_command)
Expand Down Expand Up @@ -145,13 +148,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 +169,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)
andrewsavage1 marked this conversation as resolved.
Show resolved Hide resolved
Loading