Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions util/ipgen/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,17 @@ def _refresh_directory(self, staging_dir: Path, output_dir: Path,
f'{output_dir_existing_bak}.')
raise TemplateRenderError(msg).with_traceback(e.__traceback__)

try:
os.rename(staging_dir, output_dir)
except OSError as e:
msg = (f'Cannot move staging directory {staging_dir} to '
f'{output_dir}.')
raise TemplateRenderError(msg).with_traceback(e.__traceback__)
for _ in range(5):
try:
os.rename(staging_dir, output_dir)
break
except PermissionError:
# give time for windows antivirus to run so the directory isn't locked
time.sleep(0.2)
except OSError as e:
msg = (f'Cannot move staging directory {staging_dir} to '
f'{output_dir}.')
raise TemplateRenderError(msg).with_traceback(e.__traceback__)

if do_overwrite:
try:
Expand Down
15 changes: 15 additions & 0 deletions util/topgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1521,13 +1521,28 @@ def main():
default=False,
action="store_true",
help="Only return the list of blocks and exit.")
parser.add_argument("--clear-cache",
default=False,
action="store_true",
help = "Clear any temporary files")

args = parser.parse_args()

# check combinations
if args.top_ral:
args.no_top = True

if args.clear_cache:
for path in Path.cwd().rglob('*'):
if path.name.startswith('.~'):
try:
if path.is_file() or path.is_symlink():
path.unlink()
elif path.is_dir():
shutil.rmtree(path)
except Exception as e:
print(f"Failed to remove {path}: {e}")

if (args.no_top or args.no_xbar or
args.no_plic) and (args.top_only or args.xbar_only or
args.plic_only or args.alert_handler_only):
Expand Down