Skip to content

Commit d0f5bca

Browse files
committed
chore(build): improved clean-up process
1 parent 1952d0e commit d0f5bca

File tree

2 files changed

+16
-47
lines changed

2 files changed

+16
-47
lines changed

build.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ def __init__(
6767
if parsed_target:
6868
build_type = Path(parsed_target) / build_type
6969

70+
self.tauri_target = self.gui_dir / "src-tauri" / "target" / build_type
7071
self.gui_exe = (
71-
self.gui_dir / "src-tauri" / "target" / build_type / GUI_EXECUTABLE
72+
self.tauri_target / GUI_EXECUTABLE
7273
)
7374
self.src_dir = project_root / "src"
7475
self.build_dir = project_root / ".build" / build_type
@@ -150,11 +151,10 @@ def _clean(self):
150151
self.log.debug(f"Removing {gui_dist}")
151152
shutil.rmtree(gui_dist)
152153

153-
tauri_target = self.gui_dir / "src-tauri" / "target"
154-
if tauri_target.exists():
154+
if self.tauri_target.exists():
155155
response = input("Remove Tauri target? [y/N]: ")
156156
if response.lower() == "y":
157-
shutil.rmtree(tauri_target)
157+
shutil.rmtree(self.tauri_target)
158158

159159
def _build_gui(self) -> int:
160160
if self.skip_gui:
@@ -214,13 +214,23 @@ def _build_gui(self) -> int:
214214

215215
ret = self._run(build_cmd, cwd=self.gui_dir).returncode
216216
if ret == 0:
217-
self.log.info("Copying data files")
217+
self._clean_gui_artifacts()
218218
res = self._clean_data_files()
219219
if res != 0:
220220
return res
221+
self.log.info("Copying data files")
221222
return self._copy_data_files()
222223
else:
223224
return ret
225+
226+
def _clean_gui_artifacts(self):
227+
self.log.info("Cleaning GUI build artifacts")
228+
229+
artifacts = self.tauri_target / "bundle"
230+
if artifacts.exists():
231+
self.log.debug(f"Removing {artifacts}")
232+
shutil.rmtree(artifacts)
233+
224234

225235
def _clean_data_files(self):
226236
try:

poetry.lock

Lines changed: 1 addition & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)