Skip to content

Commit 5f02d8f

Browse files
committed
Make clear - Windows: remove remaining directories
1 parent 9816a06 commit 5f02d8f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

build-system/luxmake/clear.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"""Clear and clean commands."""
66

77
import shutil
8+
import sys
9+
import subprocess
810

911
from .constants import BINARY_DIR
1012
from .utils import logger
@@ -29,6 +31,16 @@ def clean(
2931
run_cmake(cmd)
3032

3133

34+
def win_rmdir(directory):
35+
"""(Windows only) Remove directory, using DOS command."""
36+
if sys.platform == "win32":
37+
try:
38+
# Use /s /q to remove directory and all subdirectories/files, quietly
39+
subprocess.run(["cmd", "/c", "rmdir", "/s", "/q", directory], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40+
except subprocess.CalledProcessError:
41+
pass # Continue silently if directory does not exist or command fails
42+
43+
3244
def clear(
3345
_,
3446
):
@@ -40,12 +52,15 @@ def clear(
4052
"dependencies",
4153
"install",
4254
):
55+
if not directory:
56+
raise RuntimeError("Invalid binary director")
4357
directory = BINARY_DIR / subdir
4458
logger.info(
4559
"Removing '%s'",
4660
directory,
4761
)
4862
try:
63+
win_rmdir(directory)
4964
shutil.rmtree(
5065
directory,
5166
ignore_errors=True,

0 commit comments

Comments
 (0)