-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
pack.py
75 lines (55 loc) · 1.94 KB
/
pack.py
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
import os
import shutil
import threading
# Define the compile command
compile_cmd = "cargo build -r --features \"{flag}\" --target-dir \"./tmp/{game_name}\""
# Define the targets array
targets = [
["Skyrim Priority AE", "x86_64-pc-windows-msvc", "skyrim_ae", "/Data/SKSE/Plugins"],
["Fallout Priority NG", "x86_64-pc-windows-msvc", "fallout_4", "/Data/F4SE/Plugins"]
]
# Create "./tmp" and "./out" folders
if not os.path.exists("./tmp"):
os.makedirs("./tmp")
if not os.path.exists("./out"):
os.makedirs("./out")
# Define a function to run the compile command
def compile_target(target):
game_name, arch, flag, zip_nested_dir = target
cmd = compile_cmd.format(game_name=game_name, flag=flag)
os.system(cmd)
# Use multiple threads to compile targets in parallel
threads = []
for target in targets:
thread = threading.Thread(target=compile_target, args=(target,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
# Define a function to process target files
def process_target(target):
game_name = target[0]
zip_nested_dir = target[3]
out_dir = f"./out/{game_name}"
tmp_dir = f"./tmp/{game_name}"
# Create the output directory
os.makedirs(f"{out_dir}{zip_nested_dir}", exist_ok=True)
# Copy files
shutil.copy(f"{tmp_dir}/release/FallrimPriority.dll",
f"{out_dir}{zip_nested_dir}/FallrimPriority.dll")
shutil.copy("./FallrimPriority.ini", f"{out_dir}{zip_nested_dir}/FallrimPriority.ini")
# Compress the directory
shutil.make_archive(out_dir, "zip", root_dir=out_dir)
# Remove the directory
shutil.rmtree(out_dir)
# Use multiple threads to process target files in parallel
threads = []
for target in targets:
thread = threading.Thread(target=process_target, args=(target,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
# Delete "./tmp" folder
shutil.rmtree("./tmp")
print("Finished")