1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201 |
- using StringTools;
- import yaml.*;
- import sys.*;
- import sys.io.*;
- import haxe.*;
- import haxe.io.*;
- private typedef TravisConfig = {
- before_install: Array<String>,
- script: Array<String>
- }
- /**
- List of "TEST" defined in the "matrix" section of ".travis.yml".
- */
- @:enum abstract TEST(String) from String {
- var Macro = "macro";
- var Neko = "neko";
- var Js = "js";
- var Lua = "lua";
- var Php = "php";
- var Cpp = "cpp";
- var Flash9 = "flash9";
- var As3 = "as3";
- var Java = "java";
- var Cs = "cs";
- var Python = "python";
- var Hl = "hl";
- var ThirdParty = "third-party";
- }
- enum Ci {
- TravisCI;
- AppVeyor;
- }
- enum Failure {
- Fail;
- }
- /**
- Will be run by CI services, currently TravisCI and AppVeyor.
- TravisCI:
- Setting file: ".travis.yml".
- Build result: https://travis-ci.org/HaxeFoundation/haxe
- AppVeyor:
- Setting file: "appveyor.yml".
- Build result: https://ci.appveyor.com/project/HaxeFoundation/haxe
- */
- class RunCi {
- static function successMsg(msg:String):Void {
- Sys.println('\x1b[32m' + msg + '\x1b[0m');
- }
- static function failMsg(msg:String):Void {
- Sys.println('\x1b[31m' + msg + '\x1b[0m');
- }
- static function infoMsg(msg:String):Void {
- Sys.println('\x1b[36m' + msg + '\x1b[0m');
- }
- static function fail():Void {
- success = false;
- throw Fail;
- }
- /**
- Run a command using `Sys.command()`.
- If the command exits with non-zero code, exit the whole script with the same code.
- If `useRetry` is `true`, the command will be re-run if it exits with non-zero code (3 trials).
- It is useful for running network-dependent commands.
- */
- static function runCommand(cmd:String, ?args:Array<String>, useRetry:Bool = false, allowFailure:Bool = false):Void {
- var trials = useRetry ? 3 : 1;
- var exitCode:Int = 1;
- var cmdStr = cmd + (args == null ? '' : ' $args');
- while (trials-->0) {
- Sys.println('Command: $cmdStr');
- var t = Timer.stamp();
- exitCode = Sys.command(cmd, args);
- var dt = Math.round(Timer.stamp() - t);
- if (exitCode == 0)
- successMsg('Command exited with $exitCode in ${dt}s: $cmdStr');
- else
- failMsg('Command exited with $exitCode in ${dt}s: $cmdStr');
- if (exitCode == 0) {
- return;
- } else if (trials > 0) {
- Sys.println('Command will be re-run...');
- }
- }
- if (!allowFailure)
- fail();
- }
- static function isAptPackageInstalled(aptPackage:String):Bool {
- return commandSucceed("dpkg-query", ["-W", "-f='${Status}'", aptPackage]);
- }
- static function requireAptPackages(packages:Array<String>):Void {
- var notYetInstalled = [for (p in packages) if (!isAptPackageInstalled(p)) p];
- if (notYetInstalled.length > 0)
- runCommand("sudo", ["apt-get", "install", "-y"].concat(notYetInstalled), true);
- }
- static function haxelibInstallGit(account:String, repository:String, ?branch:String, ?srcPath:String, useRetry:Bool = false, ?altName:String):Void {
- var name:String = (altName == null) ? repository : altName;
- try {
- getHaxelibPath(name);
- infoMsg('$name has already been installed.');
- } catch (e:Dynamic) {
- var args:Array<String> = ["git", name, 'https://github.com/$account/$repository'];
- if (branch != null) {
- args.push(branch);
- }
- if (srcPath != null) {
- args.push(srcPath);
- }
- runCommand("haxelib", args, useRetry);
- }
- }
- static function haxelibInstall(library:String):Void {
- try {
- getHaxelibPath(library);
- infoMsg('$library has already been installed.');
- } catch (e:Dynamic) {
- runCommand("haxelib", ["install", library]);
- }
- }
- static function haxelibRun(args:Array<String>, useRetry:Bool = false):Void {
- runCommand("haxelib", ["run"].concat(args), useRetry);
- }
- static function getHaxelibPath(libName:String) {
- var proc = new Process("haxelib", ["path", libName]);
- var result;
- var code = proc.exitCode();
- do {
- result = proc.stdout.readLine();
- if (!result.startsWith("-L")) {
- break;
- }
- } while(true);
- proc.close();
- if (code != 0) {
- throw 'Failed to get haxelib path ($result)';
- }
- return result;
- }
- static function changeDirectory(path:String) {
- Sys.println('Changing directory to $path');
- Sys.setCwd(path);
- }
- static function setupFlashPlayerDebugger():Void {
- var mmcfgPath = switch (systemName) {
- case "Linux":
- Sys.getEnv("HOME") + "/mm.cfg";
- case "Mac":
- "/Library/Application Support/Macromedia/mm.cfg";
- case _:
- throw "unsupported system";
- }
- switch (systemName) {
- case "Linux":
- requireAptPackages([
- "libcurl3:i386", "libglib2.0-0:i386", "libx11-6:i386", "libxext6:i386",
- "libxt6:i386", "libxcursor1:i386", "libnss3:i386", "libgtk2.0-0:i386"
- ]);
- runCommand("wget", ["-nv", "http://fpdownload.macromedia.com/pub/flashplayer/updaters/11/flashplayer_11_sa_debug.i386.tar.gz"], true);
- runCommand("tar", ["-xf", "flashplayer_11_sa_debug.i386.tar.gz", "-C", Sys.getEnv("HOME")]);
- File.saveContent(mmcfgPath, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
- runCommand(Sys.getEnv("HOME") + "/flashplayerdebugger", ["-v"]);
- case "Mac":
- runCommand("brew", ["cask", "install", "flash-player-debugger"]);
- var dir = Path.directory(mmcfgPath);
- runCommand("sudo", ["mkdir", "-p", dir]);
- runCommand("sudo", ["chmod", "a+w", dir]);
- File.saveContent(mmcfgPath, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
- }
- }
- /**
- Run a Flash swf file.
- Return whether the test is successful or not.
- It detemines the test result by reading the flashlog.txt, looking for "SUCCESS: true".
- */
- static function runFlash(swf:String):Bool {
- swf = FileSystem.fullPath(swf);
- Sys.println('going to run $swf');
- switch (systemName) {
- case "Linux":
- new Process(Sys.getEnv("HOME") + "/flashplayerdebugger", [swf]);
- case "Mac":
- Sys.command("open", ["-a", "/Applications/Flash Player Debugger.app", swf]);
- }
- //wait a little until flashlog.txt is created
- var flashlogPath = switch (systemName) {
- case "Linux":
- Sys.getEnv("HOME") + "/.macromedia/Flash_Player/Logs/flashlog.txt";
- case "Mac":
- Sys.getEnv("HOME") + "/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt";
- case _:
- throw "unsupported system";
- }
- for (t in 0...5) {
- runCommand("sleep", ["2"]);
- if (FileSystem.exists(flashlogPath))
- break;
- }
- if (!FileSystem.exists(flashlogPath)) {
- failMsg('$flashlogPath not found.');
- return false;
- }
- //read flashlog.txt continously
- var traceProcess = new Process("tail", ["-f", flashlogPath]);
- var line = "";
- while (true) {
- try {
- line = traceProcess.stdout.readLine();
- Sys.println(line);
- if (line.indexOf("SUCCESS: ") >= 0) {
- return line.indexOf("SUCCESS: true") >= 0;
- }
- } catch (e:haxe.io.Eof) {
- break;
- }
- }
- return false;
- }
- static function runCs(exe:String, ?args:Array<String>):Void {
- if (args == null) args = [];
- exe = FileSystem.fullPath(exe);
- switch (systemName) {
- case "Linux", "Mac":
- runCommand("mono", [exe].concat(args));
- case "Windows":
- runCommand(exe, args);
- switch (ci) {
- case AppVeyor:
- // https://github.com/HaxeFoundation/haxe/issues/4873
- // runCommand("mono", [exe].concat(args));
- case _:
- //pass
- }
- }
- }
- static function runCpp(bin:String, ?args:Array<String>):Void {
- if (args == null) args = [];
- bin = FileSystem.fullPath(bin);
- runCommand(bin, args);
- }
- static function parseCommand(cmd:String) {
- var args = [];
- var offset = 0;
- var cur = new StringBuf();
- var inString = false;
- while(true) {
- switch(cmd.fastCodeAt(offset++)) {
- case '"'.code:
- inString = !inString;
- case ' '.code if (!inString):
- if (cur.length > 0) {
- args.push(cur.toString());
- cur = new StringBuf();
- }
- case '\\'.code:
- cur.addChar(cmd.fastCodeAt(offset++));
- case "$".code:
- switch (cmd.fastCodeAt(offset)) {
- case '('.code:
- ++offset;
- var env = new StringBuf();
- while(true) {
- switch(cmd.fastCodeAt(offset++)) {
- case ')'.code:
- break;
- case c:
- env.addChar(c);
- }
- }
- cur.add(Sys.getEnv(env.toString()));
- case _:
- cur.addChar("$".code);
- }
- case c:
- cur.addChar(c);
- }
- if (offset == cmd.length) {
- break;
- }
- }
- if (cur.length > 0) {
- args.push(cur.toString());
- }
- return args;
- }
- //static function parseTravisFile(path:String, ignoreBeforeInstall = false) {
- //var yaml:TravisConfig = yaml.Yaml.read(path, Parser.options().useObjects());
- //if (!ignoreBeforeInstall) {
- //for (code in yaml.before_install) {
- //var args = parseCommand(code);
- //var cmd = args.shift();
- //runCommand(cmd, args);
- //}
- //}
- //for (code in yaml.script) {
- //var args = parseCommand(code);
- //var cmd = args.shift();
- //runCommand(cmd, args);
- //}
- //}
- static function commandSucceed(cmd:String, args:Array<String>):Bool {
- return try {
- var p = new Process(cmd, args);
- var succeed = p.exitCode() == 0;
- p.close();
- succeed;
- } catch(e:Dynamic) false;
- }
- static function commandResult(cmd:String, args:Array<String>):{
- stdout:String,
- stderr:String,
- exitCode:Int
- } {
- var p = new Process(cmd, args);
- var out = {
- stdout: p.stdout.readAll().toString(),
- stderr: p.stderr.readAll().toString(),
- exitCode: p.exitCode()
- }
- p.close();
- return out;
- }
- static function addToPATH(path:String):Void {
- switch (systemName) {
- case "Windows":
- Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" + path);
- case "Mac", "Linux":
- Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + path);
- }
- }
- static function getPhpDependencies() {
- switch (systemName) {
- case "Linux":
- var phpCmd = commandResult("php", ["-v"]);
- var phpVerReg = ~/PHP ([0-9]+\.[0-9]+)/i;
- var phpVer = if (phpVerReg.match(phpCmd.stdout))
- Std.parseFloat(phpVerReg.matched(1));
- else
- null;
- if (phpCmd.exitCode == 0 && phpVer != null && phpVer >= 5.5) {
- infoMsg('php has already been installed.');
- } else {
- requireAptPackages(["php5-cli", "php5-mysql", "php5-sqlite"]);
- }
- case "Mac":
- //pass
- case "Windows":
- if (commandSucceed("php", ["-v"])) {
- infoMsg('php has already been installed.');
- } else {
- runCommand("cinst", ["php", "-version", "5.6.3", "-y"], true);
- addToPATH("C:\\tools\\php");
- }
- }
- runCommand("php", ["-v"]);
- }
- static var gotCppDependencies = false;
- static function getCppDependencies() {
- if (gotCppDependencies) return;
- //hxcpp dependencies
- switch (systemName) {
- case "Linux":
- requireAptPackages(["gcc-multilib", "g++-multilib"]);
- case "Mac":
- //pass
- }
- //install and build hxcpp
- try {
- getHaxelibPath("hxcpp");
- infoMsg('hxcpp has already been installed.');
- } catch(e:Dynamic) {
- haxelibInstallGit("HaxeFoundation", "hxcpp", true);
- var oldDir = Sys.getCwd();
- changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/");
- runCommand("haxe", ["compile.hxml"]);
- changeDirectory(oldDir);
- }
- gotCppDependencies = true;
- }
- static function getJavaDependencies() {
- haxelibInstallGit("HaxeFoundation", "hxjava", true);
- runCommand("javac", ["-version"]);
- }
- static function getJSDependencies() {
- switch (systemName) {
- case "Linux":
- if (commandSucceed("node", ["-v"])) {
- infoMsg('node has already been installed.');
- } else {
- requireAptPackages(["nodejs"]);
- }
- case "Mac":
- //pass
- }
- runCommand("node", ["-v"]);
- }
- static function getLuaDependencies(jit = false, lua_version = "lua5.2", luarocks_version = "2.3.0") {
- switch (systemName){
- case "Linux": requireAptPackages(["libpcre3-dev"]);
- case "Mac": runCommand("brew", ["install", "pcre"]);
- }
- var home_dir = Sys.getEnv("HOME");
- // the lua paths created by the setup script.
- addToPATH('$home_dir/.lua');
- addToPATH('$home_dir/.local/bin');
- // we need to cd back into the build directory to do some work
- var build_dir = Sys.getEnv("TRAVIS_BUILD_DIR");
- changeDirectory(build_dir);
- // luarocks needs to be in the path
- addToPATH('$build_dir/install/luarocks/bin');
- if (jit) Sys.putEnv("LUAJIT","yes");
- Sys.putEnv("LUAROCKS", luarocks_version);
- Sys.putEnv("LUA", lua_version);
- // use the helper scripts in .travis. TODO: Refactor as pure haxe?
- runCommand("sh", ['${build_dir}/.travis/setenv_lua.sh']);
- if (jit){
- runCommand("luajit", ["-v"]);
- } else {
- runCommand("lua", ["-v"]);
- }
- runCommand("pip", ["install", "--user", "cpp-coveralls"]);
- runCommand("luarocks", ["install", "lrexlib-pcre", "2.7.2-1", "--server=https://luarocks.org/dev"]);
- runCommand("luarocks", ["install", "luautf8", "--server=https://luarocks.org/dev"]);
- // we did user land installs of luarocks and lua. We need to point lua
- // to the luarocks install using the luarocks path and env variables
- var lua_path = commandResult("luarocks", ["path", "--lr-path"]).stdout.trim();
- Sys.putEnv("LUA_PATH", lua_path);
- trace(lua_path + " is the value for lua_path");
- // step two of the variable setting
- var lua_cpath = commandResult("luarocks", ["path", "--lr-cpath"]).stdout.trim();
- Sys.putEnv("LUA_CPATH", lua_cpath);
- trace(lua_cpath + " is the value for lua_cpath");
- // change back to the unit dir for the rest of the tests
- changeDirectory(unitDir);
- }
- static function getCsDependencies() {
- switch (systemName) {
- case "Linux":
- if (commandSucceed("mono", ["--version"]))
- infoMsg('mono has already been installed.');
- else
- requireAptPackages(["mono-devel", "mono-mcs"]);
- runCommand("mono", ["--version"]);
- case "Mac":
- if (commandSucceed("mono", ["--version"]))
- infoMsg('mono has already been installed.');
- else
- runCommand("brew", ["install", "mono"], true);
- runCommand("mono", ["--version"]);
- case "Windows":
- switch (ci) {
- case AppVeyor:
- addToPATH("C:\\Program Files (x86)\\Mono\\bin");
- runCommand("mono", ["--version"]);
- case _:
- //pass
- }
- }
- haxelibInstallGit("HaxeFoundation", "hxcs", true);
- }
- static var gotOpenFLDependencies = false;
- static function getOpenFLDependencies() {
- if (gotOpenFLDependencies) return;
- getCppDependencies();
- haxelibInstallGit("HaxeFoundation", "format");
- haxelibInstallGit("haxenme", "nme");
- haxelibInstallGit("haxenme", "nme-dev");
- haxelibInstallGit("openfl", "svg");
- haxelibInstallGit("openfl", "lime");
- haxelibInstallGit("openfl", "lime-tools");
- haxelibInstallGit("openfl", "openfl-native");
- haxelibInstallGit("openfl", "openfl-html5");
- haxelibInstallGit("openfl", "openfl");
- switch (systemName) {
- case "Linux":
- haxelibRun(["openfl", "rebuild", "linux"]);
- case "Mac":
- haxelibRun(["openfl", "rebuild", "mac"]);
- }
- haxelibRun(["openfl", "rebuild", "tools"]);
- gotOpenFLDependencies = true;
- }
- /**
- Install python and return the names of the installed pythons.
- */
- static function getPythonDependencies():Array<String> {
- switch (systemName) {
- case "Linux":
- if (commandSucceed("python3", ["-V"]))
- infoMsg('python3 has already been installed.');
- else
- requireAptPackages(["python3"]);
- runCommand("python3", ["-V"]);
- var pypy = "pypy3";
- if (commandSucceed(pypy, ["-V"])) {
- infoMsg('pypy3 has already been installed.');
- } else {
- var pypyVersion = "pypy3-2.4.0-linux64";
- runCommand("wget", ['https://bitbucket.org/pypy/pypy/downloads/${pypyVersion}.tar.bz2'], true);
- runCommand("tar", ["-xf", '${pypyVersion}.tar.bz2']);
- pypy = FileSystem.fullPath('${pypyVersion}/bin/pypy3');
- }
- runCommand(pypy, ["-V"]);
- return ["python3", pypy];
- case "Mac":
- if (commandSucceed("python3", ["-V"]))
- infoMsg('python3 has already been installed.');
- else
- runCommand("brew", ["install", "python3"], true);
- runCommand("python3", ["-V"]);
- if (commandSucceed("pypy3", ["-V"]))
- infoMsg('pypy3 has already been installed.');
- else
- runCommand("brew", ["install", "pypy3"], true);
- runCommand("pypy3", ["-V"]);
- return ["python3", "pypy3"];
- case "Windows":
- if (commandSucceed("python3", ["-V"]))
- infoMsg('python3 has already been installed.');
- else
- throw "please install python 3.x and make it available as python3 in PATH";
- runCommand("python3", ["-V"]);
- return ["python3"];
- }
- return [];
- }
- static var ci(default, never):Null<Ci> =
- if (Sys.getEnv("TRAVIS") == "true")
- TravisCI;
- else if (Sys.getEnv("APPVEYOR") == "True")
- AppVeyor;
- else
- null;
- static var systemName(default, never) = Sys.systemName();
- static var cwd(default, never) = Sys.getCwd();
- static var repoDir(default, never) = FileSystem.fullPath("..") + "/";
- static var unitDir(default, never) = cwd + "unit/";
- static var sysDir(default, never) = cwd + "sys/";
- static var optDir(default, never) = cwd + "optimization/";
- static var miscDir(default, never) = cwd + "misc/";
- static var displayDir(default, never) = cwd + "display/";
- static var gitInfo(get, null):{repo:String, branch:String, commit:String, timestamp:Float, date:String};
- static var success(default, null) = true;
- static function get_gitInfo() return if (gitInfo != null) gitInfo else gitInfo = {
- repo: switch (ci) {
- case TravisCI:
- Sys.getEnv("TRAVIS_REPO_SLUG");
- case AppVeyor:
- Sys.getEnv("APPVEYOR_PROJECT_SLUG");
- case _:
- commandResult("git", ["config", "--get", "remote.origin.url"]).stdout.trim();
- },
- branch: switch (ci) {
- case TravisCI:
- Sys.getEnv("TRAVIS_BRANCH");
- case AppVeyor:
- Sys.getEnv("APPVEYOR_REPO_BRANCH");
- case _:
- commandResult("git", ["rev-parse", "--abbrev-ref", "HEAD"]).stdout.trim();
- },
- commit: commandResult("git", ["rev-parse", "HEAD"]).stdout.trim(),
- timestamp: Std.parseFloat(commandResult("git", ["show", "-s", "--format=%ct", "HEAD"]).stdout),
- date: {
- var gitTime = commandResult("git", ["show", "-s", "--format=%ct", "HEAD"]).stdout;
- var tzd = {
- var z = Date.fromTime(0);
- z.getHours() * 60 * 60 * 1000 + z.getMinutes() * 60 * 1000;
- }
- // make time in the UTC time zone
- var time = Date.fromTime(Std.parseFloat(gitTime) * 1000 - tzd);
- DateTools.format(time, "%FT%TZ");
- }
- }
- static var haxeVer(default, never) = {
- var haxe_ver = haxe.macro.Compiler.getDefine("haxe_ver");
- switch (haxe_ver.split(".")) {
- case [major]:
- major;
- case [major, minor] if (minor.length == 1):
- '${major}.${minor}';
- case [major, minor] if (minor.length > 1):
- var minor = minor.charAt(0);
- var patch = Std.parseInt(minor.substr(1));
- '${major}.${minor}.${patch}';
- case _:
- throw haxe_ver;
- }
- }
- static var haxeVerFull(default, never) = {
- var ver = haxeVer.split(".");
- while (ver.length < 3) {
- ver.push("0");
- }
- ver.join(".");
- }
- static function deploy():Void {
- if (
- Sys.getEnv("DEPLOY") != null
- ) {
- changeDirectory(repoDir);
- // generate doc
- runCommand("make", ["-s", "install_dox"]);
- runCommand("make", ["-s", "package_doc"]);
- // deployBintray();
- deployApiDoc();
- deployPPA();
- }
- }
- static function deployBintray():Void {
- if (
- Sys.getEnv("BINTRAY") != null &&
- Sys.getEnv("BINTRAY_USERNAME") != null &&
- Sys.getEnv("BINTRAY_API_KEY") != null
- ) {
- // generate bintray config
- var tpl = new Template(File.getContent("extra/bintray.tpl.json"));
- var compatDate = ~/[^0-9]/g.replace(gitInfo.date, "");
- var json = tpl.execute({
- packageSubject: {
- var sub = Sys.getEnv("BINTRAY_SUBJECT");
- sub != null ? sub : Sys.getEnv("BINTRAY_USERNAME");
- },
- os: systemName.toLowerCase(),
- versionName: '${haxeVer}+${compatDate}.${gitInfo.commit.substr(0,7)}',
- versionDesc: "Automated CI build.",
- gitRepo: gitInfo.repo,
- gitBranch: gitInfo.branch,
- gitCommit: gitInfo.commit,
- gitDate: gitInfo.date,
- });
- var path = "extra/bintray.json";
- File.saveContent("extra/bintray.json", json);
- infoMsg("saved " + FileSystem.absolutePath(path) + " with content:");
- Sys.println(json);
- }
- }
- /**
- Deploy doc to api.haxe.org.
- */
- static function deployApiDoc():Void {
- if (
- gitInfo.branch == "development" &&
- Sys.getEnv("DEPLOY") != null &&
- Sys.getEnv("deploy_key_decrypt") != null
- ) {
- // setup deploy_key
- runCommand("openssl aes-256-cbc -k \"$deploy_key_decrypt\" -in extra/deploy_key.enc -out extra/deploy_key -d");
- runCommand("chmod 600 extra/deploy_key");
- runCommand("ssh-add extra/deploy_key");
- runCommand("make", ["-s", "deploy_doc"]);
- }
- }
- /**
- Deploy source package to ppa:haxe/snapshots.
- */
- static function deployPPA():Void {
- if (
- gitInfo.branch == "development" &&
- Sys.getEnv("DEPLOY") != null &&
- Sys.getEnv("haxeci_decrypt") != null
- ) {
- // setup deb info
- runCommand("git config --global user.name \"${DEBFULLNAME}\"");
- runCommand("git config --global user.email \"${DEBEMAIL}\"");
- // setup haxeci_ssh
- runCommand("openssl aes-256-cbc -k \"$haxeci_decrypt\" -in extra/haxeci_ssh.enc -out extra/haxeci_ssh -d");
- runCommand("chmod 600 extra/haxeci_ssh");
- runCommand("ssh-add extra/haxeci_ssh");
- // setup haxeci_sec.gpg
- runCommand("openssl aes-256-cbc -k \"$haxeci_decrypt\" -in extra/haxeci_sec.gpg.enc -out extra/haxeci_sec.gpg -d");
- runCommand("gpg --allow-secret-key-import --import extra/haxeci_sec.gpg");
- runCommand("sudo apt-get install devscripts git-buildpackage ubuntu-dev-tools dh-make -y");
- var compatDate = ~/[^0-9]/g.replace(gitInfo.date, "");
- var SNAPSHOT_VERSION = '${haxeVerFull}+1SNAPSHOT${compatDate}+${gitInfo.commit.substr(0,7)}';
- runCommand('cp out/haxe*_src.tar.gz "../haxe_${SNAPSHOT_VERSION}.orig.tar.gz"');
- changeDirectory("..");
- runCommand("git clone https://github.com/HaxeFoundation/haxe-debian.git");
- changeDirectory("haxe-debian");
- runCommand("git checkout upstream");
- runCommand("git checkout next");
- runCommand('gbp import-orig "../haxe_${SNAPSHOT_VERSION}.orig.tar.gz" -u "${SNAPSHOT_VERSION}" --debian-branch=next');
- runCommand('dch -v "1:${SNAPSHOT_VERSION}-1" --urgency low "snapshot build"');
- runCommand("debuild -S -sa");
- runCommand("backportpackage -d xenial --upload ${PPA} --yes ../haxe_*.dsc");
- runCommand("backportpackage -d wily --upload ${PPA} --yes ../haxe_*.dsc");
- runCommand("backportpackage -d vivid --upload ${PPA} --yes ../haxe_*.dsc");
- runCommand("backportpackage -d trusty --upload ${PPA} --yes ../haxe_*.dsc");
- runCommand("git checkout debian/changelog");
- runCommand("git merge -X ours --no-edit origin/next-precise");
- runCommand('dch -v "1:${SNAPSHOT_VERSION}-1" --urgency low "snapshot build"');
- runCommand("debuild -S -sa");
- runCommand("backportpackage -d precise --upload ${PPA} --yes ../haxe_*.dsc");
- }
- }
- static function main():Void {
- Sys.putEnv("OCAMLRUNPARAM", "b");
- var tests:Array<TEST> = switch (Sys.getEnv("TEST")) {
- case null:
- [Macro];
- case env:
- [for (v in env.split(",")) v.trim().toLowerCase()];
- }
- Sys.println('Going to test: $tests');
- for (test in tests) {
- switch (ci) {
- case TravisCI:
- Sys.println('travis_fold:start:test-${test}');
- case _:
- //pass
- }
- infoMsg('test $test');
- var success = true;
- try {
- changeDirectory(unitDir);
- var args = switch (ci) {
- case TravisCI:
- ["-D","travis"];
- case AppVeyor:
- ["-D","appveyor"];
- case _:
- [];
- }
- switch (test) {
- case Macro:
- runCommand("haxe", ["compile-macro.hxml"].concat(args));
- changeDirectory(displayDir);
- runCommand("haxe", ["build.hxml"]);
- changeDirectory(miscDir);
- getCsDependencies();
- getPythonDependencies();
- runCommand("haxe", ["compile.hxml"]);
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-macro.hxml"]);
- runCommand("haxe", ["compile-each.hxml", "--run", "Main"]);
- case Neko:
- runCommand("haxe", ["compile-neko.hxml", "-D", "dump", "-D", "dump_ignore_var_ids"].concat(args));
- runCommand("neko", ["bin/unit.n"]);
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-neko.hxml"]);
- runCommand("neko", ["bin/neko/sys.n"]);
- case Php:
- getPhpDependencies();
- runCommand("haxe", ["compile-php.hxml"].concat(args));
- runCommand("php", ["bin/php/index.php"]);
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-php.hxml"]);
- runCommand("php", ["bin/php/Main/index.php"]);
- case Python:
- var pys = getPythonDependencies();
- runCommand("haxe", ["compile-python.hxml"].concat(args));
- for (py in pys) {
- runCommand(py, ["bin/unit.py"]);
- }
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-python.hxml"]);
- for (py in pys) {
- runCommand(py, ["bin/python/sys.py"]);
- }
- changeDirectory(miscDir + "pythonImport");
- runCommand("haxe", ["compile.hxml"]);
- for (py in pys) {
- runCommand(py, ["test.py"]);
- }
- case Lua:
- getLuaDependencies();
- runCommand("haxe", ["compile-lua.hxml"].concat(args));
- runCommand("lua", ["bin/unit.lua"]);
- case Cpp:
- getCppDependencies();
- runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M32"].concat(args));
- runCpp("bin/cpp/TestMain-debug", []);
- switch (ci) {
- case AppVeyor:
- //save time...
- case _:
- runCommand("rm", ["-rf", "cpp"]);
- runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"].concat(args));
- runCpp("bin/cpp/TestMain-debug", []);
- runCommand("haxe", ["compile-cppia-host.hxml"]);
- runCommand("haxe", ["compile-cppia.hxml"]);
- runCpp("bin/cppia/Host-debug", ["bin/unit.cppia"]);
- }
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-cpp.hxml"]);
- runCpp("bin/cpp/Main-debug", []);
- // if (Sys.systemName() == "Mac")
- // {
- // changeDirectory(miscDir + "cppObjc");
- // runCommand("haxe", ["build.hxml"]);
- // runCpp("bin/TestObjc-debug");
- // }
- case Js:
- getJSDependencies();
- var jsOutputs = [
- for (es3 in [[], ["-D", "js-es=3"]])
- for (unflatten in [[], ["-D", "js-unflatten"]])
- for (classic in [[], ["-D", "js-classic"]])
- {
- var extras = args.concat(es3).concat(unflatten).concat(classic);
- runCommand("haxe", ["compile-js.hxml"].concat(extras));
- var output = if (extras.length > 0) {
- "bin/js/" + extras.join("") + "/unit.js";
- } else {
- "bin/js/default/unit.js";
- }
- var outputDir = Path.directory(output);
- if (!FileSystem.exists(outputDir)) {
- FileSystem.createDirectory(outputDir);
- }
- FileSystem.rename("bin/unit.js", output);
- FileSystem.rename("bin/unit.js.map", output + ".map");
- runCommand("node", ["-e", "require('./" + output + "').unit.TestMain.nodejsMain();"]);
- output;
- }
- ];
- var env = Sys.environment();
- if (
- env.exists("SAUCE") &&
- env.exists("SAUCE_USERNAME") &&
- env.exists("SAUCE_ACCESS_KEY")
- ) {
- // sauce-connect should have been started
- // var scVersion = "sc-4.3-linux";
- // runCommand("wget", ['https://saucelabs.com/downloads/${scVersion}.tar.gz'], true);
- // runCommand("tar", ["-xf", '${scVersion}.tar.gz']);
- // //start sauce-connect
- // var scReadyFile = "sauce-connect-ready-" + Std.random(100);
- // var sc = new Process('${scVersion}/bin/sc', [
- // "-i", Sys.getEnv("TRAVIS_JOB_NUMBER"),
- // "-f", scReadyFile
- // ]);
- // while(!FileSystem.exists(scReadyFile)) {
- // Sys.sleep(0.5);
- // }
- runCommand("npm", ["install", "wd", "q"], true);
- haxelibInstall("hxnodejs");
- runCommand("haxe", ["compile-saucelabs-runner.hxml"]);
- var server = new Process("nekotools", ["server"]);
- runCommand("node", ["bin/RunSauceLabs.js"].concat([for (js in jsOutputs) "unit-js.html?js=" + js.urlEncode()]));
- server.close();
- // sc.close();
- }
- infoMsg("Test optimization:");
- changeDirectory(optDir);
- runCommand("haxe", ["run.hxml"]);
- case Java:
- getJavaDependencies();
- runCommand("haxe", ["compile-java.hxml"].concat(args));
- runCommand("java", ["-jar", "bin/java/TestMain-Debug.jar"]);
- runCommand("haxe", ["compile-java.hxml","-dce","no"].concat(args));
- runCommand("java", ["-jar", "bin/java/TestMain-Debug.jar"]);
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-java.hxml"]);
- runCommand("java", ["-jar", "bin/java/Main-Debug.jar"]);
- infoMsg("Testing java-lib extras");
- changeDirectory('$unitDir/bin');
- runCommand("git", ["clone", "https://github.com/waneck/java-lib-tests.git", "--depth", "1"], true);
- for (dir in FileSystem.readDirectory('java-lib-tests'))
- {
- var path = 'java-lib-tests/$dir';
- if (FileSystem.isDirectory(path)) for (file in FileSystem.readDirectory(path))
- {
- if (file.endsWith('.hxml'))
- {
- runCommand("haxe", ["--cwd",'java-lib-tests/$dir',file]);
- }
- }
- }
- case Cs:
- getCsDependencies();
- var compl = switch [ci, systemName] {
- case [TravisCI, "Linux"]:
- "-travis";
- case _:
- "";
- };
- for (fastcast in [[], ["-D", "fast_cast"]])
- for (noroot in [[], ["-D", "no_root"]])
- for (erasegenerics in [[], ["-D", "erase_generics"]])
- {
- var extras = fastcast.concat(erasegenerics).concat(noroot);
- runCommand("haxe", ['compile-cs$compl.hxml'].concat(extras));
- runCs("bin/cs/bin/TestMain-Debug.exe");
- runCommand("haxe", ['compile-cs-unsafe$compl.hxml'].concat(extras));
- runCs("bin/cs_unsafe/bin/TestMain-Debug.exe");
- }
- runCommand("haxe", ['compile-cs$compl.hxml','-dce','no']);
- runCs("bin/cs/bin/TestMain-Debug.exe");
- changeDirectory(sysDir);
- runCommand("haxe", ["compile-cs.hxml",'-D','fast_cast']);
- runCs("bin/cs/bin/Main-Debug.exe", []);
- changeDirectory(miscDir + "csTwoLibs");
- for (i in 1...5)
- {
- runCommand("haxe", ['compile-$i.hxml','-D','fast_cast']);
- runCs("bin/main/bin/Main.exe");
- }
- case Flash9:
- setupFlashPlayerDebugger();
- runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb", "-D", "dump", "-D", "dump_ignore_var_ids"].concat(args));
- var success = runFlash("bin/unit9.swf");
- if (!success)
- fail();
- case As3:
- setupFlashPlayerDebugger();
- //setup flex sdk
- if (commandSucceed("mxmlc", ["--version"])) {
- infoMsg('mxmlc has already been installed.');
- } else {
- var flexVersion = "4.14.1";
- runCommand("wget", ['http://archive.apache.org/dist/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true);
- runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]);
- var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin';
- addToPATH(flexsdkPath + "/bin");
- var playerglobalswcFolder = flexsdkPath + "/player";
- FileSystem.createDirectory(playerglobalswcFolder + "/11.1");
- runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true);
- File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder');
- runCommand("mxmlc", ["--version"]);
- }
- runCommand("haxe", ["compile-as3.hxml", "-D", "fdb"].concat(args));
- var success = runFlash("bin/unit9_as3.swf");
- if (!success)
- fail();
- case Hl:
- runCommand("haxe", ["compile-hl.hxml"], false, true);
- case ThirdParty:
- getPhpDependencies();
- getJavaDependencies();
- getJSDependencies();
- getCsDependencies();
- getPythonDependencies();
- getCppDependencies();
- //getOpenFLDependencies();
- //testPolygonalDs();
- // if (systemName == "Linux") testFlambe(); //#3439
- testHxTemplo();
- testMUnit();
- testHaxeQuake();
- //testOpenflSamples();
- //testFlixelDemos();
- case t:
- throw "unknown target: " + t;
- }
- } catch(f:Failure) {
- success = false;
- }
- switch (ci) {
- case TravisCI:
- Sys.println('travis_fold:end:test-${test}');
- case _:
- //pass
- }
- if (success) {
- successMsg('test ${test} succeeded');
- } else {
- failMsg('test ${test} failed');
- }
- }
- if (success) {
- deploy();
- } else {
- Sys.exit(1);
- }
- }
- static function testHxTemplo() {
- infoMsg("Test hx-templo:");
- changeDirectory(unitDir);
- haxelibInstallGit("Simn", "hxparse", "development", "src");
- haxelibInstallGit("Simn", "hxtemplo");
- var buildArgs = [
- "-cp", "src",
- "-cp", "test",
- "-main", "Test",
- "-lib", "hxparse",
- "-dce", "full"
- ];
- changeDirectory(getHaxelibPath("hxtemplo") + "..");
- runCommand("haxe", ["build.hxml"]);
- }
- static function testPolygonalDs() {
- infoMsg("Test polygonal-ds:");
- changeDirectory(unitDir);
- haxelibInstallGit("Simn", "ds", "python-support", null, false, "polygonal-ds");
- haxelibInstallGit("polygonal", "core", "master", "src", false, "polygonal-core");
- haxelibInstallGit("polygonal", "printf", "master", "src", false, "polygonal-printf");
- changeDirectory(getHaxelibPath("polygonal-ds"));
- runCommand("haxe", ["build.hxml"]);
- runCommand("python3", ["unit.py"]);
- runCommand("node", ["unit.js"]);
- }
- static function testMUnit() {
- infoMsg("Test MUnit:");
- changeDirectory(unitDir);
- haxelibInstallGit("massiveinteractive", "mconsole", "master", "src");
- haxelibInstallGit("massiveinteractive", "MassiveCover", "master", "src", false, "mcover");
- haxelibInstallGit("massiveinteractive", "MassiveLib", "master", "src", false, "mlib");
- haxelibInstallGit("massiveinteractive", "MassiveUnit", "2.1.2", "src", false, "munit");
- changeDirectory(Path.join([getHaxelibPath("munit"), "..", "tool"]));
- runCommand("haxe", ["build.hxml"]);
- haxelibRun(["munit", "test", "-result-exit-code", "-neko"], true);
- changeDirectory("../");
- haxelibRun(["munit", "test", "-result-exit-code", "-neko"], true);
- }
- static function testHaxeQuake() {
- infoMsg("Test HaxeQuake:");
- changeDirectory(unitDir);
- runCommand("git", ["clone", "https://github.com/nadako/HaxeQuake"]);
- changeDirectory("HaxeQuake/Client");
- runCommand("haxe", ["build.hxml"]);
- }
- static function testFlambe() {
- infoMsg("Test Flambe:");
- changeDirectory(unitDir);
- runCommand("git", ["clone", "https://github.com/aduros/flambe"]);
- runCommand("sh", ["flambe/bin/run-travis"]);
- }
- //static function testOpenflSamples() {
- //infoMsg("Test OpenFL Samples:");
- //
- //changeDirectory(unitDir);
- //
- //haxelibInstallGit("jgranick", "actuate");
- //haxelibInstallGit("jgranick", "box2d");
- //haxelibInstallGit("jgranick", "layout");
- //haxelibInstallGit("openfl", "swf");
- //haxelibInstallGit("openfl", "openfl-samples");
- //
- //var path = getHaxelibPath("openfl-samples");
- //var old = Sys.getEnv("pwd");
- //Sys.putEnv("pwd", path);
- //parseTravisFile(haxe.io.Path.join([path, ".travis.yml"]), true);
- //if (old != null) {
- //Sys.putEnv("pwd", old);
- //}
- //}
- static function testFlixelDemos() {
- infoMsg("Test Flixel Demos:");
- changeDirectory(unitDir);
- getOpenFLDependencies();
- haxelibInstall("systools");
- haxelibInstall("spinehx");
- haxelibInstall("nape");
- haxelibInstall("task");
- haxelibInstallGit("larsiusprime", "firetongue");
- haxelibInstallGit("YellowAfterLife", "openfl-bitfive");
- haxelibInstallGit("HaxeFlixel", "flixel");
- haxelibInstallGit("HaxeFlixel", "flixel-addons");
- haxelibInstallGit("HaxeFlixel", "flixel-ui");
- haxelibInstallGit("HaxeFlixel", "flixel-demos");
- haxelibInstallGit("HaxeFlixel", "flixel-tools");
- haxelibRun(["flixel-tools", "testdemos", "-flash"]);
- haxelibRun(["flixel-tools", "testdemos", "-neko"]);
- haxelibRun(["flixel-tools", "testdemos", "-html5"]);
- }
- }
|