forked from OpenAstroTech/OpenAstroTracker-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_script_remove_patched_files.py
More file actions
29 lines (22 loc) · 931 Bytes
/
post_script_remove_patched_files.py
File metadata and controls
29 lines (22 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Import("env", "projenv")
import os
import tempfile
def cprint(*args, **kwargs):
print(f'post_script_remove_patched_files.py:', *args, **kwargs)
def clean_up_patched_files(*_, **__):
"""
Removes all temporary patched files created previously in the build process
"""
# patch_path_key needs to be kept in sync with pre_script_patch_debug.py
patch_path_key = '_patched_'
tempdir_path = tempfile.gettempdir()
cprint(f'Temp file dir is {tempdir_path}')
patched_filepaths = []
for filename in os.listdir(tempdir_path):
full_filepath = os.path.join(tempdir_path, filename)
if os.path.isfile(full_filepath) and patch_path_key in filename:
patched_filepaths.append(full_filepath)
for patched_filepath in patched_filepaths:
cprint(f'Removing {patched_filepath}')
os.remove(patched_filepath)
env.AddPostAction('buildprog', clean_up_patched_files)