Progress on CPPIA support

This commit is contained in:
Joshua Granick
2019-05-14 12:02:52 -07:00
parent 8ac1ed24c7
commit 290b86fb87
7 changed files with 168 additions and 92 deletions

View File

@@ -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.Callable<cpp.Object->Int->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.Callable<cpp.Object->cpp.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.Callable<cpp.Object->Int->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);

View File

@@ -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<Char>):DataPointer
{

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::OUTPUT_DIR::/haxe
-cppia ::CPPIA_FILE::
--macro keep("::APP_MAIN::")
-debug

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::OUTPUT_DIR::/haxe
-cppia ::CPPIA_FILE::
--macro keep("::APP_MAIN::")
-D final

View File

@@ -0,0 +1,4 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::OUTPUT_DIR::/haxe
-cppia ::CPPIA_FILE::
--macro keep("::APP_MAIN::")

View File

@@ -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", "");

View File

@@ -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")
{
/*
@@ -1078,19 +1110,24 @@ class WindowsPlatform extends PlatformTarget
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);
}
}
if(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;
}
@@ -1118,8 +1155,7 @@ class WindowsPlatform extends PlatformTarget
for (filename in outputFiles)
{
if (!(StringTools.endsWith(filename,".exe") ||
StringTools.endsWith(filename,".pri") )
if (!(StringTools.endsWith(filename, ".exe") || StringTools.endsWith(filename, ".pri"))
&& filename != "AppxManifest.xml")
{
buf.add(filename);
@@ -1127,8 +1163,7 @@ class WindowsPlatform extends PlatformTarget
}
}
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);
@@ -1138,8 +1173,17 @@ class WindowsPlatform extends PlatformTarget
Log.error("Error creating layout.resfiles " + e);
}
var makepriParams = ["new", "/ProjectRoot", resultFilePath, "/ConfigXml", resultFilePath + "\\priconfig.xml", "/Manifest", applicationDirectory + "/"+'AppxManifest.xml', "/OutputFile", applicationDirectory +"resources.pri"];
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);
@@ -1151,8 +1195,7 @@ class WindowsPlatform extends PlatformTarget
Log.info("waiting pri..");
retry--;
}
if (retry<=0)
Log.error("Error on MakePri");
if (retry <= 0) Log.error("Error on MakePri");
var appxDir = applicationDirectory + "../";
@@ -1189,7 +1232,8 @@ class WindowsPlatform extends PlatformTarget
#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);
}
@@ -1197,16 +1241,13 @@ class WindowsPlatform extends PlatformTarget
// check pfx
retry = 10;
while (retry>0 && !sys.FileSystem.exists(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
@@ -1220,22 +1261,33 @@ class WindowsPlatform extends PlatformTarget
Log.error("could not copy " + appxDir + pfxFileName + " to " + pfxPath);
}
}
}
if (pfxPath != null && certificatePwd != null && pfxPath.length > 0 && certificatePwd.length > 0)
{
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);
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");
Log.info("\n\n***Double click " + pfxPath
+ " to setup certificate (Local machine, Place all certificates in the following store->Trusted People)\n");
process4.close();
}
}