forked from r9r-dev/fs2020-vl3-rotax915
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
54 lines (42 loc) · 2.01 KB
/
build.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
import os
import sys
import json
root_dir = "."
root_ctrl_excl = ["build.py", "layout.json", "manifest.json"]
project_directories = [root_dir, "RTC", "SimObjects"]
manifest_entries = None
content_entries = list()
total_package_size = 0
for project_directory in project_directories:
if (project_directory is root_dir):
for file_name in os.listdir(project_directory):
if not os.path.isdir(file_name) and file_name not in root_ctrl_excl:
file_size = os.path.getsize(file_name)
file_date = 116444736000000000 + int(os.path.getmtime(file_name) * 10000000.0)
content_entry = {"path": file_name, "size": file_size, "date": file_date}
content_entries.append(content_entry)
print("Added file: " + file_name)
else:
for directory_path, directory_names, file_names in os.walk(project_directory):
for file_name in file_names:
file_path = os.path.join(directory_path, file_name)
file_size = os.path.getsize(file_path)
file_date = 116444736000000000 + int(os.path.getmtime(file_path) * 10000000.0)
content_entry = {"path": file_path.replace(os.sep, "/"), "size": file_size, "date": file_date}
content_entries.append(content_entry)
total_package_size += file_size
print("Added file: " + file_path)
layout_entries = {"content": content_entries}
if content_entries:
with open("layout.json", "w") as layout_file:
json.dump(layout_entries, layout_file, indent=2)
else:
print("Error: layout.json not updated", file=sys.stderr)
with open("manifest.json", "r") as manifest_file:
manifest_entries = json.load(manifest_file)
manifest_entries["total_package_size"] = str(total_package_size).zfill(20)
if manifest_entries:
with open("manifest.json", "w") as manifest_file:
json.dump(manifest_entries, manifest_file, indent=2)
else:
print("Error: manifest.json not updated", file=sys.stderr)