Go to most recent revision | Compare with Previous | Blame | View Log
# Chandler blueprintimport os, hardhatutiltreeName = "Chandler"def Start(hardhatScript, workingDir, cvsVintage, buildId, clobber, log):# make sure workingDir is absoluteworkingDir = os.path.abspath(workingDir)if not os.path.exists(workingDir):os.mkdir(workingDir)os.chdir(workingDir)# do debugDo(hardhatScript, "debug", workingDir, cvsVintage, buildId, clobber, log)# do releaseDo(hardhatScript, "release", workingDir, cvsVintage, buildId, clobber, log)# These modules are the ones to check out of CVScvsModules = ('osaf/chandler/Chandler','osaf/chandler/python','osaf/chandler/zodb','osaf/chandler/distutils','osaf/chandler/egenix-mx','osaf/chandler/wxpython','osaf/chandler/jabber-py','osaf/chandler/swig','osaf/chandler/pkgconfig','osaf/chandler/net/expat','osaf/chandler/net/gettext','osaf/chandler/net/glib','osaf/chandler/net/libiconv','osaf/chandler/net/libxml2','osaf/chandler/net/roadrunner','osaf/chandler/net/sc-db','osaf/chandler/net/rap')# If any of these modules have changed, scrub everything before buildingscrubAllModules = {'osaf/chandler/python':1,'osaf/chandler/zodb':1,'osaf/chandler/distutils':1,'osaf/chandler/egenix-mx':1,'osaf/chandler/wxpython':1,'osaf/chandler/jabber-py':1,'osaf/chandler/swig':1,'osaf/chandler/pkgconfig':1,'osaf/chandler/net/expat':1,'osaf/chandler/net/gettext':1,'osaf/chandler/net/glib':1,'osaf/chandler/net/libiconv':1,'osaf/chandler/net/libxml2':1,'osaf/chandler/net/roadrunner':1,'osaf/chandler/net/sc-db':1,'osaf/chandler/net/rap':1}mainModule = 'osaf/chandler/Chandler'logPath = 'osaf/chandler/hardhat.log'def Do(hardhatScript, mode, workingDir, cvsVintage, buildId, clobber, log):print "Do " + modelog.write("Do " + mode + "\n")path = os.environ.get('PATH', os.environ.get('path'))print "Path =", pathcvsProgram = hardhatutil.findInPath(path, "cvs")print "CVS =", cvsProgramprint "HardHat = ", hardhatScriptmodeDir = os.path.join(workingDir, mode)if clobber:if os.path.exists(modeDir):print "removing", modeDirlog.write("removing " + modeDir + "\n")hardhatutil.rmdirRecursive(modeDir)if not os.path.exists(modeDir):print "creating", modeDirlog.write("creating " + modeDir + "\n")os.mkdir(modeDir)os.chdir(modeDir)moduleData = {}needToScrubAll = 0for module in cvsModules:print "- - - -", module, "- - - - - - - - - - - - - - - - -"log.write("module: " + module + "\n")moduleData[module] = {}moduleDir = os.path.join(modeDir, module)# does module's directory exist?if not os.path.exists(moduleDir):# check out that moduleos.chdir(modeDir)print "checking out", modulelog.write("checking out: " + module + " with " + cvsVintage + "\n")outputList = hardhatutil.executeCommandReturnOutput([cvsProgram, "-q", "checkout", cvsVintage, module])dumpOutputList(outputList, log)else:# it exists, see if it has changedos.chdir(moduleDir)print "seeing if we need to update", moduleoutputList = hardhatutil.executeCommandReturnOutput([cvsProgram, "-qn", "update", cvsVintage])dumpOutputList(outputList, log)if NeedsUpdate(outputList):print "YES"moduleData[module]["changed"] = 1# update itos.chdir(moduleDir)print "updating", modulelog.write("updating: " + module + " with " + cvsVintage + "\n")outputList = hardhatutil.executeCommandReturnOutput([cvsProgram, "-q", "update", cvsVintage])dumpOutputList(outputList, log)if scrubAllModules.has_key(module):print "we need to scrub everything"needToScrubAll = 1else:print "NO, unchanged"log.write("unchanged" + "\n")moduleData[module]["changed"] = 0mainModuleDir = os.path.join(modeDir, mainModule)print "Main module dir =", mainModuleDirif needToScrubAll:os.chdir(mainModuleDir)print "Scrubbing all"log.write("scrubbing all" + "\n")outputList = hardhatutil.executeCommandReturnOutput([hardhatScript, "-nS"])libraryDir = os.path.join(modeDir, "osaf", "chandler", mode)if os.path.exists(libraryDir):print "removing", libraryDirlog.write("removing " + libraryDir + "\n")hardhatutil.rmdirRecursive(libraryDir)else:os.chdir(mainModuleDir)print "scrubbing only Chandler"log.write("scrubbing only Chandler" + "\n")outputList = hardhatutil.executeCommandReturnOutput([hardhatScript, "-ns"])os.chdir(mainModuleDir)try:if mode == "debug":print "Building debug"log.write("building debug" + "\n")outputList = hardhatutil.executeCommandReturnOutput([hardhatScript, "-dB"])if mode == "release":print "Building release"log.write("building release" + "\n")outputList = hardhatutil.executeCommandReturnOutput([hardhatScript, "-rB"])outputList = hardhatutil.executeCommandReturnOutput([hardhatScript, "-D"])except Exception, e:print "a build error"log.write("error during build" + "\n")log.write("build log:" + "\n")CopyLog(os.path.join(modeDir, logPath), log)log.write("end of log" + "\n")raise eelse:log.write("build successful" + "\n")log.write("build log:" + "\n")CopyLog(os.path.join(modeDir, logPath), log)log.write("end of log" + "\n")# need to get exit codes from hardhat calls# test# distribute, copy to output dirdef dumpOutputList(outputList, fd = None):for line in outputList:print "------"+ line,if fd:fd.write(line)def NeedsUpdate(outputList):for line in outputList:if line.find("IDE Scripts"):# this hack is for skipping some Mac-specific files that# under Windows always appear to be needing an updatecontinueif line[0] == "U":return 1if line[0] == "P":return 1if line[0] == "A":return 1if line[0] == "R":return 1def CopyLog(file, fd):input = open(file, "r")line = input.readline()while line:fd.write(line)line = input.readline()input.close()