-
Notifications
You must be signed in to change notification settings - Fork 1
/
bundles.py
62 lines (46 loc) · 1.88 KB
/
bundles.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
import os
import subprocess
WIN32_PREFIX = 'Win32'
BUNDLE_PREFIX = 'CustomLevels'
FROSTBITE_VER = 'Frostbite2_0'
INTERMEDIATE_FOLDER_NAME = 'intermediate'
EBX_JSON_FOLDER_NAME = 'ebx_json'
SB_OUTPUT_FOLDER_NAME = 'sb'
def generate_bundles(rime_path: str, out_dir: str):
input_path = os.path.join(
os.getcwd(), INTERMEDIATE_FOLDER_NAME, EBX_JSON_FOLDER_NAME)
output_path = os.path.join(out_dir, SB_OUTPUT_FOLDER_NAME)
if not os.path.exists(output_path):
os.makedirs(output_path)
commands = []
super_bundle_names = []
print('Superbundles:')
commands_path = os.path.join(os.getcwd(), INTERMEDIATE_FOLDER_NAME, 'commands.txt')
for mapName in os.listdir(input_path):
# build superbundle
sb_name = WIN32_PREFIX + '/' + BUNDLE_PREFIX + '/' + mapName + '/' + mapName
commands.append('build_sb ' + sb_name + ' ' +
FROSTBITE_VER + ' \"' + output_path + '\"\n')
for file in os.listdir(os.path.join(input_path, mapName)):
file_name = os.path.splitext(file)[0] # Remove extension
file_path = os.path.join(input_path, mapName, file)
if not os.path.isfile(file_path):
continue
# build bundle
bundle_name_w32 = WIN32_PREFIX + '/' + BUNDLE_PREFIX + '/' + mapName + '/' + file_name
commands.append('build_bundle ' + bundle_name_w32 + '\n')
partition_name = BUNDLE_PREFIX + '/' + mapName + '/' + file_name
# add partition to bundle and build bundle
commands.append('add_json_partition ' + partition_name.lower() + ' \"' + file_path + '\"\n')
commands.append('build\n')
# build superbundle
commands.append('build\n\n')
super_bundle_names.append(sb_name)
print(sb_name)
# save commands in commands.txt
with open(commands_path, "w") as f:
f.writelines(commands)
print('Attempting to compile with Rime...')
# execute commands with rime
subprocess.run([os.path.join(rime_path, 'RimeREPL.exe'), commands_path], cwd=rime_path)
return super_bundle_names