-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy_release.py
More file actions
60 lines (46 loc) · 1.6 KB
/
Copy pathcopy_release.py
File metadata and controls
60 lines (46 loc) · 1.6 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import re
import shutil
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
BUILD_DIR = os.path.join(SCRIPT_DIR, "build", "windows-release")
INSTALLER_DIR = os.path.join(SCRIPT_DIR, "Installer")
EXCLUDE_PREFIXES = ("_", ".", "CMakeFiles")
EXCLUDE_EXTENSIONS = (".exp", ".pdb", ".cmake", ".txt", ".ninja", ".json", ".log", ".deps", ".lib", ".dll.a", ".dmp")
def find_output_dir():
entries = os.listdir(INSTALLER_DIR)
for name in sorted(entries, reverse=True):
if os.path.isdir(os.path.join(INSTALLER_DIR, name)):
return os.path.join(INSTALLER_DIR, name)
raise RuntimeError("No versioned installer folder found in Installer/")
def should_include(name):
if name.startswith(EXCLUDE_PREFIXES):
return False
if os.path.isdir(os.path.join(BUILD_DIR, name)):
return True
_, ext = os.path.splitext(name)
if ext.lower() in EXCLUDE_EXTENSIONS:
return False
return True
def main():
output_base = find_output_dir()
dest_root = os.path.join(output_base, "CodeWizard", "CodeWizard")
entries = os.listdir(BUILD_DIR)
to_copy = [name for name in sorted(entries) if should_include(name)]
print(f"Source: {BUILD_DIR}")
print(f"Dest: {dest_root}")
print(f"Files/folders to copy ({len(to_copy)}):")
for name in to_copy:
print(f" - {name}")
for name in to_copy:
src = os.path.join(BUILD_DIR, name)
dst = os.path.join(dest_root, name)
if os.path.isfile(src):
os.makedirs(os.path.dirname(dst), exist_ok=True)
shutil.copy2(src, dst)
elif os.path.isdir(src):
if os.path.exists(dst):
shutil.rmtree(dst)
shutil.copytree(src, dst)
print("Done.")
if __name__ == "__main__":
main()