delphimvcframework/build.py

72 lines
2.5 KiB
Python
Raw Normal View History

2015-04-01 17:01:23 +02:00
# coding: latin-1
import subprocess
import os
import glob
from colorama import *
init()
2015-04-01 17:01:23 +02:00
#################################################################################
def buildProject(project):
print(Fore.YELLOW + "Building " + project)
2015-04-01 17:01:23 +02:00
p = project.replace('.dproj', '.cfg')
if os.path.isfile(p):
if os.path.isfile(p + '.unused'):
os.remove(p + '.unused')
os.rename(p, p + '.unused')
2015-04-01 17:01:23 +02:00
# print os.system("msbuild /t:Build /p:Config=Debug \"" + project + "\"")
return subprocess.call("rsvars.bat & msbuild /t:Build /p:Config=Debug /p:Platform=Win32 \"" + project + "\"", shell=True) == 0
2015-04-01 17:01:23 +02:00
def summaryTable(builds):
print(ansi.clear_screen())
dmvc_copyright()
print(Fore.WHITE + "PROJECT NAME".ljust(90) + "STATUS".ljust(10))
print(Fore.YELLOW + "=" * 100)
2015-04-01 17:01:23 +02:00
good = bad = 0
for item in builds:
if item['status'] == 'ok':
#WConio.textcolor(WConio.LIGHTGREEN)
2015-04-01 17:01:23 +02:00
good += 1
else:
#WConio.textcolor(WConio.RED)
2015-04-01 17:01:23 +02:00
bad += 1
print(Fore.BLUE + item['project'].ljust(90) + (Fore.WHITE if item['status'] == 'ok' else Fore.RED) + item['status'].ljust(4))
#WConio.textcolor(WConio.WHITE)
print(Fore.YELLOW + "=" * 100)
#WConio.textcolor(WConio.GREEN)
print(Fore.WHITE + "GOOD :".rjust(90) + str(good).rjust(10, '.'))
#WConio.textcolor(WConio.RED)
print(Fore.RED + "BAD :".rjust(90) + str(bad).rjust(10, '.'))
2015-04-01 17:01:23 +02:00
#################################################################################
def main(projects):
dmvc_copyright()
builds = []
for project in projects:
filename = '\\'.join(project.split('\\')[-3:])
list = {'project': filename}
if buildProject(project):
list["status"] = "ok"
else:
list["status"] = "ko"
builds.append(list)
summaryTable(builds)
2015-04-01 17:01:23 +02:00
# Store current attribute settings
#old_setting = WConio.gettextinfo()[4] & 0x00FF
2015-04-01 17:01:23 +02:00
def dmvc_copyright():
print(Style.BRIGHT + Fore.WHITE + "----------------------------------------------------------------------------------------")
print(Fore.RED + " ** Delphi MVC Framework Building System **")
print(Fore.WHITE + "Delphi MVC Framework is CopyRight (2010-2016) of Daniele Teti and the DMVCFramework TEAM")
print(Fore.RESET + "----------------------------------------------------------------------------------------\n")
2015-04-01 17:01:23 +02:00
## MAIN ##
projects = glob.glob("*\**\*.dproj")
main(projects)
print(Style.RESET_ALL)