|
2 | 2 | import subprocess |
3 | 3 | import sys |
4 | 4 | import time |
| 5 | +import shutil |
| 6 | +import zipfile |
5 | 7 |
|
6 | 8 | UE_VERSIONS = ['4.15', '4.16', '4.17'] |
7 | 9 | PYTHON_VERSIONS = ["C:/Program Files/Python36", "C:/Program Files/Python35", "C:/Python27"] |
8 | 10 |
|
9 | | -def msbuild(project, python_version): |
| 11 | +RELEASE_DIR = sys.argv[1].rstrip('/') |
| 12 | + |
| 13 | +def zipdir(path, zh): |
| 14 | + for root, dirs, files in os.walk(path): |
| 15 | + for file in files: |
| 16 | + zh.write(os.path.join(root, file)) |
| 17 | + |
| 18 | +def msbuild(project, python_version, variant): |
10 | 19 | base_environ = os.environ |
11 | 20 | base_environ.update({'PYTHONHOME': python_version}) |
| 21 | + if variant == 'threaded_': |
| 22 | + base_environ.update({'UEP_ENABLE_THREADS': '1'}) |
12 | 23 | vs = '"C:/Program Files (x86)/MSBuild/14.0/Bin/MSBuild.exe"' |
13 | 24 | process = subprocess.Popen('{0} {1} /t:Rebuild /p:Configuration="Development Editor" /p:Platform=Win64'.format(vs, project), env=base_environ) |
14 | 25 | while process.poll() is None: |
@@ -42,13 +53,21 @@ def git(project): |
42 | 53 | sln = os.path.join('D:/', project, '{0}.sln'.format(project)) |
43 | 54 | git(project) |
44 | 55 | for python_version in PYTHON_VERSIONS: |
45 | | - start = time.time() |
46 | | - print('\n\n***** building {0} for {1} *****\n\n'.format(sln, python_version)) |
47 | | - sys.stdout.flush() |
48 | | - msbuild(sln, python_version) |
49 | | - commandlet(ue_version, project) |
50 | | - end = time.time() |
51 | | - print('\n\n***** built {0} for {1} in {2} seconds *****\n\n'.format(project, python_version, end-start)) |
| 56 | + for variant in ('', 'threaded_'): |
| 57 | + python_sanitized = os.path.basename(python_version).lower() |
| 58 | + start = time.time() |
| 59 | + print('\n\n***** building {0} for {1} ({2}) *****\n\n'.format(sln, python_version, variant)) |
| 60 | + sys.stdout.flush() |
| 61 | + msbuild(sln, python_version, variant) |
| 62 | + commandlet(ue_version, project) |
| 63 | + end = time.time() |
| 64 | + for item in ('UE4Editor.modules', 'UE4Editor-UnrealEnginePython.dll', 'UE4Editor-PythonConsole.dll', 'UE4Editor-PythonEditor.dll'): |
| 65 | + shutil.copyfile('D:/{0}/Plugins/UnrealEnginePython/Binaries/Win64/{1}'.format(project, item), '{0}/UnrealEnginePython/Binaries/Win64/{1}'.format(RELEASE_DIR, item)) |
| 66 | + filename = 'UnrealEnginePython_{0}_{1}_{2}_{3}win64.zip'.format(os.path.basename(RELEASE_DIR), ue_version.replace('.','_'), python_sanitized, variant) |
| 67 | + zh = zipfile.ZipFile(os.path.join(RELEASE_DIR, filename), 'w', zipfile.ZIP_DEFLATED) |
| 68 | + zipdir(os.path.join(RELEASE_DIR, 'UnrealEnginePython'), zh) |
| 69 | + zh.close() |
| 70 | + print('\n\n***** built {0} for {1} in {2} seconds [{3}]*****\n\n'.format(project, python_version, end-start, filename)) |
52 | 71 |
|
53 | 72 | main_end = time.time() |
54 | 73 | print('release ready after {0} seconds'.format(main_end-main_start)) |
0 commit comments