-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquish.py
More file actions
80 lines (62 loc) · 2.36 KB
/
squish.py
File metadata and controls
80 lines (62 loc) · 2.36 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
Squishes all the required files into a single folder
to upload to the steam workshop or use in-game
"""
import os
import shutil
ROOT: str = os.getcwd()
BUILD_FOLDER: str = os.path.join(ROOT, "Build")
# Add file extensions to this list that should not be included in build
excluded_file_types: set[str] = set([
".exp", # Unnnecesary binaries from exu compilation
".lib"
])
# Add specific files in this list that must be present for the build to succeed
required_items: list[str] = [
"exu.dll"
]
source_paths: list[str] = []
# Helper to add source directories
def add_item_recurse(*path_from_root: str) -> None:
final_path: str = ROOT
for dir in path_from_root:
final_path = os.path.join(final_path, dir)
source_paths.append(final_path)
# Add the target paths for the build, it will search their entire tree
# so you only need to list the top level path
add_item_recurse("Assets")
add_item_recurse("Multiplayer")
add_item_recurse("Presets")
add_item_recurse("Scripts")
add_item_recurse("Singleplayer")
add_item_recurse("External", "ExtraUtilities", "Release")
add_item_recurse("External", "Ordnance Models (ScrapPool)")
add_item_recurse("External", "RequireFix")
add_item_recurse("External", "VTScrapPool", "src")
def squish() -> None:
os.makedirs("Build", exist_ok = True)
for path in source_paths:
for path, _, files in os.walk(path):
for file in files:
_, extension = os.path.splitext(file)
if extension in excluded_file_types:
continue
shutil.copyfile(os.path.join(path, file), os.path.join(BUILD_FOLDER, file))
def verify_files() -> list[str]:
missing_files: list[str] = []
for _, _, files in os.walk(BUILD_FOLDER):
for required_file in required_items:
if required_file not in files:
missing_files.append(required_file)
return missing_files
if __name__ == "__main__":
squish()
missing_files: list[str] = verify_files()
if len(missing_files) == 0:
print("Built release")
else:
print("Failed to build release, missing file(s):")
shutil.rmtree(BUILD_FOLDER)
for missing_file in missing_files:
print(missing_file)
print("\nDid you remember to compile the binaries?")