First pass at WinRT app builds

This commit is contained in:
Joshua Granick
2018-11-01 17:33:42 -07:00
parent e2cf19e14c
commit df0827f4a6
6 changed files with 217 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
-main ApplicationMain ::HAXE_FLAGS::
-cpp ::CPP_DIR::
-cp ::OUTPUT_DIR::/haxe
--macro keep("::APP_MAIN::")
-D winrt
-debug

View File

@@ -0,0 +1,6 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::OUTPUT_DIR::/haxe
-cpp ::CPP_DIR::
--macro keep("::APP_MAIN::")
-D winrt
-D final

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-cp ::OUTPUT_DIR::/haxe
-cpp ::CPP_DIR::
--macro keep("::APP_MAIN::")
-D winrt

View File

@@ -0,0 +1,95 @@
<xml>
<include name="${HXCPP}/build-tool/BuildCommon.xml" />
<files id="main">
<file name="Main.cpp" />
</files>
<target id="main" output="Main${DBG}" tool="linker" toolid="exe">
<files id="main" />
::foreach ndlls::
<lib name="::path::" />::end::
<section if="windows">
<lib name="gdi32.lib" />
<lib name="opengl32.lib" />
<lib name="user32.lib" />
<lib name="kernel32.lib" />
<lib name="advapi32.lib" />
<lib name="winmm.lib" />
<lib name="imm32.lib" />
<lib name="ole32.lib" />
<lib name="oleaut32.lib" />
<lib name="version.lib" />
<lib name="ws2_32.lib" />
<lib name="wldap32.lib" />
<lib name="shell32.lib" />
<lib name="comdlg32.lib" />
<lib name="comsuppw.lib" />
<lib name="usp10.lib" />
<lib name="rpcrt4.lib" />
<lib name="dwrite.lib" />
</section>
<section if="linux">
<lib name="${HXCPP}/lib/${BINDIR}/liblinuxcompat.a" />
<lib name="-lpthread" />
<lib name="-lrt" />
<lib name="-lgc" if="LIME_NEKO" />
<lib name="-lm" if="LIME_NEKO" />
</section>
<section if="mac">
<vflag name="-l" value="iconv"/>
<vflag name="-framework" value="IOKit" />
<vflag name="-framework" value="Foundation" />
<vflag name="-framework" value="CoreAudio" />
<vflag name="-framework" value="CoreVideo" />
<vflag name="-framework" value="Cocoa" />
<vflag name="-framework" value="OpenGL" />
<vflag name="-framework" value="AudioToolbox" />
<vflag name="-framework" value="AudioUnit" />
<vflag name="-framework" value="ForceFeedback" />
<vflag name="-framework" value="Carbon" />
<vflag name="-framework" value="AppKit" />
<vflag name="-framework" value="OpenAL"/>
<lib name="/opt/local/lib/libgc.a" if="LIME_NEKO" />
<lib name="-lm" if="LIME_NEKO" />
</section>
<section if="android">
<lib name="-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit" if="LIME_SDL"/>
<lib name="-ldl" />
<lib name="-llog" />
<lib name="-landroid" />
<lib name="-lEGL" />
<lib name="-lGLESv2" />
<lib name="-lGLESv1_CM" />
<lib name="-lOpenSLES" />
</section>
<lib name="libApplicationMain${DBG}${LIBEXT}" />
</target>
<target id="default">
<target id="main" />
</target>
</xml>

View File

@@ -0,0 +1,43 @@
#include <stdio.h>
#ifdef HX_WINDOWS
#include <windows.h>
#endif
extern "C" const char *hxRunLibrary ();
extern "C" void hxcpp_set_top_of_stack ();
extern "C" int zlib_register_prims ();
extern "C" int lime_cairo_register_prims ();
extern "C" int lime_openal_register_prims ();
::foreach ndlls::::if (registerStatics)::
extern "C" int ::nameSafe::_register_prims ();::end::::end::
#ifdef HX_WINDOWS
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
extern "C" int main(int argc, char *argv[]) {
#endif
hxcpp_set_top_of_stack ();
zlib_register_prims ();
lime_cairo_register_prims ();
lime_openal_register_prims ();
::foreach ndlls::::if (registerStatics)::
::nameSafe::_register_prims ();::end::::end::
const char *err = NULL;
err = hxRunLibrary ();
if (err) {
printf("Error: %s\n", err);
return -1;
}
return 0;
}

View File

@@ -72,6 +72,10 @@ class WindowsPlatform extends PlatformTarget {
targetType = "java";
} else if (project.targetFlags.exists ("winrt")) {
targetType = "winrt";
} else {
targetType = "cpp";
@@ -166,7 +170,15 @@ class WindowsPlatform extends PlatformTarget {
}
if (!project.targetFlags.exists ("static") || targetType != "cpp") {
if (targetType == "winrt") {
for (ndll in project.ndlls) {
ProjectHelper.copyLibrary (project, ndll, "WinRT", "", (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") {
var targetSuffix = (targetType == "hl") ? ".hdll" : null;
@@ -249,6 +261,55 @@ class WindowsPlatform extends PlatformTarget {
System.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar", Path.combine (applicationDirectory, project.app.file + ".jar"));
JavaHelper.copyLibraries (project.templatePaths, "Windows" + (is64 ? "64" : ""), applicationDirectory);
} else if (targetType == "winrt") {
var haxeArgs = [ hxml ];
var flags = [];
haxeArgs.push ("-D");
haxeArgs.push ("winrt");
flags.push ("-Dwinrt");
if (!project.environment.exists ("SHOW_CONSOLE")) {
haxeArgs.push ("-D");
haxeArgs.push ("no_console");
flags.push ("-Dno_console");
}
if (!project.targetFlags.exists ("static")) {
System.runCommand ("", "haxe", haxeArgs);
if (noOutput) return;
CPPHelper.compile (project, targetDirectory + "/obj", flags);
System.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : "") + ".exe", executablePath);
} else {
System.runCommand ("", "haxe", haxeArgs.concat ([ "-D", "static_link" ]));
if (noOutput) return;
CPPHelper.compile (project, targetDirectory + "/obj", flags.concat ([ "-Dstatic_link" ]));
CPPHelper.compile (project, targetDirectory + "/obj", flags, "BuildMain.xml");
System.copyFile (targetDirectory + "/obj/Main" + (project.debug ? "-debug" : "") + ".exe", executablePath);
}
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 {
var haxeArgs = [ hxml ];