|
@@ -11,138 +11,232 @@ import runci.System.*;
|
|
import runci.System.CommandFailure;
|
|
import runci.System.CommandFailure;
|
|
import runci.Config.*;
|
|
import runci.Config.*;
|
|
|
|
|
|
|
|
+using StringTools;
|
|
|
|
+
|
|
class Flash {
|
|
class Flash {
|
|
static final miscFlashDir = getMiscSubDir('flash');
|
|
static final miscFlashDir = getMiscSubDir('flash');
|
|
|
|
|
|
static function getLatestFPVersion():Array<Int> {
|
|
static function getLatestFPVersion():Array<Int> {
|
|
- final appcast = Xml.parse(haxe.Http.requestUrl("http://fpdownload2.macromedia.com/get/flashplayer/update/current/xml/version_en_mac_pep.xml"));
|
|
|
|
|
|
+ final appcast = Xml.parse(haxe.Http.requestUrl("http://fpdownload.macromedia.com/get/flashplayer/update/current/xml/version_en_mac_pep.xml"));
|
|
final versionStr = new haxe.xml.Access(appcast).node.XML.node.update.att.version;
|
|
final versionStr = new haxe.xml.Access(appcast).node.XML.node.update.att.version;
|
|
return versionStr.split(",").map(Std.parseInt);
|
|
return versionStr.split(",").map(Std.parseInt);
|
|
}
|
|
}
|
|
|
|
|
|
- static public function setupFlexSdk():Void {
|
|
|
|
|
|
+ static final defaultApacheMirror = "https://downloads.apache.org/";
|
|
|
|
+
|
|
|
|
+ static function getPreferredApacheMirror() {
|
|
|
|
+ return try {
|
|
|
|
+ Json.parse(Http.requestUrl("https://www.apache.org/dyn/closer.lua?as_json=1")).preferred;
|
|
|
|
+ } catch (e) {
|
|
|
|
+ failMsg('Unable to determine preferred Apache mirror. Defaulting to $defaultApacheMirror');
|
|
|
|
+ defaultApacheMirror;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function downloadFlexSdk(version:String, sdkPath:String):Void {
|
|
|
|
+ final apacheMirror = getPreferredApacheMirror();
|
|
|
|
+ if (systemName == "Windows") {
|
|
|
|
+ final zipName = 'apache-flex-sdk-${version}-bin.zip';
|
|
|
|
+ runNetworkCommand("wget", ["-nv", '${apacheMirror}/flex/${version}/binaries/$zipName', "-O", getDownloadPath() + '/$zipName']);
|
|
|
|
+ runCommand("7z", ["x", getDownloadPath() + '/$zipName', "-o" + sdkPath, "-y"]);
|
|
|
|
+ } else {
|
|
|
|
+ final tarName = 'apache-flex-sdk-${version}-bin.tar.gz';
|
|
|
|
+ runNetworkCommand("wget", ["-nv", '${apacheMirror}/flex/${version}/binaries/$tarName', "-O", getDownloadPath() + '/$tarName']);
|
|
|
|
+ runCommand("tar", ["-xf", getDownloadPath() + '/$tarName', "-C", getInstallPath()]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function setupFlexSdk():Void {
|
|
if (commandSucceed("mxmlc", ["--version"])) {
|
|
if (commandSucceed("mxmlc", ["--version"])) {
|
|
infoMsg('mxmlc has already been installed.');
|
|
infoMsg('mxmlc has already been installed.');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // download flex sdk
|
|
|
|
+ final flexVersion = "4.16.0";
|
|
|
|
+ final flexSdkPath = Path.normalize(getInstallPath() + '/apache-flex-sdk-${flexVersion}-bin');
|
|
|
|
+
|
|
|
|
+ if (FileSystem.exists(flexSdkPath)) {
|
|
|
|
+ infoMsg('Flex SDK found at $flexSdkPath');
|
|
|
|
+ } else {
|
|
|
|
+ downloadFlexSdk(flexVersion, flexSdkPath);
|
|
|
|
+ }
|
|
|
|
+ addToPATH(flexSdkPath + "/bin");
|
|
|
|
+
|
|
|
|
+ // download playerglobal.swc
|
|
|
|
+ final playerGlobalSwcFolder = flexSdkPath + "/player";
|
|
|
|
+ FileSystem.createDirectory(playerGlobalSwcFolder + "/11.1");
|
|
|
|
+ final flashVersion = getLatestFPVersion();
|
|
|
|
+
|
|
|
|
+ final playerGlobalSwcPath = playerGlobalSwcFolder + "/11.1/playerglobal.swc";
|
|
|
|
+
|
|
|
|
+ if (FileSystem.exists(playerGlobalSwcPath)) {
|
|
|
|
+ infoMsg('playerglobal.swc found at $playerGlobalSwcPath');
|
|
} else {
|
|
} else {
|
|
- var apacheMirror = Json.parse(Http.requestUrl("http://www.apache.org/dyn/closer.lua?as_json=1")).preferred;
|
|
|
|
- var flexVersion = "4.16.0";
|
|
|
|
- runNetworkCommand("wget", ["-nv", '${apacheMirror}/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz']);
|
|
|
|
- runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", getDownloadPath()]);
|
|
|
|
- var flexsdkPath = getDownloadPath() + '/apache-flex-sdk-${flexVersion}-bin';
|
|
|
|
- addToPATH(flexsdkPath + "/bin");
|
|
|
|
- var playerglobalswcFolder = flexsdkPath + "/player";
|
|
|
|
- FileSystem.createDirectory(playerglobalswcFolder + "/11.1");
|
|
|
|
- var flashVersion = runci.targets.Flash.getLatestFPVersion();
|
|
|
|
- runNetworkCommand("wget", ["-nv", 'http://download.macromedia.com/get/flashplayer/updaters/${flashVersion[0]}/playerglobal${flashVersion[0]}_${flashVersion[1]}.swc', "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"]);
|
|
|
|
- File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder');
|
|
|
|
- runCommand("mxmlc", ["--version"]);
|
|
|
|
|
|
+ runNetworkCommand("wget", [
|
|
|
|
+ "-nv",
|
|
|
|
+ 'https://fpdownload.macromedia.com/get/flashplayer/updaters/${flashVersion[0]}/playerglobal${flashVersion[0]}_${flashVersion[1]}.swc',
|
|
|
|
+ "-O",
|
|
|
|
+ playerGlobalSwcPath
|
|
|
|
+ ]);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ // set playerglobal.swc
|
|
|
|
+ File.saveContent(flexSdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerGlobalSwcFolder');
|
|
|
|
+
|
|
|
|
+ // ensure flex sdk is working
|
|
|
|
+ runCommand("mxmlc", ["--version"]);
|
|
}
|
|
}
|
|
|
|
|
|
- static public var playerCmd:String;
|
|
|
|
|
|
+ static var playerLocation:String;
|
|
|
|
+ static var flashlogPath:String;
|
|
|
|
|
|
- static public function setupFlashPlayerDebugger():Void {
|
|
|
|
- var mmcfgPath = switch (systemName) {
|
|
|
|
- case "Linux":
|
|
|
|
- Sys.getEnv("HOME") + "/mm.cfg";
|
|
|
|
- case "Mac":
|
|
|
|
- "/Library/Application Support/Macromedia/mm.cfg";
|
|
|
|
|
|
+ static function createConfigFile(location:String):Void {
|
|
|
|
+ final mmcfgPath = location + "/mm.cfg";
|
|
|
|
+ if (!FileSystem.exists(mmcfgPath))
|
|
|
|
+ File.saveContent(mmcfgPath, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function setupFlashDebuggerMac():Void {
|
|
|
|
+ playerLocation = getInstallPath() + "/Flash Player.app";
|
|
|
|
+ flashlogPath = Sys.getEnv("HOME") + "/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt";
|
|
|
|
+
|
|
|
|
+ if (FileSystem.exists(playerLocation))
|
|
|
|
+ infoMsg('Flash player found at $playerLocation');
|
|
|
|
+ else {
|
|
|
|
+ final majorVersion = getLatestFPVersion()[0];
|
|
|
|
+ final packageName = "flashplayer_32_sa_debug.dmg";
|
|
|
|
+ runNetworkCommand("wget", [
|
|
|
|
+ "-nv",
|
|
|
|
+ 'https://fpdownload.macromedia.com/pub/flashplayer/updaters/${majorVersion}/$packageName',
|
|
|
|
+ "-O",
|
|
|
|
+ getDownloadPath() + '/$packageName'
|
|
|
|
+ ]);
|
|
|
|
+ runCommand("hdiutil", ["attach", getDownloadPath() + '/$packageName']);
|
|
|
|
+
|
|
|
|
+ runCommand("cp", ["-R", "/Volumes/Flash Player/Flash Player.app", getInstallPath()]);
|
|
|
|
+ runCommand("hdiutil", ["detach", "/Volumes/Flash Player"]);
|
|
|
|
+
|
|
|
|
+ // Disable the "application downloaded from Internet" warning
|
|
|
|
+ runCommand("xattr", ["-d", "-r", "com.apple.quarantine", playerLocation]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final configLocation = "/Library/Application Support/Macromedia";
|
|
|
|
+ if (!FileSystem.exists(configLocation)) {
|
|
|
|
+ runCommand("sudo", ["mkdir", "-p", configLocation]);
|
|
|
|
+ runCommand("sudo", ["chmod", "a+w", configLocation]);
|
|
|
|
+ }
|
|
|
|
+ createConfigFile(configLocation);
|
|
|
|
+
|
|
|
|
+ runCommand("open", ["-a", playerLocation, "-v"]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function setupFlashDebuggerLinux():Void {
|
|
|
|
+ flashlogPath = Sys.getEnv("HOME") + "/.macromedia/Flash_Player/Logs/flashlog.txt";
|
|
|
|
+
|
|
|
|
+ final debuggerName = "flashplayerdebugger";
|
|
|
|
+ playerLocation = Path.join([getInstallPath(), debuggerName]);
|
|
|
|
+ if (Sys.command("type", [debuggerName]) == 0) {
|
|
|
|
+ playerLocation = debuggerName;
|
|
|
|
+ infoMsg('Using $debuggerName from PATH');
|
|
|
|
+ } else if(FileSystem.exists(playerLocation)) {
|
|
|
|
+ infoMsg('Flash player found at $playerLocation');
|
|
|
|
+ } else {
|
|
|
|
+ Linux.requireAptPackages(["libglib2.0-0", "libfreetype6"]);
|
|
|
|
+ final majorVersion = getLatestFPVersion()[0];
|
|
|
|
+ final tarFileName = 'flash_player_sa_linux_debug.x86_64.tar.gz';
|
|
|
|
+ runNetworkCommand("wget", [
|
|
|
|
+ "-nv",
|
|
|
|
+ 'https://fpdownload.macromedia.com/pub/flashplayer/updaters/${majorVersion}/$tarFileName',
|
|
|
|
+ "-O",
|
|
|
|
+ getDownloadPath() + '/$tarFileName'
|
|
|
|
+ ]);
|
|
|
|
+ runCommand("tar", ["-xf", getDownloadPath() + '/$tarFileName', "-C", getInstallPath()]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ createConfigFile(Sys.getEnv("HOME"));
|
|
|
|
+
|
|
|
|
+ // ensure the debugger works
|
|
|
|
+ switch (ci) {
|
|
|
|
+ case GithubActions:
|
|
|
|
+ runCommand("xvfb-run", ["-a", playerLocation, "-v"]);
|
|
case _:
|
|
case _:
|
|
- throw "unsupported system";
|
|
|
|
|
|
+ runCommand(playerLocation, ["-v"]);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function setupFlashDebuggerWindows():Void {
|
|
|
|
+ flashlogPath = Sys.getEnv("APPDATA") + "\\Macromedia\\Flash Player\\Logs\\flashlog.txt";
|
|
|
|
+ final exeName = "flashplayer_32_sa_debug.exe";
|
|
|
|
+ playerLocation = Path.join([getInstallPath(), exeName]);
|
|
|
|
|
|
|
|
+ final majorVersion = getLatestFPVersion()[0];
|
|
|
|
+ if (FileSystem.exists(playerLocation))
|
|
|
|
+ infoMsg('Flash player found at $playerLocation');
|
|
|
|
+ else
|
|
|
|
+ runNetworkCommand("wget", [
|
|
|
|
+ "-nv",
|
|
|
|
+ 'https://fpdownload.macromedia.com/pub/flashplayer/updaters/${majorVersion}/$exeName',
|
|
|
|
+ "-O",
|
|
|
|
+ playerLocation
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ createConfigFile(Sys.getEnv("HOMEDRIVE") + "\\" + Sys.getEnv("HOMEPATH"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function setupFlashPlayerDebugger():Void {
|
|
switch (systemName) {
|
|
switch (systemName) {
|
|
case "Linux":
|
|
case "Linux":
|
|
- playerCmd = "flashplayerdebugger";
|
|
|
|
- if(Sys.command("type", [playerCmd]) != 0) {
|
|
|
|
- Linux.requireAptPackages([
|
|
|
|
- "libglib2.0-0", "libfreetype6"
|
|
|
|
- ]);
|
|
|
|
- var majorVersion = getLatestFPVersion()[0];
|
|
|
|
- runNetworkCommand("wget", ["-nv", 'http://fpdownload.macromedia.com/pub/flashplayer/updaters/${majorVersion}/flash_player_sa_linux_debug.x86_64.tar.gz']);
|
|
|
|
- runCommand("tar", ["-xf", "flash_player_sa_linux_debug.x86_64.tar.gz", "-C", getDownloadPath()]);
|
|
|
|
- playerCmd = Path.join([getDownloadPath(), "flashplayerdebugger"]);
|
|
|
|
- }
|
|
|
|
- if (!FileSystem.exists(mmcfgPath)) {
|
|
|
|
- File.saveContent(mmcfgPath, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
|
|
|
|
- }
|
|
|
|
- switch (ci) {
|
|
|
|
- case GithubActions:
|
|
|
|
- runCommand("xvfb-run", ["-a", playerCmd, "-v"]);
|
|
|
|
- case _:
|
|
|
|
- runCommand(playerCmd, ["-v"]);
|
|
|
|
- }
|
|
|
|
|
|
+ setupFlashDebuggerLinux();
|
|
case "Mac":
|
|
case "Mac":
|
|
- if (commandResult("brew", ["cask", "list", "flash-player-debugger"]).exitCode == 0) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- attemptCommand("brew", ["uninstall", "[email protected]"]);
|
|
|
|
- attemptCommand("brew", ["uninstall", "[email protected]"]);
|
|
|
|
- attemptCommand("brew", ["untap", "local/openssl"]);
|
|
|
|
- attemptCommand("brew", ["untap", "local/python2"]);
|
|
|
|
- runCommand("brew", ["update"]);
|
|
|
|
- runCommand("brew", ["install", "--cask", "flash-player-debugger"]);
|
|
|
|
-
|
|
|
|
- // Disable the "application downloaded from Internet" warning
|
|
|
|
- runCommand("xattr", ["-d", "-r", "com.apple.quarantine", "/Applications/Flash Player Debugger.app"]);
|
|
|
|
-
|
|
|
|
- var dir = Path.directory(mmcfgPath);
|
|
|
|
- if (!FileSystem.exists(dir)) {
|
|
|
|
- runCommand("sudo", ["mkdir", "-p", dir]);
|
|
|
|
- runCommand("sudo", ["chmod", "a+w", dir]);
|
|
|
|
- }
|
|
|
|
- if (!FileSystem.exists(mmcfgPath)) {
|
|
|
|
- File.saveContent(mmcfgPath, "ErrorReportingEnable=1\nTraceOutputFileEnable=1");
|
|
|
|
- }
|
|
|
|
|
|
+ setupFlashDebuggerMac();
|
|
|
|
+ case "Windows":
|
|
|
|
+ setupFlashDebuggerWindows();
|
|
|
|
+ case _:
|
|
|
|
+ throw "unsupported system";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
Run a Flash swf file.
|
|
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".
|
|
|
|
|
|
+ Throws `CommandFailure` if unsuccessful.
|
|
|
|
+ It detemines the test result by reading the flashlog.txt, looking for "success: true".
|
|
*/
|
|
*/
|
|
- static public function runFlash(swf:String):Bool {
|
|
|
|
|
|
+ static function runFlash(swf:String):Void {
|
|
swf = FileSystem.fullPath(swf);
|
|
swf = FileSystem.fullPath(swf);
|
|
- Sys.println('going to run $swf');
|
|
|
|
- switch (systemName) {
|
|
|
|
- case "Linux":
|
|
|
|
- switch (ci) {
|
|
|
|
- case GithubActions:
|
|
|
|
- new Process("xvfb-run", ["-a", playerCmd, swf]);
|
|
|
|
- case _:
|
|
|
|
- new Process(playerCmd, [swf]);
|
|
|
|
- }
|
|
|
|
- case "Mac":
|
|
|
|
- Sys.command("open", ["-a", "/Applications/Flash Player Debugger.app", swf]);
|
|
|
|
- }
|
|
|
|
|
|
+ infoMsg('Running .swf file: $swf');
|
|
|
|
|
|
- //wait a little until flashlog.txt is created
|
|
|
|
- var flashlogPath = switch (systemName) {
|
|
|
|
- case "Linux":
|
|
|
|
- Sys.getEnv("HOME") + "/.macromedia/Flash_Player/Logs/flashlog.txt";
|
|
|
|
|
|
+ final runProcess = switch (systemName) {
|
|
|
|
+ case "Linux" if (ci == GithubActions):
|
|
|
|
+ new Process("xvfb-run", ["-a", playerLocation, swf]);
|
|
case "Mac":
|
|
case "Mac":
|
|
- Sys.getEnv("HOME") + "/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt";
|
|
|
|
- case _:
|
|
|
|
- throw "unsupported system";
|
|
|
|
|
|
+ new Process("open", ["-a", playerLocation, swf]);
|
|
|
|
+ default:
|
|
|
|
+ new Process(playerLocation, [swf]);
|
|
}
|
|
}
|
|
|
|
|
|
- for (t in 0...5) {
|
|
|
|
- runCommand("sleep", ["2"]);
|
|
|
|
|
|
+ // wait a little until flashlog.txt is created
|
|
|
|
+ for (_ in 0...5) {
|
|
|
|
+ infoMsg("Waiting 2 seconds for flash log file...");
|
|
|
|
+ Sys.sleep(2);
|
|
if (FileSystem.exists(flashlogPath))
|
|
if (FileSystem.exists(flashlogPath))
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (!FileSystem.exists(flashlogPath)) {
|
|
if (!FileSystem.exists(flashlogPath)) {
|
|
failMsg('$flashlogPath not found.');
|
|
failMsg('$flashlogPath not found.');
|
|
- return false;
|
|
|
|
|
|
+ throw new CommandFailure();
|
|
}
|
|
}
|
|
|
|
|
|
- //read flashlog.txt continously
|
|
|
|
- var traceProcess = new Process("tail", ["-f", flashlogPath]);
|
|
|
|
|
|
+ // read flashlog.txt continously
|
|
|
|
+ final traceProcess = switch (systemName) {
|
|
|
|
+ case "Windows":
|
|
|
|
+ new Process("powershell", ["-command", '& {Get-Content "$flashlogPath" -Wait -Tail 1}']);
|
|
|
|
+ default:
|
|
|
|
+ new Process("tail", ["-f", flashlogPath]);
|
|
|
|
+ }
|
|
var success = false;
|
|
var success = false;
|
|
while (true) {
|
|
while (true) {
|
|
try {
|
|
try {
|
|
- var line = traceProcess.stdout.readLine();
|
|
|
|
|
|
+ final line = traceProcess.stdout.readLine();
|
|
if (line.indexOf("success: ") >= 0) {
|
|
if (line.indexOf("success: ") >= 0) {
|
|
success = line.indexOf("success: true") >= 0;
|
|
success = line.indexOf("success: true") >= 0;
|
|
break;
|
|
break;
|
|
@@ -151,30 +245,27 @@ class Flash {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ runProcess.kill();
|
|
|
|
+ runProcess.close();
|
|
|
|
+
|
|
traceProcess.kill();
|
|
traceProcess.kill();
|
|
traceProcess.close();
|
|
traceProcess.close();
|
|
- Sys.command("cat", [flashlogPath]);
|
|
|
|
- return success;
|
|
|
|
|
|
+ final cmd = (systemName == "Windows") ? "type" : "cat";
|
|
|
|
+ Sys.command(cmd, [flashlogPath]);
|
|
|
|
+ if (!success)
|
|
|
|
+ throw new CommandFailure();
|
|
}
|
|
}
|
|
|
|
|
|
static public function run(args:Array<String>) {
|
|
static public function run(args:Array<String>) {
|
|
setupFlashPlayerDebugger();
|
|
setupFlashPlayerDebugger();
|
|
setupFlexSdk();
|
|
setupFlexSdk();
|
|
- var success = true;
|
|
|
|
for (argsVariant in [[], ["--swf-version", "32"]]) {
|
|
for (argsVariant in [[], ["--swf-version", "32"]]) {
|
|
runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb", "-D", "dump", "-D", "dump_ignore_var_ids"].concat(args).concat(argsVariant));
|
|
runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb", "-D", "dump", "-D", "dump_ignore_var_ids"].concat(args).concat(argsVariant));
|
|
- var runSuccess = runFlash("bin/unit9.swf");
|
|
|
|
- if (!runSuccess) {
|
|
|
|
- success = false;
|
|
|
|
- }
|
|
|
|
|
|
+ runFlash("bin/unit9.swf");
|
|
}
|
|
}
|
|
|
|
|
|
changeDirectory(miscFlashDir);
|
|
changeDirectory(miscFlashDir);
|
|
runCommand("haxe", ["run.hxml"]);
|
|
runCommand("haxe", ["run.hxml"]);
|
|
-
|
|
|
|
- if (!success)
|
|
|
|
- throw new CommandFailure();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|