-
Notifications
You must be signed in to change notification settings - Fork 1
/
makeRelease.py
93 lines (74 loc) · 3.01 KB
/
makeRelease.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
87
88
89
90
91
92
93
from pathlib import Path, PurePath
import os
import shutil
import zipfile
import sys
PROJECT_NAME = "rrt"
BIN_DIR = "release"
BIN_BIN_DIR = BIN_DIR + "/bin"
RELEASE_DIR = BIN_DIR + "/release"
CMAKE_PRE_BUILD_CMD = "cmake . -B" + BIN_DIR
CMAKE_BUILD_CMD = "cmake --build " + BIN_DIR + " --config MinSizeRel -j4"
BOOST_VERSION = "1_71"
BOOST_PREFIX = "libboost_"
BOOST_SUFFIX = "-mgw73-mt-x64-" + BOOST_VERSION + ".dll"
BOOST_LIBS = ["date_time", "filesystem",
"thread", "log"] # change it to include in zip
# just add search path and name to include in zip
INCLUDED_FILES = (("c:/Program Files (x86)/zlib", "libzlib.dll"),)
IGNORED_FILES = ["D3Dcompiler_47.dll",
"opengl32sw.dll", "libEGL.dll", "libGLESV2.dll"] # these files will be deleted from release
def cmake(clean=False):
if Path(BIN_DIR).exists():
print("removing " + BIN_DIR + " dir")
shutil.rmtree(BIN_DIR)
os.system(CMAKE_PRE_BUILD_CMD)
os.system(CMAKE_BUILD_CMD)
def findFile(src, filename):
for dirpath, _, filenames in os.walk(src):
for file in filenames:
if file.lower() == filename:
print("Found " + filename + " in " + dirpath)
return dirpath + "\\" + file
print(filename + " not found")
quit()
def addToZip(version=""):
zipPath = BIN_DIR + "/" + PROJECT_NAME + " " + version + ".zip"
if Path(zipPath).exists():
os.remove(zipPath)
with zipfile.ZipFile(zipPath, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as releaseZip:
for dirpath, _, filenames in os.walk(RELEASE_DIR):
for filename in filenames:
fullPath = dirpath + "/" + filename
fullPathWithoutReleaseDir = fullPath.replace(RELEASE_DIR, "")
if filename not in IGNORED_FILES:
releaseZip.write(dirpath + "/" + filename,
fullPathWithoutReleaseDir)
for lib in BOOST_LIBS:
fullName = BOOST_PREFIX + lib + BOOST_SUFFIX
releaseZip.write(findFile("c:/boost/lib", fullName), fullName)
for toZip in INCLUDED_FILES:
releaseZip.write(findFile(toZip[0], toZip[1]), toZip[1])
print('Zip created in "' + zipPath + '"')
def prepareReleaseDir():
if Path(RELEASE_DIR).exists():
shutil.rmtree(RELEASE_DIR)
shutil.copytree(BIN_BIN_DIR, RELEASE_DIR)
print("Release dir " + RELEASE_DIR + " prepared")
def getProjectVersion():
versionPath = findFile(BIN_DIR, "version.h")
if versionPath == "":
return
with open(versionPath) as f:
for line in f:
if (line.find("PROJECT_VER") != -1):
projectVersion = line.split('"')[1]
print("Got Project Version = " + projectVersion)
return projectVersion
return
if __name__ == "__main__":
cmake()
prepareReleaseDir()
os.system(findFile(os.getenv("QT_DIR", "c:/Qt"),
"windeployqt.exe") + " --release " + RELEASE_DIR)
addToZip(getProjectVersion())