Skip to content

Commit

Permalink
…/89\#discussion_r1037771523

refresh.template.py: omit warn_missing_generated and rename _file_exists to _warn_if_file_doesnt_exist
  • Loading branch information
xinzhengzhang committed Dec 4, 2022
1 parent 99430a2 commit eec7394
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def _print_header_finding_warning_once():
Continuing gracefully...""")
_print_header_finding_warning_once.has_logged = False

def _file_exists(source_file, warn_missing_generated = True):
def _warn_if_file_doesnt_exist(source_file):
if not os.path.isfile(source_file):
if not _file_exists.has_logged_missing_file_error and True == warn_missing_generated: # Just log once; subsequent messages wouldn't add anything.
_file_exists.has_logged_missing_file_error = True
if not _warn_if_file_doesnt_exist.has_logged_missing_file_error: # Just log once; subsequent messages wouldn't add anything.
_warn_if_file_doesnt_exist.has_logged_missing_file_error = True
log_warning(f""">>> A source file you compile doesn't (yet) exist: {source_file}
It's probably a generated file, and you haven't yet run a build to generate it.
That's OK; your code doesn't even have to compile for this tool to work.
Expand All @@ -109,7 +109,7 @@ def _file_exists(source_file, warn_missing_generated = True):
Continuing gracefully...""")
return False
return True
_file_exists.has_logged_missing_file_error = False
_warn_if_file_doesnt_exist.has_logged_missing_file_error = False

@functools.lru_cache(maxsize=None)
def _get_bazel_cached_action_keys():
Expand Down Expand Up @@ -594,7 +594,7 @@ def _get_files(compile_action):
assert source_file.endswith(_get_files.source_extensions), f"Source file candidate, {source_file}, seems to be wrong.\nSelected from {compile_action.arguments}.\nPlease file an issue with this information!"

# Warn gently about missing files
if not _file_exists(source_file):
if not _warn_if_file_doesnt_exist(source_file):
return {source_file}, set()

# Note: We need to apply commands to headers and sources.
Expand Down Expand Up @@ -833,7 +833,7 @@ def _get_swift_command_for_files(compile_action):
source_files = set(filter(lambda x: x[-6:] == ".swift", compile_action.arguments))

for source_file in source_files:
_file_exists(source_file)
_warn_if_file_doesnt_exist(source_file)

return source_files, set(), compile_action.arguments

Expand Down

0 comments on commit eec7394

Please sign in to comment.