Initial CPP winrt -static

Runs but no bitmap is displayed when testing with DisplayingABitmap. You can attach VS2017 debugger (Debug Installed App Package).

lime rebuild tools
lime rebuild winrt -static
in DisplayingABitmap:
openfl test project.xml winrt -static
This commit is contained in:
Carlos Madrazo
2019-03-03 22:33:03 -05:00
committed by Joshua Granick
parent 00e3c85b58
commit 125840589f
13 changed files with 266 additions and 112 deletions

View File

@@ -154,11 +154,14 @@ class WindowsPlatform extends PlatformTarget
if (targetType == "winrt")
{
for (ndll in project.ndlls)
if(!project.targetFlags.exists ("static"))
{
ProjectHelper.copyLibrary(project, ndll, "WinRT" + (is64 ? "64" : ""), "",
for (ndll in project.ndlls)
{
ProjectHelper.copyLibrary(project, ndll, "WinRT" + (is64 ? "64" : ""), "",
(ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", applicationDirectory,
project.debug, null);
}
}
}
else if (!project.targetFlags.exists("static") || targetType != "cpp")
@@ -295,13 +298,14 @@ class WindowsPlatform extends PlatformTarget
System.copyFile(targetDirectory + "/obj/Main" + (project.debug ? "-debug" : "") + ".exe", executablePath);
}
var iconPath = Path.combine(applicationDirectory, "icon.ico");
//TODO createWinrtIcons
//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);
}
//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
{
@@ -402,6 +406,12 @@ class WindowsPlatform extends PlatformTarget
context.APP_DESCRIPTION = project.meta.title;
}
}
else if (targetType == "winrt")
{
context.CPP_DIR = targetDirectory + "/obj";
context.BUILD_DIR = project.app.path + "/winrt" + (is64 ? "64" : "");
context.DC = "::";
}
else
{
context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n";
@@ -576,6 +586,10 @@ class WindowsPlatform extends PlatformTarget
{
System.runCommand(applicationDirectory, "java", ["-jar", project.app.file + ".jar"].concat(arguments));
}
else if (targetType == "winrt")
{
winrtRun(arguments);
}
else if (project.target == cast System.hostPlatform)
{
arguments = arguments.concat(["-livereload"]);
@@ -614,7 +628,7 @@ class WindowsPlatform extends PlatformTarget
var context = generateContext();
context.OUTPUT_DIR = targetDirectory;
if (targetType == "cpp" && project.targetFlags.exists("static"))
if ((targetType == "cpp" || targetType == "winrt") && project.targetFlags.exists("static"))
{
var programFiles = project.environment.get("ProgramFiles(x86)");
var hasVSCommunity = (programFiles != null && FileSystem.exists(Path.combine(programFiles, "Microsoft Visual Studio/Installer/vswhere.exe")));
@@ -651,7 +665,13 @@ class WindowsPlatform extends PlatformTarget
ProjectHelper.recursiveSmartCopyTemplate(project, "haxe", targetDirectory + "/haxe", context);
ProjectHelper.recursiveSmartCopyTemplate(project, targetType + "/hxml", targetDirectory + "/haxe", context);
if (targetType == "cpp" && project.targetFlags.exists("static"))
if (targetType == "winrt" && project.targetFlags.exists ("static"))
{
ProjectHelper.recursiveSmartCopyTemplate (project, "winrt/assetspkg", targetDirectory + "/bin/assetspkg", context, false, true);
ProjectHelper.recursiveSmartCopyTemplate (project, "winrt/appx", targetDirectory + "/bin", context, true, true);
ProjectHelper.recursiveSmartCopyTemplate (project, "winrt/static", targetDirectory + "/obj", context, true, true);
}
else if (targetType == "cpp" && project.targetFlags.exists("static"))
{
ProjectHelper.recursiveSmartCopyTemplate(project, "cpp/static", targetDirectory + "/obj", context);
}
@@ -888,9 +908,118 @@ class WindowsPlatform extends PlatformTarget
System.watch(command, dirs);
}
@ignore public override function install():Void {}
// @ignore public override function install ():Void {}
override public function install():Void
{
super.install();
if (targetType == "winrt")
{
//if(project.winrtConfig.isAppx)
//{
// TODO: pack in appx
//}
//else
{
uninstall();
Log.info("run: Register app");
var process = new sys.io.Process('powershell', ["-noprofile", "-command",'Add-AppxPackage -Path '+applicationDirectory + "/"+'AppxManifest.xml -Register']);
if (process.exitCode() != 0)
{
var message = process.stderr.readAll().toString();
Log.error("Cannot register. " + message);
}
process.close();
}
}
}
@ignore public override function trace():Void {}
@ignore public override function uninstall():Void {}
//@ignore public override function uninstall ():Void {}
override public function uninstall():Void
{
super.uninstall();
if (targetType == "winrt")
//if(project.winrtConfig.isAppx)
//{
// TODO
//}
//else
{
var appxName = project.meta.packageName;
Log.info("run: Remove previous registered app");
var process = new sys.io.Process('powershell', ["-noprofile", "-command",'Get-AppxPackage '+appxName+' | Remove-AppxPackage']);
if (process.exitCode() != 0)
{
var message = process.stderr.readAll().toString();
Log.error("Cannot remove. " + message);
}
process.close();
}
}
public function winrtRun (arguments:Array<String>):Void
{
var dir = applicationDirectory;
var haxeDir = targetDirectory + "/haxe";
//if(project.winrtConfig.isAppx)
//{
// Log.info("\n***Double click on "+project.app.file + ".Appx to install Appx");
//}
//else
{
var appxName = project.meta.packageName;
var appxId = "App";
var appxAUMID:String = null;
var appxInfoFile = haxeDir + "/appxinfo.txt";
var kitsRoot10 = "C:\\Program Files (x86)\\Windows Kits\\10\\"; //%WindowsSdkDir%
//get PackageFamilyappxName and set appxAUMID
// write app info in a file
var cmd = 'Get-AppxPackage '+appxName+' | Out-File '+appxInfoFile+' -Encoding ASCII';
trace("powershell " + cmd);
var process3 = new sys.io.Process('powershell', [cmd]);
if (process3.exitCode() != 0)
{
var message = process3.stderr.readAll().toString();
Log.error("Cannot get PackageFamilyName. " + message);
}
process3.close();
// parse file
if(sys.FileSystem.exists(appxInfoFile))
{
var fin = sys.io.File.read(appxInfoFile, false);
try
{
while(true)
{
var str = fin.readLine();
var split = str.split (":");
var name = StringTools.trim(split[0]);
if( name == "PackageFamilyName")
{
var appxPackageFamilyName = StringTools.trim(split[1]);
if(appxPackageFamilyName!=null)
{
appxAUMID = appxPackageFamilyName+"!"+appxId;
break;
}
}
}
}
catch(e:haxe.io.Eof)
{
Log.error('Could not get PackageFamilyName from '+appxInfoFile);
}
fin.close();
}
Log.info("run: "+appxAUMID);
Log.info(kitsRoot10+'App Certification Kit\\microsoft.windows.softwarelogo.appxlauncher.exe '+appxAUMID);
var process4 = new sys.io.Process(kitsRoot10+'App Certification Kit\\microsoft.windows.softwarelogo.appxlauncher.exe', [appxAUMID]);
}
}
}