def generateCMake(generator, platform, log, checkOptionalLibs, python): buildDir = os.path.join(env["SUMO_HOME"], "build", "cmake-build-" + platform) cmakeOpt = ["-DCOMPILE_DEFINITIONS=MSVC_TEST_SERVER", "-DCHECK_OPTIONAL_LIBS=%s" % checkOptionalLibs] if python: cmakeOpt += ["-DPYTHON_EXECUTABLE=%s" % python] if checkOptionalLibs: cmakeOpt += ["-DSUMO_UTILS=True"] # Create directory or clear it if already exists if os.path.exists(buildDir): status.printLog("Cleaning directory of %s." % generator, log) shutil.rmtree(buildDir) os.makedirs(buildDir) status.printLog("Creating solution for %s." % generator, log) subprocess.call(["cmake", "../..", "-G", generator, "-A", platform] + cmakeOpt, cwd=buildDir, stdout=log, stderr=subprocess.STDOUT) return buildDir
def generateCMake(generator, platform, checkOptionalLibs, python): buildDir = os.path.join(SUMO_HOME, "build", "cmake-build-" + platform) cmakeOpt = ["-DCOMPILE_DEFINITIONS=MSVC_TEST_SERVER", "-DCHECK_OPTIONAL_LIBS=%s" % checkOptionalLibs] if python: cmakeOpt += ["-DPYTHON_EXECUTABLE=%s" % python] if checkOptionalLibs: cmakeOpt += ["-DSUMO_UTILS=True"] # Create directory or clear it if already exists try: if os.path.exists(buildDir): status.printLog("Cleaning directory of %s." % generator) shutil.rmtree(buildDir) os.makedirs(buildDir) except Exception as e: status.printLog("Error occured on build dir cleanup: %s." % e) status.printLog("Creating solution for %s." % generator) status.log_subprocess(["cmake", "../..", "-G", generator, "-A", platform] + cmakeOpt, cwd=buildDir) return buildDir
options.binDir.replace("bin", "tools"), "libsumo") for ext in ("*.exe", "*.ilk", "*.pdb", "*.py", "*.pyd", "*.dll", "*.lib", "*.exp", "*.jar"): toClean += glob.glob(os.path.join(options.rootDir, options.binDir, ext)) toClean += glob.glob(os.path.join(toolsLibsumoDir, "libsumo*")) for f in toClean: try: os.remove(f) except WindowsError: pass # we need to use io.open here due to http://bugs.python.org/issue16273 with io.open(makeLog, 'a') as log: status.printLog( "Running %s build using python %s." % (options.msvc_version, sys.version), log) gitrev = repositoryUpdate(options, log) generator = "Visual Studio " + ("12 2013" if options.msvc_version == "msvc12" else "16 2019") buildDir = generateCMake(generator, platform, log, options.suffix == "extra", options.python) ret = subprocess.call(["cmake", "--build", ".", "--config", "Release"], cwd=buildDir, stdout=log, stderr=subprocess.STDOUT) if os.path.exists(os.path.join("src", "libsumo", "_libsumo.vcxproj")): subprocess.call(["cmake", "--build", ".", "--target", "_libsumo"], cwd=buildDir, stdout=log, stderr=subprocess.STDOUT)
def main(options, platform="x64"): env["FILEPREFIX"] = options.msvc_version + options.suffix + platform prefix = os.path.join(options.remoteDir, env["FILEPREFIX"]) makeLog = prefix + "Release.log" makeAllLog = prefix + "Debug.log" testLog = prefix + "Test.log" testDebugLog = prefix + "DebugTest.log" statusLog = prefix + "status.log" log_handler = status.set_rotating_log(makeLog) status.killall(("", "D"), BINARIES) toClean = [] for ext in ("*.exe", "*.ilk", "*.pdb", "*.py", "*.pyd", "*.dll", "*.lib", "*.exp", "*.jar", "*.manifest", "*.fmu"): toClean += glob.glob(os.path.join(SUMO_HOME, "bin", ext)) toClean += glob.glob(os.path.join(SUMO_HOME, "tools", "lib*", "*lib*")) toClean += glob.glob(os.path.join(SUMO_HOME, "share", "*", "*")) for f in toClean: try: os.remove(f) except Exception: pass for d in (glob.glob(os.path.join(SUMO_HOME, "bin", "osgPlugins*")) + glob.glob(os.path.join(SUMO_HOME, "tools", "*.egg-info"))): shutil.rmtree(d, ignore_errors=True) for d in glob.glob(os.path.join(SUMO_HOME, "docs", "*")): if os.path.basename(d) in ('examples', 'javadoc', 'man', 'pydoc', 'tutorial', 'userdoc'): shutil.rmtree(d, ignore_errors=True) status.printLog("Running %s build using python %s." % (options.msvc_version, sys.version)) gitrev = repositoryUpdate(options) generator = "Visual Studio " + ("12 2013" if options.msvc_version == "msvc12" else "16 2019") buildDir = generateCMake(generator, platform, options.suffix == "extra", options.python) ret = status.log_subprocess(["cmake", "--build", ".", "--config", "Release"], cwd=buildDir) status.log_subprocess(["cmake", "--build", ".", "--config", "Release", "--target", "lisum"], cwd=buildDir) status.log_subprocess(["cmake", "--build", ".", "--config", "Release", "--target", "userdoc", "examples"], cwd=buildDir) status.log_subprocess(["cmake", "--install", "."], cwd=buildDir) plat = platform.lower().replace("x", "win") if options.msvc_version != "msvc16": plat += options.msvc_version for d in glob.glob(os.path.join(buildDir, "sumo-*")): if os.path.isdir(d): installDir = d installBase = os.path.basename(installDir) binaryZip = os.path.join(buildDir, "sumo-%s%s-%s" % (plat, options.suffix, installBase[5:])) if ret == 0: try: for f in (glob.glob(os.path.join(SUMO_HOME, "*.md")) + [os.path.join(SUMO_HOME, n) for n in ("AUTHORS", "ChangeLog", "LICENSE")]): shutil.copy(f, installDir) if options.suffix == "extra": shutil.copy(os.path.join(SUMO_HOME, "build", "wix", "gpl-2.0.txt"), os.path.join(installDir, "LICENSE")) for f in glob.glob(os.path.join(SUMO_HOME, "bin", "*.jar")): shutil.copy(f, os.path.join(installDir, "bin")) shutil.copytree(os.path.join(SUMO_HOME, "docs"), os.path.join(installDir, "docs"), ignore=shutil.ignore_patterns('web')) shutil.copy(os.path.join(buildDir, "src", "version.h"), os.path.join(installDir, "include")) status.printLog("Creating sumo.zip.") shutil.make_archive(binaryZip, 'zip', buildDir, installBase) shutil.copy(binaryZip + ".zip", options.remoteDir) status.printLog("Creating sumo.msi.") if options.suffix == "extra": wix.buildMSI(binaryZip + ".zip", binaryZip + ".msi", license=os.path.join(SUMO_HOME, "build", "wix", "gpl-2.0.rtf")) else: wix.buildMSI(binaryZip + ".zip", binaryZip + ".msi") shutil.copy(binaryZip + ".msi", options.remoteDir) except Exception as ziperr: status.printLog("Warning: Could not zip to %s.zip (%s)!" % (binaryZip, ziperr)) gameZip = os.path.join(buildDir, "sumo-game-%s%s-%s.zip" % (plat, options.suffix, installBase[5:])) status.printLog("Creating sumo-game.zip.") try: status.log_subprocess(["cmake", "--build", ".", "--target", "game"], cwd=buildDir) shutil.move(os.path.join(buildDir, "sumo-game.zip"), gameZip) shutil.copy(gameZip, options.remoteDir) except Exception as e: status.printLog("Warning: Could not create nightly sumo-game.zip! (%s)" % e) debug_handler = status.set_rotating_log(makeAllLog, log_handler) ret = status.log_subprocess(["cmake", "--build", ".", "--config", "Debug"], cwd=buildDir) if ret == 0: debugZip = os.path.join(buildDir, "sumo-%s%sDebug-%s.zip" % (plat, options.suffix, installBase[5:])) status.printLog("Creating sumoDebug.zip.") try: with zipfile.ZipFile(debugZip, 'w', zipfile.ZIP_DEFLATED) as zipf: for ext in ("*D.exe", "*.dll", "*D.pdb"): for f in glob.glob(os.path.join(SUMO_HOME, "bin", ext)): zipf.write(f, os.path.join(installBase, "bin", os.path.basename(f))) shutil.copy(debugZip, options.remoteDir) except IOError as ziperr: status.printLog("Warning: Could not zip to %s (%s)!" % (debugZip, ziperr)) log_handler = status.set_rotating_log(testLog, debug_handler) status.printLog("Running tests.") runTests(options, env, gitrev) with open(statusLog, 'w') as log: status.printStatus(makeLog, makeAllLog, env["SMTP_SERVER"], log, testLog=testLog) if not options.x64only: debug_handler = status.set_rotating_log(testDebugLog, log_handler) status.printLog("Running debug tests.") runTests(options, env, gitrev, "D") with open(prefix + "Dstatus.log", 'w') as log: status.printStatus(makeAllLog, testDebugLog, env["SMTP_SERVER"], log, testLog=testDebugLog)
"--tests-dir", dest="testsDir", default=r"git\tests", help="directory containg the tests, relative to the root dir") optParser.add_option("-m", "--remote-dir", dest="remoteDir", default="S:\\daily", help="directory to move the results to") optParser.add_option("-p", "--python", help="path to python interpreter to use") (options, args) = optParser.parse_args() env = os.environ if "SUMO_HOME" not in env: env["SUMO_HOME"] = os.path.dirname( os.path.dirname(os.path.dirname(__file__))) env["PYTHON"] = "python" env["SMTP_SERVER"] = "smtprelay.dlr.de" msvcVersion = "msvc12" platform = "x64" env["FILEPREFIX"] = msvcVersion + options.suffix + platform prefix = os.path.join(options.remoteDir, env["FILEPREFIX"]) testLog = prefix + "NeteditTest.log" gitrev = sumolib.version.gitDescribe() with open(testLog, 'a') as log: status.printLog("Running tests.", log) runTests(options, env, gitrev, log)
optParser = optparse.OptionParser() optParser.add_option("-r", "--root-dir", dest="rootDir", default=r"D:\Sumo", help="root for git and log output") optParser.add_option("-s", "--suffix", default="", help="suffix to the fileprefix") optParser.add_option("-b", "--bin-dir", dest="binDir", default=r"git\bin", help="directory containg the binaries, relative to the root dir") optParser.add_option("-t", "--tests-dir", dest="testsDir", default=r"git\tests", help="directory containg the tests, relative to the root dir") optParser.add_option("-m", "--remote-dir", dest="remoteDir", default="S:\\daily", help="directory to move the results to") optParser.add_option("-p", "--python", help="path to python interpreter to use") (options, args) = optParser.parse_args() env = os.environ if "SUMO_HOME" not in env: env["SUMO_HOME"] = os.path.dirname( os.path.dirname(os.path.dirname(__file__))) env["PYTHON"] = "python" env["SMTP_SERVER"] = "smtprelay.dlr.de" msvcVersion = "msvc16" platform = "x64" env["FILEPREFIX"] = msvcVersion + options.suffix + platform prefix = os.path.join(options.remoteDir, env["FILEPREFIX"]) gitrev = sumolib.version.gitDescribe() status.set_rotating_log(prefix + "NeteditTest.log") status.printLog("Running tests.") runTests(options, env, gitrev)