|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +import sys |
| 5 | +import os |
| 6 | +import zipfile |
| 7 | +import platform |
| 8 | + |
| 9 | + |
| 10 | +_platform = platform.platform().lower() |
| 11 | +is_linux = False |
| 12 | +is_windows = False |
| 13 | +if _platform.startswith("linux"): |
| 14 | + _platform = "linux" |
| 15 | + is_linux = True |
| 16 | +elif _platform.startswith("windows"): |
| 17 | + _platform = "windows" |
| 18 | + is_windows = True |
| 19 | +else: |
| 20 | + sys.exit("Unknown platform") |
| 21 | + |
| 22 | + |
| 23 | +if is_linux: |
| 24 | + ret = os.system("./build_plugin_linux.sh") |
| 25 | + |
| 26 | +if is_windows: |
| 27 | + ret = os.system("./build_plugin_windows.bat") |
| 28 | + |
| 29 | +if ret != 0: |
| 30 | + sys.exit("Could not build...") |
| 31 | + |
| 32 | + |
| 33 | +with open("version") as _file: |
| 34 | + content = _file.read() |
| 35 | + _version = content.strip() |
| 36 | + |
| 37 | +folder_inside = "UnigineEditorPlugin_Python3Scripting_" + _version |
| 38 | +_zip_filename = _platform + "_UnigineEditorPlugin_Python3Scripting_" + _version + ".zip" |
| 39 | + |
| 40 | +if os.path.isfile(_zip_filename): |
| 41 | + os.remove(_zip_filename) |
| 42 | + |
| 43 | +zf = zipfile.ZipFile(_zip_filename, 'w', zipfile.ZIP_DEFLATED) |
| 44 | + |
| 45 | +if is_linux: |
| 46 | + zf.write( |
| 47 | + "bin/editor/libUnigineEditorPlugin_Python3Scripting_x64.so", |
| 48 | + folder_inside + "/bin/editor/libUnigineEditorPlugin_Python3Scripting_x64.so", |
| 49 | + ) |
| 50 | + zf.write( |
| 51 | + "bin/editor_debug/libUnigineEditorPlugin_Python3Scripting_x64d.so", |
| 52 | + folder_inside + "/bin/editor_debug/libUnigineEditorPlugin_Python3Scripting_x64d.so", |
| 53 | + ) |
| 54 | + |
| 55 | +if is_windows: |
| 56 | + zf.write( |
| 57 | + "bin/editor/UnigineEditorPlugin_Python3Scripting_x64.dll", |
| 58 | + folder_inside + "/bin/editor/UnigineEditorPlugin_Python3Scripting_x64.dll", |
| 59 | + ) |
| 60 | + zf.write( |
| 61 | + "bin/editor_debug/UnigineEditorPlugin_Python3Scripting_x64d.dll", |
| 62 | + folder_inside + "/bin/editor_debug/UnigineEditorPlugin_Python3Scripting_x64d.dll", |
| 63 | + ) |
| 64 | + |
| 65 | + |
| 66 | +rootdir = "Python3Scripting_examples" |
| 67 | +for root, subdirs, files in os.walk(rootdir): |
| 68 | + for _file in files: |
| 69 | + _src = os.path.join(root, _file) |
| 70 | + _src = _src[len(rootdir)+1:] |
| 71 | + _src = os.path.join("bin", "Python3Scripting", _src) |
| 72 | + _dst = os.path.join(folder_inside, _src) |
| 73 | + zf.write(_src, _dst) |
| 74 | + |
| 75 | +zf.close() |
0 commit comments