Skip to content

Commit

Permalink
added makeRelease.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
Niakr1s committed Nov 23, 2019
1 parent e5ef978 commit da70283
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
release/*
*.dwl
*.dwl2
*.bak
Expand Down
75 changes: 75 additions & 0 deletions makeRelease.py
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())

0 comments on commit da70283

Please sign in to comment.