''' Created on 16.05.2012 @author: Dima ''' import time import argparse from os.path import abspath, dirname from sys import argv import os, sys from subprocess import Popen, PIPE global separator_string separator_string = " " def subprocess(request): print(request) p = Popen(request, stdout=PIPE, stdin = PIPE, shell= True) text = p.communicate("y\n".encode()) retcode = p.wait() print(text[0].decode('cp866')) print("exit", "code: %d" % retcode, sep=separator_string) return retcode def main(argv): parser = argparse.ArgumentParser(description=separator_string.join(['Build', 'Qt', 'with', 'configuration']), epilog=separator_string.join(['Tested', 'on', 'Python 3.2.2', 'OS Windows XP'])) parser.add_argument('-qtd', '--qt_dir', dest='qt_dir' , help=separator_string.join(['Set', 'a', 'path', 'to', 'Qt', 'dir' ]), default = argv[0]) parser.add_argument('-ctl', '--conf_type_link', dest = 'conf_type_link', help=separator_string.join(['Set', 'a', 'type', 'link', 'Qt' ]), default= "'-shared'") parser.add_argument('-ctb', '--conf_type_build', dest='conf_type_build' , help=separator_string.join(['Set', 'a', 'type', 'build', 'Qt']), default = "'-debug-and-release'") parser.add_argument('-cspec', '--conf_spec', dest='conf_specification' , help=separator_string.join(['Set', 'a', 'specification', 'build', 'Qt' ]), default = "'win32-msvc2010'") parser.add_argument('-fout', '--lout_file', dest='stream_log_out_file_name', help=separator_string.join(['Set', 'a', 'name', 'for', 'the', 'output', 'file'])) parser.add_argument('-ferr', '--lerr_file', dest='stream_log_err_file_name', help=separator_string.join(['Set', 'a', 'name', 'for', 'the' , 'error' , 'output', 'file'])) options = parser.parse_args() conf_specification = options.conf_specification.replace("'","") qt_dir = options.qt_dir.replace("'","") conf_type_link = options.conf_type_link.replace("'","") conf_type_build = options.conf_type_build.replace("'","") script_start_up_dir = dirname(abspath(argv[0])) print('Script', "is" , "launched", "in" , 'dir: %s' % script_start_up_dir, sep=separator_string) print("Args: %s" % options) request = [os.path.join("C:/", "Program Files", "Microsoft Visual Studio 10.0", "Common7", "Tools", "vsvars32.bat")] subprocess(request) os.system("PAUSE") saveout = sys.stdout saveerr = sys.stderr if options.stream_log_out_file_name: stream_log_out_file = open(options.stream_log_out_file_name, 'w') sys.stdout = stream_log_out_file sys.stderr = stream_log_out_file if options.stream_log_err_file_name: stream_log_err_file = open(options.stream_log_err_file_name, 'w') sys.stderr = stream_log_err_file start_time = time.clock() print ('Setting', 'up' ,'a', 'Qt' ,'environment...', sep=separator_string) os.environ['QTDIR'] = qt_dir print("--", "QTDIR", "set" ,"to" ,"%s"%os.environ['QTDIR']) os.environ['PATH']= "%s;%s"%(os.path.join(os.environ['QTDIR'],"bin"),os.environ['PATH']) print("--", "Added", "%s"%os.path.join(os.environ['QTDIR'],"bin"), "to", "PATH") os.environ['QMAKESPEC']= conf_specification print("--", "QMAKESPEC" ,"set" ,"to" , os.environ['QMAKESPEC']) os.chdir(qt_dir) print ("Configuration", "Qt", sep=separator_string) request = [ "configure.exe", conf_type_link, conf_type_build, "-opensource", "-qt-zlib", "-qt-libpng", "-qt-libmng", "-qt-libjpeg", "-no-crt", "-nomake", "demos", "-nomake", "examples", "-no-qt3support", "-no-qmake", ] subprocess(request) os.chdir("qmake") print ("Compile", "qmake", sep=separator_string) request = [ os.path.join(script_start_up_dir,"jom", "jom.exe"), "-j", "%d"%4, "-f", "makefile.win32"] subprocess(request) request = [ os.path.join(script_start_up_dir,"jom", "jom.exe"), "-f", "makefile.win32", "clean"] subprocess(request) os.chdir(qt_dir) print ("Compile", "Qt", sep=separator_string) request = [ os.path.join(script_start_up_dir,"jom", "jom.exe"), "-j", "%d"%4] subprocess(request) now_time = time.clock() print("Time:", time.strftime('%H:%M:%S', time.gmtime(start_time - now_time)),sep= separator_string) if options.stream_log_out_file_name: sys.stdout = stream_log_out_file stream_log_out_file.close() if options.stream_log_err_file_name: sys.stderr = stream_log_err_file stream_log_err_file.close() sys.stdout = saveout sys.stderr = saveerr os.system("PAUSE") if __name__ == '__main__': main(argv[1:])
основные проблемы:
1.
Compile qmake ['C:\\workspace\\QtBuild\\src\\qtbuild\\jom\\jom.exe', '-j', '4', '-f', 'makefile.win32'] jom 1.0.11 - empower your cores jom: C:\Qt\4.8.1\qmake\makefile.win32 [qmake_pch.obj] Error 1 cl -c -Fo./ -W3 -nologo -O2 /MP -I. -Igenerators -Igenerators\unix -Igenerators\win32 -Igenerators\mac -Igenerators\symbian -Igenerators\integrity -I..\include -I..\include\QtCore -I..\include -I..\include\QtCore -I..\src\corelib\global -I..\src\corelib\xml -I..\mkspecs\win32-msvc2010 -I..\tools\shared -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED -DQLIBRARYINFO_EPOCROOT -c -Yc -Fpqmake_pch.pch -TP qmake_pch.h "cl" не является внутренней или внешней командой, исполняемой программой или пакетным файлом. exit code: 2
request = [os.path.join("C:/", "Program Files", "Microsoft Visual Studio 10.0", "Common7", "Tools", "vsvars32.bat")] subprocess(request)