-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_packages.py
67 lines (55 loc) · 1.99 KB
/
make_packages.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
import os
import glob
import itertools
import shutil
import json
import zipfile
print("Creating packages for Unreal Engine chat")
supported_ue_versions = ["5.0.0", "5.1.0", "5.2.0", "5.3.0", "5.4.0"]
print("Preparing files")
current_dir = os.path.dirname(os.path.realpath(__file__))
temporary_dir = current_dir + "/../Pubnub/"
shutil.copytree(current_dir, temporary_dir)
os.remove(temporary_dir + "/LICENSE")
os.remove(temporary_dir + "/make_packages.py")
os.remove(temporary_dir + "/.gitignore")
os.remove(temporary_dir + "/README.md")
shutil.rmtree(temporary_dir + "/.github", ignore_errors=True)
shutil.rmtree(temporary_dir + "/.git", ignore_errors=True)
shutil.rmtree(temporary_dir + "/readme_content", ignore_errors=True)
cpp_files = itertools.chain(
glob.glob(temporary_dir + "/**/*.cpp", recursive=True),
glob.glob(temporary_dir + "/**/*.hpp", recursive=True),
glob.glob(temporary_dir + "/**/*.c", recursive=True),
glob.glob(temporary_dir + "/**/*.h", recursive=True),
)
for version in supported_ue_versions:
print("Creating package for Unreal Engine " + version)
with open(temporary_dir + "/PubnubChat.uplugin", "r") as uplugin_file:
uplugin = json.load(uplugin_file)
uplugin["EngineVersion"] = version
plugin_version = uplugin["VersionName"]
with open(
temporary_dir + "/PubnubChat.uplugin", "w"
) as uplugin_file_write:
json.dump(uplugin, uplugin_file_write, indent=4)
zipf = zipfile.ZipFile(
temporary_dir
+ "../Pubnub-chat-"
+ plugin_version
+ "-ue"
+ version
+ ".zip",
"w",
zipfile.ZIP_DEFLATED,
)
for root, dirs, inner_files in os.walk(temporary_dir):
for file in inner_files:
zipf.write(
os.path.join(root, file),
os.path.relpath(
os.path.join(root, file), os.path.join(temporary_dir, "..")
),
)
zipf.close()
shutil.rmtree(temporary_dir, ignore_errors=True)