-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from pathlib import Path, PurePath | ||
import os | ||
import shutil | ||
import zipfile | ||
|
||
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" | ||
|
||
IGNORED_FILES = ["D3Dcompiler_47.dll", | ||
"opengl32sw.dll", "libEGL.dll", "libGLESV2.dll"] | ||
|
||
|
||
def cmake(): | ||
if Path(BIN_DIR).exists(): | ||
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) | ||
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()) |