From 290b86fb8703a088b641452739231da6ce1c0669 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 14 May 2019 12:02:52 -0700 Subject: [PATCH] Progress on CPPIA support --- .../_internal/backend/native/NativeCFFI.hx | 32 +-- src/lime/utils/DataPointer.hx | 2 +- templates/cppia/hxml/debug.hxml | 5 + templates/cppia/hxml/final.hxml | 5 + templates/cppia/hxml/release.hxml | 4 + tools/CommandLineTools.hx | 10 + tools/platforms/WindowsPlatform.hx | 202 +++++++++++------- 7 files changed, 168 insertions(+), 92 deletions(-) create mode 100644 templates/cppia/hxml/debug.hxml create mode 100644 templates/cppia/hxml/final.hxml create mode 100644 templates/cppia/hxml/release.hxml diff --git a/src/lime/_internal/backend/native/NativeCFFI.hx b/src/lime/_internal/backend/native/NativeCFFI.hx index 4f5a25de5..57a08cfe8 100644 --- a/src/lime/_internal/backend/native/NativeCFFI.hx +++ b/src/lime/_internal/backend/native/NativeCFFI.hx @@ -28,7 +28,7 @@ import lime.utils.ArrayBufferView; import lime.system.CFFI; import lime.system.CFFIPointer; #end -#if cpp +#if (cpp && !cppia) import cpp.Float32; #else typedef Float32 = Float; @@ -53,7 +53,7 @@ typedef CFFIPointer = Dynamic; class NativeCFFI { #if (lime_cffi && !macro) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_application_create():Dynamic; @@ -601,7 +601,7 @@ class NativeCFFI ._loadPrime("lime", "lime_zlib_decompress", "ooo", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_application_create = CFFI.load("lime", "lime_application_create", 0); private static var lime_application_event_manager_register = CFFI.load("lime", "lime_application_event_manager_register", 2); private static var lime_application_exec = CFFI.load("lime", "lime_application_exec", 1); @@ -1360,7 +1360,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && android) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_jni_call_member(jniMethod:Dynamic, jniObject:Dynamic, args:Dynamic):Dynamic; @@ -1425,7 +1425,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && lime_openal) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_al_buffer_data(buffer:CFFIPointer, format:Int, data:Dynamic, size:Int, freq:Int):Void; @@ -1796,7 +1796,7 @@ class NativeCFFI private static var lime_al_remove_send = new cpp.CallableInt->cpp.Void>(cpp.Prime._loadPrime("lime", "lime_al_remove_send", "oiv", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_al_buffer_data = CFFI.load("lime", "lime_al_buffer_data", 5); private static var lime_al_buffer3f = CFFI.load("lime", "lime_al_buffer3f", 5); private static var lime_al_buffer3i = CFFI.load("lime", "lime_al_buffer3i", 5); @@ -2306,7 +2306,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && lime_cairo) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_cairo_arc(handle:CFFIPointer, xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void; @@ -2739,7 +2739,7 @@ class NativeCFFI private static var lime_cairo_surface_flush = new cpp.Callablecpp.Void>(cpp.Prime._loadPrime("lime", "lime_cairo_surface_flush", "ov", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_cairo_arc = CFFI.load("lime", "lime_cairo_arc", -1); private static var lime_cairo_arc_negative = CFFI.load("lime", "lime_cairo_arc_negative", -1); private static var lime_cairo_clip = CFFI.load("lime", "lime_cairo_clip", 1); @@ -3261,7 +3261,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && lime_curl) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_curl_getdate(date:String, now:Float):Float; @@ -3358,7 +3358,7 @@ class NativeCFFI private static var lime_curl_multi_wait = new cpp.CallableInt->Int>(cpp.Prime._loadPrime("lime", "lime_curl_multi_wait", "oii", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_curl_getdate = CFFI.load("lime", "lime_curl_getdate", 2); private static var lime_curl_global_cleanup = CFFI.load("lime", "lime_curl_global_cleanup", 0); private static var lime_curl_global_init = CFFI.load("lime", "lime_curl_global_init", 1); @@ -3518,7 +3518,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && (lime_opengl || lime_opengles)) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_gl_active_texture(texture:Int):Void; @@ -4511,7 +4511,7 @@ class NativeCFFI ._loadPrime("lime", "lime_gl_wait_sync", "oiiiv", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_gl_active_texture = CFFI.load("lime", "lime_gl_active_texture", 1); private static var lime_gl_attach_shader = CFFI.load("lime", "lime_gl_attach_shader", 2); private static var lime_gl_begin_query = CFFI.load("lime", "lime_gl_begin_query", 2); @@ -5599,7 +5599,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && lime_harfbuzz) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_hb_blob_create(data:DataPointer, length:Int, memoryMode:Int):CFFIPointer; @@ -6002,7 +6002,7 @@ class NativeCFFI ._loadPrime("lime", "lime_hb_shape", "ooov", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_hb_blob_create:lime.utils.DataPointer->Int->Int->Dynamic = CFFI.load("lime", "lime_hb_blob_create", 3); private static var lime_hb_blob_create_sub_blob:Dynamic->Int->Int->Dynamic = CFFI.load("lime", "lime_hb_blob_create_sub_blob", 3); private static var lime_hb_blob_get_data:Dynamic->Float = CFFI.load("lime", "lime_hb_blob_get_data", 1); @@ -6559,7 +6559,7 @@ class NativeCFFI #end #end #if (lime_cffi && !macro && lime_vorbis) - #if cpp + #if (cpp && !cppia) #if (disable_cffi || haxe_ver < "3.4.0") @:cffi private static function lime_vorbis_file_bitrate(vorbisFile:Dynamic, bitstream:Int):Int; @@ -6677,7 +6677,7 @@ class NativeCFFI ._loadPrime("lime", "lime_vorbis_file_time_total", "oid", false)); #end #end - #if neko + #if (neko || cppia) private static var lime_vorbis_file_bitrate = CFFI.load("lime", "lime_vorbis_file_bitrate", 2); private static var lime_vorbis_file_bitrate_instant = CFFI.load("lime", "lime_vorbis_file_bitrate_instant", 1); private static var lime_vorbis_file_clear = CFFI.load("lime", "lime_vorbis_file_clear", 1); diff --git a/src/lime/utils/DataPointer.hx b/src/lime/utils/DataPointer.hx index 207aea51a..4bfed5c62 100644 --- a/src/lime/utils/DataPointer.hx +++ b/src/lime/utils/DataPointer.hx @@ -45,7 +45,7 @@ abstract DataPointer(DataPointerType) to DataPointerType #end } - #if (cpp && !doc_gen) + #if (cpp && !cppia && !doc_gen) #if (haxe_ver < 4) @:from @:noCompletion public static inline function fromCharPointer(pointer:Pointer):DataPointer { diff --git a/templates/cppia/hxml/debug.hxml b/templates/cppia/hxml/debug.hxml new file mode 100644 index 000000000..2dcee2f69 --- /dev/null +++ b/templates/cppia/hxml/debug.hxml @@ -0,0 +1,5 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-cppia ::CPPIA_FILE:: +--macro keep("::APP_MAIN::") +-debug \ No newline at end of file diff --git a/templates/cppia/hxml/final.hxml b/templates/cppia/hxml/final.hxml new file mode 100644 index 000000000..0a682c742 --- /dev/null +++ b/templates/cppia/hxml/final.hxml @@ -0,0 +1,5 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-cppia ::CPPIA_FILE:: +--macro keep("::APP_MAIN::") +-D final \ No newline at end of file diff --git a/templates/cppia/hxml/release.hxml b/templates/cppia/hxml/release.hxml new file mode 100644 index 000000000..58e30ae8f --- /dev/null +++ b/templates/cppia/hxml/release.hxml @@ -0,0 +1,4 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-cppia ::CPPIA_FILE:: +--macro keep("::APP_MAIN::") \ No newline at end of file diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index 890f26b0c..290096918 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -243,6 +243,10 @@ class CommandLineTools target = cast System.hostPlatform; targetFlags.set("hl", ""); + case "cppia": + target = cast System.hostPlatform; + targetFlags.set("cppia", ""); + case "java": target = cast System.hostPlatform; targetFlags.set("java", ""); @@ -899,6 +903,7 @@ class CommandLineTools Log.println(" \x1b[1mjava\x1b[0m -- Alias for host platform (using \x1b[1m-java\x1b[0m)"); Log.println(" \x1b[1mcs\x1b[0m -- Alias for host platform (using \x1b[1m-cs\x1b[0m)"); Log.println(" \x1b[1mhl/hashlink\x1b[0m -- Alias for host platform (using \x1b[1m-hl\x1b[0m)"); + Log.println(" \x1b[1mcppia\x1b[0m -- Alias for host platform (using \x1b[1m-cppia\x1b[0m)"); Log.println(" \x1b[1muwp\x1b[0;3m/\x1b[0m\x1b[1mwinjs\x1b[0m -- Alias for \x1b[1mwindows -uwp\x1b[0m"); // Log.println (" \x1b[1miphone\x1b[0;3m/\x1b[0m\x1b[1miphoneos\x1b[0m -- \x1b[1mios\x1b[0m"); // Log.println (" \x1b[1miphonesim\x1b[0m -- Alias for \x1b[1mios -simulator\x1b[0m"); @@ -1008,6 +1013,7 @@ class CommandLineTools Log.println(" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-nodejs\x1b[0m -- Build for Node.js instead of C++"); Log.println(" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-cs\x1b[0m -- Build for C# instead of C++"); Log.println(" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-hl\x1b[0m -- Build for HashLink instead of C++"); + Log.println(" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-cppia\x1b[0m -- Build for CPPIA instead of C++"); Log.println(" \x1b[3m(windows)\x1b[0m \x1b[1m-winjs\x1b[0m -- Build for WinJS instead of C++ (implies UWP)"); Log.println(" \x1b[3m(windows)\x1b[0m \x1b[1m-uwp\x1b[0m -- Build for Universal Windows Platform"); Log.println(" \x1b[3m(html5)\x1b[0m \x1b[1m-electron\x1b[0m -- Target Electron instead of the browser"); @@ -1478,6 +1484,10 @@ class CommandLineTools target = cast System.hostPlatform; targetFlags.set("hl", ""); + case "cppia": + target = cast System.hostPlatform; + targetFlags.set("cppia", ""); + case "java": target = cast System.hostPlatform; targetFlags.set("java", ""); diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 626f96519..5e0af6aee 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -53,6 +53,11 @@ class WindowsPlatform extends PlatformTarget targetType = "hl"; is64 = false; } + else if (project.targetFlags.exists("cppia")) + { + targetType = "cppia"; + is64 = true; + } else if (project.targetFlags.exists("nodejs")) { targetType = "nodejs"; @@ -224,6 +229,24 @@ class WindowsPlatform extends PlatformTarget System.runCommand("", System.findTemplate(templates, "bin/ReplaceVistaIcon.exe"), [executablePath, iconPath, "1"], true, true); } } + else if (targetType == "cppia") + { + System.runCommand("", "haxe", [hxml]); + + if (noOutput) return; + + System.copyFile(Path.combine(Haxelib.getPath(new Haxelib("hxcpp")), "bin/Windows64/Cppia.exe"), executablePath); + System.copyFile(targetDirectory + "/obj/ApplicationMain.cppia", Path.combine(applicationDirectory, "script.cppia")); + + var iconPath = Path.combine(applicationDirectory, "icon.ico"); + + if (IconHelper.createWindowsIcon(icons, iconPath) && System.hostPlatform == WINDOWS) + { + var templates = [Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)) + + "/templates"].concat(project.templatePaths); + System.runCommand("", System.findTemplate(templates, "bin/ReplaceVistaIcon.exe"), [executablePath, iconPath, "1"], true, true); + } + } else if (targetType == "nodejs") { System.runCommand("", "haxe", [hxml]); @@ -448,6 +471,7 @@ class WindowsPlatform extends PlatformTarget context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n"; context.NODE_FILE = targetDirectory + "/bin/ApplicationMain.js"; context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl"; + context.CPPIA_FILE = targetDirectory + "/obj/ApplicationMain.cppia"; context.CPP_DIR = targetDirectory + "/obj"; context.BUILD_DIR = project.app.path + "/windows" + (is64 ? "64" : ""); } @@ -474,6 +498,8 @@ class WindowsPlatform extends PlatformTarget hxml.hl = "_.hl"; case "neko": hxml.neko = "_.n"; + case "cppia": + hxml.cppia = "_.cppia"; case "java": hxml.java = "_"; case "nodejs", "winjs": @@ -553,6 +579,12 @@ class WindowsPlatform extends PlatformTarget { NodeJSHelper.run(project, targetDirectory + "/bin/ApplicationMain.js", arguments); } + else if (targetType == "cppia") + { + // arguments = arguments.concat(["-livereload"]); + arguments = ["script.cppia"]; //.concat(arguments); + System.runCommand(applicationDirectory, Path.withoutDirectory(executablePath), arguments); + } else if (targetType == "winjs") { /* @@ -955,7 +987,7 @@ class WindowsPlatform extends PlatformTarget super.install(); if (targetType == "winrt") { - if(project.targetFlags.exists("appx")) + if (project.targetFlags.exists("appx")) { var context = project.templateContext; buildWinrtPackage(context.KEY_STORE, context.KEY_STORE_PASSWORD); @@ -985,7 +1017,7 @@ class WindowsPlatform extends PlatformTarget override public function uninstall():Void { super.uninstall(); - if (targetType == "winrt" && !project.targetFlags.exists("appx")) + if (targetType == "winrt" && !project.targetFlags.exists("appx")) { var appxName = project.meta.packageName; Log.info("run: Remove previous registered app"); @@ -1001,16 +1033,16 @@ class WindowsPlatform extends PlatformTarget } process.close(); } - //TODO if (targetType == "winrt" && project.targetFlags.exists("appx")) + // TODO if (targetType == "winrt" && project.targetFlags.exists("appx")) } public function winrtRun(arguments:Array):Void { var dir = applicationDirectory; var haxeDir = targetDirectory + "/haxe"; - if (project.targetFlags.exists("appx")) + if (project.targetFlags.exists("appx")) { - Log.info("\n***Double click on "+project.app.file + ".Appx to install Appx"); + Log.info("\n***Double click on " + project.app.file + ".Appx to install Appx"); } else { @@ -1067,176 +1099,196 @@ class WindowsPlatform extends PlatformTarget } } - public function buildWinrtPackage(pfxPath:String, certificatePwd:String):Void + public function buildWinrtPackage(pfxPath:String, certificatePwd:String):Void { if (project.targetFlags.exists("appx")) { - var kitsRoot10 = "C:\\Program Files (x86)\\Windows Kits\\10\\"; //%WindowsSdkDir% + var kitsRoot10 = "C:\\Program Files (x86)\\Windows Kits\\10\\"; // %WindowsSdkDir% var haxeDir = targetDirectory + "/haxe"; var binDir:String = kitsRoot10 + "\\bin"; - if (sys.FileSystem.exists(binDir)) + if (sys.FileSystem.exists(binDir)) { var maxSDK:Int = 0; - for (file in sys.FileSystem.readDirectory(binDir)) { - if(StringTools.startsWith(file,"10.0")){ + for (file in sys.FileSystem.readDirectory(binDir)) + { + if (StringTools.startsWith(file, "10.0")) + { var file2 = file.split("10.0.")[1]; file2 = file2.split(".0")[0]; - var fileSDK:Int = Std.parseInt(file2); - maxSDK = (maxSDK>fileSDK?maxSDK:fileSDK); + var fileSDK:Int = Std.parseInt(file2); + maxSDK = (maxSDK > fileSDK ? maxSDK : fileSDK); } } - if(maxSDK>0){ - Log.info("Found max SDK 10.0."+maxSDK+".0"); - binDir += "\\10.0."+maxSDK+".0"; + if (maxSDK > 0) + { + Log.info("Found max SDK 10.0." + maxSDK + ".0"); + binDir += "\\10.0." + maxSDK + ".0"; } - } else { + } + else + { Log.error('"$binDir" does not exists'); return; } - var makepriPath = binDir+'\\x86\\MakePri.exe'; - var makeappxPath = binDir+'\\x86\\MakeAppx.exe'; - var signToolPath = binDir+'\\x64\\SignTool.exe'; + var makepriPath = binDir + '\\x86\\MakePri.exe'; + var makeappxPath = binDir + '\\x86\\MakeAppx.exe'; + var signToolPath = binDir + '\\x64\\SignTool.exe'; - var resultFilePath = haxeDir +"\\temp"; - var resultFileName = resultFilePath +"/layout.resfiles"; + var resultFilePath = haxeDir + "\\temp"; + var resultFileName = resultFilePath + "/layout.resfiles"; Log.info("make pri"); var outputDirectory = Path.combine(FileSystem.fullPath(targetDirectory), "appx"); var binPath = Path.combine(FileSystem.fullPath(targetDirectory), "bin"); pfxPath = Path.combine(outputDirectory, pfxPath); - //prepare file to make pri + // prepare file to make pri try { var from = outputDirectory; var buf = new StringBuf(); - //todo + // todo var outputFiles = FileSystem.readDirectory(binPath); for (filename in outputFiles) { - if (!(StringTools.endsWith(filename,".exe") || - StringTools.endsWith(filename,".pri") ) - && filename!="AppxManifest.xml") + if (!(StringTools.endsWith(filename, ".exe") || StringTools.endsWith(filename, ".pri")) + && filename != "AppxManifest.xml") { - buf.add(filename); - buf.addChar(10); + buf.add(filename); + buf.addChar(10); } } - - if(sys.FileSystem.exists(resultFileName)) - sys.FileSystem.deleteFile(sys.FileSystem.absolutePath(resultFileName)); + + if (sys.FileSystem.exists(resultFileName)) sys.FileSystem.deleteFile(sys.FileSystem.absolutePath(resultFileName)); sys.io.File.saveContent(resultFileName, buf.toString()); Log.info("Created layout.resfiles : " + resultFileName); } - catch(e:Dynamic) + catch (e:Dynamic) { Log.error("Error creating layout.resfiles " + e); } - - var makepriParams = ["new", "/ProjectRoot", resultFilePath, "/ConfigXml", resultFilePath + "\\priconfig.xml", "/Manifest", applicationDirectory + "/"+'AppxManifest.xml', "/OutputFile", applicationDirectory +"resources.pri"]; - Log.info( makepriPath+ " " + makepriParams); + var makepriParams = [ + "new", + "/ProjectRoot", + resultFilePath, + "/ConfigXml", + resultFilePath + "\\priconfig.xml", + "/Manifest", + applicationDirectory + "/" + 'AppxManifest.xml', + "/OutputFile", + applicationDirectory + "resources.pri" + ]; + Log.info(makepriPath + " " + makepriParams); var process = new sys.io.Process(makepriPath, makepriParams); - //needs to wait make pri + // needs to wait make pri var retry:Int = 10; - while (retry>0 && !sys.FileSystem.exists(applicationDirectory + "/"+"resources.pri")) + while (retry > 0 && !sys.FileSystem.exists(applicationDirectory + "/" + "resources.pri")) { Sys.sleep(1); Log.info("waiting pri.."); retry--; } - if (retry<=0) - Log.error("Error on MakePri"); + if (retry <= 0) Log.error("Error on MakePri"); - var appxDir = applicationDirectory+"../"; + var appxDir = applicationDirectory + "../"; - Log.info("make "+project.app.file+".Appx"); - var makeappParams = ["pack", "/d", applicationDirectory, "/p", appxDir+project.app.file+".Appx" ]; + Log.info("make " + project.app.file + ".Appx"); + var makeappParams = ["pack", "/d", applicationDirectory, "/p", appxDir + project.app.file + ".Appx"]; var process2 = new sys.io.Process(makeappxPath, makeappParams); Log.info(makeappParams.toString()); process.close(); process2.close(); - var pfxFileName = project.app.file+".pfx"; + var pfxFileName = project.app.file + ".pfx"; - if (pfxPath!=null && pfxPath.length>0) + if (pfxPath != null && pfxPath.length > 0) { - if (sys.FileSystem.exists(appxDir+"scripts/"+pfxFileName)) + if (sys.FileSystem.exists(appxDir + "scripts/" + pfxFileName)) { - //apply certificate - Log.info("Pfx cert found: path: " +appxDir+"scripts/"+pfxFileName+", pwd:"+certificatePwd); + // apply certificate + Log.info("Pfx cert found: path: " + appxDir + "scripts/" + pfxFileName + ", pwd:" + certificatePwd); } else { - //create certificate - Log.warn("Warn: certificate " +pfxPath+" not found, run the following command to create a new one:"); - //copyTemplateDir( "winrt/scripts", applicationDirectory+"/.." ); + // create certificate + Log.warn("Warn: certificate " + pfxPath + " not found, run the following command to create a new one:"); + // copyTemplateDir( "winrt/scripts", applicationDirectory+"/.." ); - //New certificate, calls powershell script on elevated mode -// var cmd = "Start-Process powershell \"-ExecutionPolicy Bypass -Command `\"cd `\""+sys.FileSystem.absolutePath(applicationDirectory)+"/.."+"`\"; & `\".\\newcertificate.ps1`\"`\"\" -Verb RunAs"; -// var cmd = "Start-Process powershell \"-Command `\"cd `\""+sys.FileSystem.absolutePath(applicationDirectory)+"/.."+"`\"; & `\".\\newcertificate.ps1`\"`\"\" -Verb RunAs"; + // New certificate, calls powershell script on elevated mode + // var cmd = "Start-Process powershell \"-ExecutionPolicy Bypass -Command `\"cd `\""+sys.FileSystem.absolutePath(applicationDirectory)+"/.."+"`\"; & `\".\\newcertificate.ps1`\"`\"\" -Verb RunAs"; + // var cmd = "Start-Process powershell \"-Command `\"cd `\""+sys.FileSystem.absolutePath(applicationDirectory)+"/.."+"`\"; & `\".\\newcertificate.ps1`\"`\"\" -Verb RunAs"; - //var cmd = "\"cd "+sys.FileSystem.absolutePath(applicationDirectory)+"/../scripts;Start-Process powershell -verb runas -ArgumentList \'-file .\\newcertificate.ps1\'\""; + // var cmd = "\"cd "+sys.FileSystem.absolutePath(applicationDirectory)+"/../scripts;Start-Process powershell -verb runas -ArgumentList \'-file .\\newcertificate.ps1\'\""; var cmd = "-Command \"Start-Process powershell \\\"-ExecutionPolicy Bypass -NoProfile -NoExit -Command `\\\"cd \\`\\\"E:/openfl/BunnyMark/Export/winrt/bin/../scripts\\`\\\"; & \\`\\\".\\newcertificate.ps1\\`\\\"`\\\"\\\" -Verb RunAs\""; - Log.info("powershell "+cmd); + Log.info("powershell " + cmd); #if 0 var process3 = new sys.io.Process("powershell", [cmd]); - if (process3.exitCode() != 0) { + if (process3.exitCode() != 0) + { var message = process3.stderr.readAll().toString(); Log.error("Error newcertificate. " + message); } process3.close(); - //check pfx + // check pfx retry = 10; - while (retry>0 && !sys.FileSystem.exists(appxDir+"scripts/"+pfxFileName)){ - Log.info("waiting "+appxDir+"scripts/"+pfxFileName); + while (retry > 0 && !sys.FileSystem.exists(appxDir + "scripts/" + pfxFileName)) + { + Log.info("waiting " + appxDir + "scripts/" + pfxFileName); Sys.sleep(6); retry--; } - if (retry<=0) - Log.error("Error creating certificate"); - - - + if (retry <= 0) Log.error("Error creating certificate"); #else return; #end } - if(appxDir+"scripts/"+pfxFileName != pfxPath) + if (appxDir + "scripts/" + pfxFileName != pfxPath) { - System.copyFile(appxDir+"scripts/"+pfxFileName, pfxPath); + System.copyFile(appxDir + "scripts/" + pfxFileName, pfxPath); if (!sys.FileSystem.exists(pfxPath)) { - Log.error("could not copy "+appxDir+pfxFileName+" to "+pfxPath); + Log.error("could not copy " + appxDir + pfxFileName + " to " + pfxPath); } } - } - if (pfxPath!=null && certificatePwd!=null && pfxPath.length>0 && certificatePwd.length>0) + if (pfxPath != null && certificatePwd != null && pfxPath.length > 0 && certificatePwd.length > 0) { - Log.info("signing "+project.app.file+".Appx with " + pfxPath); + Log.info("signing " + project.app.file + ".Appx with " + pfxPath); - var signParams = ["sign", "/fd", "SHA256", "/a", "/f", pfxPath, "/p", certificatePwd, appxDir+project.app.file+".Appx"]; + var signParams = [ + "sign", + "/fd", + "SHA256", + "/a", + "/f", + pfxPath, + "/p", + certificatePwd, + appxDir + project.app.file + ".Appx" + ]; - Log.info(signToolPath+" "+signParams); + Log.info(signToolPath + " " + signParams); var process4 = new sys.io.Process(signToolPath, signParams); - if (process4.exitCode() != 0) { + if (process4.exitCode() != 0) + { var message = process4.stderr.readAll().toString(); Log.error("Error signing appx. " + message); } - Log.info("\n\n***Double click "+pfxPath+" to setup certificate (Local machine, Place all certificates in the following store->Trusted People)\n"); - process4.close(); + Log.info("\n\n***Double click " + pfxPath + + " to setup certificate (Local machine, Place all certificates in the following store->Trusted People)\n"); + process4.close(); } } }