def doUploadToStaging(buildmode, workingDir, buildVersion, log): print "doUploadToStaging..." if buildmode == "debug": dbgStr = "DEBUG=1" else: dbgStr = "" buildRoot = os.path.join(workingDir, 'external') print 'Setting BUILD_ROOT=', buildRoot log.write('Setting BUILD_ROOT=' + buildRoot + '\n') os.putenv('BUILD_ROOT', buildRoot) os.chdir(buildRoot) uploadDir = os.path.join(buildRoot, buildVersion) if not os.path.exists(uploadDir): os.mkdir(uploadDir) try: upload = ' uploadworld UPLOAD=' + uploadDir print "Doing make " + dbgStr + upload log.write("Doing make " + dbgStr + upload + "\n") outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], dbgStr, upload]) hardhatutil.dumpOutputList(outputList, log) log.write(separator) except hardhatutil.ExternalCommandErrorWithOutputList, e: print "upload error" log.write("***Error during upload***\n") log.write(separator) log.write("Build log:" + "\n") hardhatutil.dumpOutputList(e.outputList, log) log.write(separator) raise e
def doTests(hardhatScript, mode, workingDir, outputDir, buildVersion, log): testDir = os.path.join(workingDir, "chandler") os.chdir(testDir) if mode == "debug": dashT = '-dvt' else: dashT = '-vrt' try: # test print "Testing " + mode log.write(separator) log.write("Testing " + mode + " ...\n") print "hardhatScript [%s]" % hardhatScript outputList = hardhatutil.executeCommandReturnOutput( [hardhatScript, dashT]) hardhatutil.dumpOutputList(outputList, log) except Exception, e: print "a testing error" doCopyLog("***Error during tests***", workingDir, logPath, log) forceBuildNextCycle(log, workingDir) return "test_failed"
def doDistribution(workingDir, log, outputDir, buildVersion, buildVersionEscaped): log.write(separator) log.write("[tbox] Creating distribution files\n") for (module, target, distSource, fileGlob) in reposDist: moduleDir = os.path.join(workingDir, module) print "Distribution [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput([antProgram, target]) hardhatutil.dumpOutputList(outputList, log) sourceDir = os.path.join(moduleDir, distSource) targetDir = os.path.join(outputDir, buildVersion) if not os.path.exists(targetDir): os.mkdir(targetDir) print sourceDir, targetDir log.write("[tbox] Moving %s to %s\n" % (sourceDir, targetDir)) hardhatlib.copyFiles(sourceDir, targetDir, fileGlob) except Exception, e: doCopyLog("***Error during distribution building process*** ", workingDir, logPath, log) raise e
def doDistribution(workingDir, log, outputDir, buildVersion, buildVersionEscaped): log.write(separator) log.write("[tbox] Creating distribution files\n") for (module, target, distSource, fileGlob) in reposDist: moduleDir = os.path.join(workingDir, module) print "Distribution [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput( [antProgram, target]) hardhatutil.dumpOutputList(outputList, log) sourceDir = os.path.join(moduleDir, distSource) targetDir = os.path.join(outputDir, buildVersion) if not os.path.exists(targetDir): os.mkdir(targetDir) print sourceDir, targetDir log.write("[tbox] Moving %s to %s\n" % (sourceDir, targetDir)) hardhatlib.copyFiles(sourceDir, targetDir, fileGlob) except Exception, e: doCopyLog("***Error during distribution building process*** ", workingDir, logPath, log) raise e
def doDistribution(releaseMode, workingDir, log, outputDir, buildVersion, buildVersionEscaped, hardhatScript): # Create end-user, developer distributions chanDir = os.path.join(workingDir, 'chandler') os.chdir(chanDir) print "Making distribution files for " + releaseMode log.write(separator) log.write("Making distribution files for " + releaseMode + "\n") if releaseMode == "debug": distOption = "-dD" else: distOption = "-D" try: outputList = hardhatutil.executeCommandReturnOutput([ hardhatScript, "-o", os.path.join(outputDir, buildVersion), distOption, buildVersionEscaped ]) hardhatutil.dumpOutputList(outputList, log) except Exception, e: doCopyLog("***Error during distribution building process*** ", workingDir, logPath, log) forceBuildNextCycle(log, workingDir) raise e
def doInstall(buildmode, workingDir, log, cleanFirst=False): # for our purposes, we do not really do a build # we will update chandler from SVN, and grab new tarballs when they appear if buildmode == "debug": dbgStr = "DEBUG=1" else: dbgStr = "" if cleanFirst: clean = " clean " else: clean = " " moduleDir = os.path.join(workingDir, mainModule) os.chdir(moduleDir) print "Doing make " + dbgStr + clean + "install strip\n" log.write("Doing make " + dbgStr + clean + "install strip\n") try: outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], dbgStr, clean, "install", "strip" ]) hardhatutil.dumpOutputList(outputList, log) except hardhatutil.ExternalCommandErrorWithOutputList, e: print "build error" log.write("***Error during build***\n") log.write(separator) log.write("Build log:" + "\n") hardhatutil.dumpOutputList(e.outputList, log) log.write(separator) forceBuildNextCycle(log, workingDir) raise e
def doInstall(buildmode, workingDir, log, cleanFirst=False): # for our purposes, we do not really do a build # we will update chandler from SVN, and grab new tarballs when they appear if buildmode == "debug": dbgStr = "DEBUG=1" else: dbgStr = "" if cleanFirst: clean = " clean " else: clean = " " moduleDir = os.path.join(workingDir, mainModule) os.chdir(moduleDir) print "Doing make " + dbgStr + clean + "install strip\n" log.write("Doing make " + dbgStr + clean + "install strip\n") try: outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], dbgStr, clean, "install", "strip"]) hardhatutil.dumpOutputList(outputList, log) except hardhatutil.ExternalCommandErrorWithOutputList, e: print "build error" log.write("***Error during build***\n") log.write(separator) log.write("Build log:" + "\n") hardhatutil.dumpOutputList(e.outputList, log) log.write(separator) forceBuildNextCycle(log, workingDir) raise e
def doBuild(buildmode, workingDir, log, svnChanges, clean='realclean'): # We only build external if there were changes in it # We build internal if external or internal were changed # We never build in chandler, because there is nothing to build if buildmode == "debug": dbgStr = "DEBUG=1" else: dbgStr = "" buildRoot = os.path.join(workingDir, 'external') print 'Setting BUILD_ROOT=', buildRoot log.write('Setting BUILD_ROOT=' + buildRoot + '\n') os.putenv('BUILD_ROOT', buildRoot) try: for module in reposModules: print module, "..." log.write("- - - - " + module + " - - - - - - -\n") if module == 'external' and not svnChanges['external']: print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue if module == 'internal' and not svnChanges['external'] and not svnChanges['internal']: print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue if module == 'chandler': print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue moduleDir = os.path.join(workingDir, module) print "cd", moduleDir log.write("cd " + moduleDir + "\n") os.chdir(moduleDir) buildCmds = ' all binaries install' print "Doing make " + dbgStr + " " + clean + buildCmds + "\n" log.write("Doing make " + dbgStr + " " + clean + buildCmds + "\n") outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], dbgStr, clean, buildCmds ]) hardhatutil.dumpOutputList(outputList, log) log.write(separator) except hardhatutil.ExternalCommandErrorWithOutputList, e: print "build error" log.write("***Error during build***\n") log.write(separator) log.write("Build log:" + "\n") hardhatutil.dumpOutputList(e.outputList, log) log.write(separator) forceBuildNextCycle(log, workingDir) raise e
def doBuild(workingDir, log): log.write("[tbox] Building\n") for (module, target) in reposBuild: moduleDir = os.path.join(workingDir, module) mavenDir = os.path.join(workingDir, "..", "tbox_maven", module) print "Building [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput([antProgram, "-Dmaven.home.local=" + mavenDir, target]) hardhatutil.dumpOutputList(outputList, log) except: log.write("[tbox] Build failed for [%s]\n" % module)
def doRealclean(log, workingDir): try: # If make install fails, it will almost certainly fail next time # as well - the typical case has been bad binaries packages. # So what we do here is try to do realclean which will force # the build to get new binaries tarballs next time, and if fixed # binaries were uploaded in the meanwhile we'll recover # automatically. This will also sort us out of corrupted debug/release. print "Doing make realclean\n" log.write("Doing make realclean\n") moduleDir = os.path.join(workingDir, mainModule) os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], "realclean"]) hardhatutil.dumpOutputList(outputList, log) except: print "make realclean failed\n" log.write("make realclean failed\n")
def doDistribution(releaseMode, workingDir, log, outputDir, buildVersion, buildVersionEscaped, hardhatScript): # Create end-user, developer distributions print "Making distribution files for " + releaseMode log.write(separator) log.write("Making distribution files for " + releaseMode + "\n") if releaseMode == "debug": distOption = "-dD" else: distOption = "-D" try: outputList = hardhatutil.executeCommandReturnOutput( [hardhatScript, "-o", os.path.join(outputDir, buildVersion), distOption, buildVersionEscaped]) hardhatutil.dumpOutputList(outputList, log) except Exception, e: doCopyLog("***Error during distribution building process*** ", workingDir, logPath, log) forceBuildNextCycle(log, workingDir) raise e
def doBuild(workingDir, log): log.write("[tbox] Building\n") for (module, target) in reposBuild: moduleDir = os.path.join(workingDir, module) mavenDir = os.path.join(workingDir, '..', 'tbox_maven', module) print "Building [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput( [antProgram, '-Dmaven.home.local=' + mavenDir, target]) hardhatutil.dumpOutputList(outputList, log) except: log.write("[tbox] Build failed for [%s]\n" % module)
def doTests(workingDir, log): log.write("[tbox] Running unit tests\n") for (module, target) in reposTest: moduleDir = os.path.join(workingDir, module) print "Testing [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput([antProgram, target]) hardhatutil.dumpOutputList(outputList, log) except Exception, e: doCopyLog("***Error during tests***", workingDir, logPath, log) return "test_failed" else: doCopyLog("Tests successful", workingDir, logPath, log)
def main(): curDir = os.path.abspath(os.getcwd()) path = os.environ.get('PATH', os.environ.get('path')) svnProgram = hardhatutil.findInPath(path, "svn") if os.path.exists(stopFile): os.remove(stopFile) go = 1 firstRound = 1 while go: os.chdir(curDir) if not firstRound: print "Sleeping 5 minutes" time.sleep(5 * 60) nowString = time.strftime("%Y-%m-%d %H:%M:%S") # check SVN for any new hardhat script try: # bring this hardhat directory up to date outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "update"]) hardhatutil.dumpOutputList(outputList) except: raise TinderbuildError, "Error updating HardHat" try: # launch the real build script outputList = hardhatutil.executeCommandReturnOutput( [os.path.join(curDir, 'tinderbox.py'), ' '.join(sys.argv[1:])]) hardhatutil.dumpOutputList(outputList) except: raise TinderbuildError, "Failed to launch build script" if os.path.exists(stopFile): go = 0 firstRound = 0
def doTests(workingDir, log): log.write("[tbox] Running unit tests\n") for (module, target) in reposTest: moduleDir = os.path.join(workingDir, module) print "Testing [%s]" % module try: os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutput( [antProgram, target]) hardhatutil.dumpOutputList(outputList, log) except Exception, e: doCopyLog("***Error during tests***", workingDir, logPath, log) return "test_failed" else: doCopyLog("Tests successful", workingDir, logPath, log)
def doBuild(buildmode, workingDir, log, svnChanges, clean='realclean'): # We only build external if there were changes in it # We build internal if external or internal were changed # We never build in chandler, because there is nothing to build if buildmode == "debug": dbgStr = "DEBUG=1" else: dbgStr = "" buildRoot = os.path.join(workingDir, 'external') print 'Setting BUILD_ROOT=', buildRoot log.write('Setting BUILD_ROOT=' + buildRoot + '\n') os.putenv('BUILD_ROOT', buildRoot) try: for module in reposModules: print module, "..." log.write("- - - - " + module + " - - - - - - -\n") if module == 'external' and not svnChanges['external']: print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue if module == 'internal' and not svnChanges[ 'external'] and not svnChanges['internal']: print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue if module == 'chandler': print 'Nothing to be done for module', module log.write('Nothing to be done for module ' + module + '\n') log.write(separator) continue moduleDir = os.path.join(workingDir, module) print "cd", moduleDir log.write("cd " + moduleDir + "\n") os.chdir(moduleDir) buildCmds = ' all binaries install' print "Doing make " + dbgStr + " " + clean + buildCmds + "\n" log.write("Doing make " + dbgStr + " " + clean + buildCmds + "\n") outputList = hardhatutil.executeCommandReturnOutput( [buildenv['make'], dbgStr, clean, buildCmds]) hardhatutil.dumpOutputList(outputList, log) log.write(separator) except hardhatutil.ExternalCommandErrorWithOutputList, e: print "build error" log.write("***Error during build***\n") log.write(separator) log.write("Build log:" + "\n") hardhatutil.dumpOutputList(e.outputList, log) log.write(separator) forceBuildNextCycle(log, workingDir) raise e