-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathprepare_release.py
86 lines (70 loc) · 3.31 KB
/
prepare_release.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
76
77
78
79
80
81
82
83
84
85
86
import json
import os
import shutil
import sys
if __name__ == "__main__":
if len(sys.argv) != 2:
print('Invalid usage: python {}'.format(' '.join(sys.argv)))
print('Usage: python prepare_release.py <version> (e.g. 4.25)')
sys.exit(1)
target_ue_version = sys.argv[1]
tools_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.join(tools_dir, '..')
staging_dir = os.path.join(root_dir, 'Staging')
if os.path.exists(staging_dir):
print('Cleaning previous staging environment ...')
shutil.rmtree(staging_dir)
if not os.path.exists(staging_dir):
os.makedirs(staging_dir)
plugin_version = None
with open(os.path.join(root_dir, 'ACLPLugin', 'ACLPlugin.uplugin'), 'r') as f:
data = json.load(f)
if not 'VersionName' in data:
print('UE Plugin version not found in ACLPlugin.uplugin')
sys.exit(1)
plugin_version = data['VersionName']
print('Copying plugin content ...')
plugin_src_dir = os.path.join(root_dir, 'ACLPlugin')
plugin_dst_dir = os.path.join(staging_dir, 'ACLPlugin')
shutil.copytree(plugin_src_dir, plugin_dst_dir)
acl_root_dir = os.path.join(plugin_dst_dir, 'Source', 'ThirdParty', 'acl')
rtm_root_dir = os.path.join(acl_root_dir, 'external', 'rtm')
sjsoncpp_root_dir = os.path.join(acl_root_dir, 'external', 'sjson-cpp')
# Copy natvis files in the root
shutil.copyfile(os.path.join(acl_root_dir, 'tools', 'vs_visualizers', 'acl.natvis'), os.path.join(plugin_dst_dir, 'acl.natvis'))
shutil.copyfile(os.path.join(rtm_root_dir, 'tools', 'vs_visualizers', 'rtm.natvis'), os.path.join(plugin_dst_dir, 'rtm.natvis'))
shutil.copyfile(os.path.join(sjsoncpp_root_dir, 'tools', 'vs_visualizers', 'sjson-cpp.natvis'), os.path.join(plugin_dst_dir, 'sjson-cpp.natvis'))
# Remove catch2 and other third party dependencies we do not own or need
print('Removing what we don\'t need ...')
shutil.rmtree(os.path.join(acl_root_dir, 'external', 'catch2'))
shutil.rmtree(os.path.join(rtm_root_dir, 'external', 'catch2'))
shutil.rmtree(os.path.join(sjsoncpp_root_dir, 'external', 'catch2'))
shutil.rmtree(os.path.join(acl_root_dir, 'external', 'benchmark'))
shutil.rmtree(os.path.join(rtm_root_dir, 'external', 'benchmark'))
# Remove extra things not needed for UE development
dirs_to_prune = [ acl_root_dir, rtm_root_dir, sjsoncpp_root_dir ]
to_remove_list = [
'.all-contributorsrc', '.editorconfig', '.git', '.gitignore', '.gitmodules',
'cmake', 'tests', 'test_data', 'tools', 'make.py', 'sonar-project.properties',
'CMakeLists.txt', 'appveyor.yml', '.github', 'docs'
]
for dir_to_prune in dirs_to_prune:
for to_remove in to_remove_list:
path_to_remove = os.path.join(dir_to_prune, to_remove)
if os.path.exists(path_to_remove):
try:
shutil.rmtree(path_to_remove)
except NotADirectoryError:
os.remove(path_to_remove)
print('Setting uplugin version to: {} ...'.format(target_ue_version))
uplugin_file = os.path.join(plugin_dst_dir, 'ACLPlugin.uplugin')
with open(uplugin_file) as f:
uplugin_file_content = f.read()
uplugin_file_content = uplugin_file_content.replace('4.25.0', target_ue_version + '.0')
with open(uplugin_file, 'w') as f:
f.write(uplugin_file_content)
print('Zipping ACLPlugin ...')
zip_filename = os.path.join(root_dir, 'ACLPlugin_v' + plugin_version + '_' + target_ue_version)
shutil.make_archive(zip_filename, 'zip', staging_dir)
print('Done!')
sys.exit(0)