nothing works yet. checking in to work on a different machine

This commit is contained in:
jared gholston
2017-08-07 16:40:11 -07:00
committed by Joshua Granick
parent 3139f28bf2
commit 985d70464a
7 changed files with 380 additions and 11 deletions

View File

@@ -62,6 +62,8 @@ class ProjectXMLParser extends HXProject {
private function initialize ():Void {
Sys.println ("ProjectXMLParser initialize() platformType: " + platformType + " target: " + target + " flags: " + targetFlags);
switch (platformType) {
case MOBILE:
@@ -124,21 +126,21 @@ class ProjectXMLParser extends HXProject {
defines.set ("native", "1");
if (target == Platform.WINDOWS) {
if (target == Platform.WINDOWS && !targetFlags.exists ("uwp")) {
Sys.println ("Setting targetType CPP");
defines.set ("targetType", "cpp");
defines.set ("cpp", "1");
defines.set ("mingw", "1");
} else {
Sys.println ("Setting targetType NEKO?");
defines.set ("targetType", "neko");
defines.set ("neko", "1");
}
} else if (targetFlags.exists ("cpp") || ((platformType != PlatformType.WEB) && !targetFlags.exists ("html5")) || target == Platform.EMSCRIPTEN) {
Sys.println ("Setting targetType CPP?");
defines.set ("targetType", "cpp");
defines.set ("native", "1");
defines.set ("cpp", "1");

View File

@@ -7,8 +7,10 @@ import lime.project.Icon;
import lime.tools.helpers.CPPHelper;
import lime.tools.helpers.DeploymentHelper;
import lime.tools.helpers.FileHelper;
import lime.tools.helpers.HTML5Helper;
import lime.tools.helpers.IconHelper;
import lime.tools.helpers.LogHelper;
import lime.tools.helpers.ModuleHelper;
import lime.tools.helpers.CSHelper;
import lime.tools.helpers.GUID;
import lime.tools.helpers.NekoHelper;
@@ -27,6 +29,8 @@ import sys.io.File;
import sys.FileSystem;
class WindowsPlatform extends PlatformTarget {
@@ -34,6 +38,7 @@ class WindowsPlatform extends PlatformTarget {
private var executablePath:String;
private var is64:Bool;
private var targetType:String;
private var outputFile:String;
public function new (command:String, _project:HXProject, targetFlags:Map<String, String> ) {
@@ -62,6 +67,11 @@ class WindowsPlatform extends PlatformTarget {
targetType = "cs";
} else if (project.targetFlags.exists ("uwp")) {
targetType = "windows";
outputFile = targetDirectory + "/bin/" + project.app.file + ".js";
} else {
targetType = "cpp";
@@ -70,18 +80,59 @@ class WindowsPlatform extends PlatformTarget {
targetDirectory = PathHelper.combine (project.app.path, project.config.getString ("windows.output-directory", targetType == "cpp" ? "windows" : targetType));
targetDirectory = StringTools.replace (targetDirectory, "arch64", is64 ? "64" : "");
applicationDirectory = targetDirectory + "/bin/";
executablePath = applicationDirectory + project.app.file + ".exe";
}
}
public override function build ():Void {
var hxml = targetDirectory + "/haxe/" + buildType + ".hxml";
PathHelper.mkdir (targetDirectory);
// universal windows platform
// for now build html5
if (project.targetFlags.exists ("uwp")) {
Sys.println ("I am building some magic UWP shit!");
ModuleHelper.buildModules (project, targetDirectory + "/obj", targetDirectory + "/bin");
if (project.app.main != null) {
var outputFile = targetDirectory + "/bin/" + project.app.file + ".js";
ProcessHelper.runCommand ("", "haxe", [ hxml ] );
if (noOutput) return;
if (project.targetFlags.exists ("webgl")) {
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain.js", outputFile);
}
if (project.modules.iterator ().hasNext ()) {
ModuleHelper.patchFile (outputFile);
}
if (project.targetFlags.exists ("minify") || buildType == "final") {
HTML5Helper.minify (project, targetDirectory + "/bin/" + project.app.file + ".js");
}
}
return;
} else {
Sys.println ("I am NOT building some magic UWP shit! " + targetType);
}
for (dependency in project.dependencies) {
if (StringTools.endsWith (dependency.path, ".dll")) {
@@ -92,6 +143,7 @@ class WindowsPlatform extends PlatformTarget {
}
}
if (!project.targetFlags.exists ("static") || targetType != "cpp") {
@@ -150,7 +202,38 @@ class WindowsPlatform extends PlatformTarget {
CSHelper.addSourceFiles (txtPath, CSHelper.ndllSourceFiles);
CSHelper.addGUID (txtPath, GUID.uuid ());
CSHelper.compile (project, targetDirectory + "/obj", applicationDirectory + project.app.file, "x86", "desktop");
} else if(project.targetFlags.exists ("uwp")) {
ModuleHelper.buildModules (project, targetDirectory + "/obj", targetDirectory + "/bin");
if (project.app.main != null) {
var outputFile = targetDirectory + "/bin/" + project.app.file + ".js";
var hxml = targetDirectory + "/haxe/" + buildType + ".hxml";
ProcessHelper.runCommand ("", "haxe", [ hxml ] );
if (noOutput) return;
if (project.targetFlags.exists ("webgl")) {
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain.js", outputFile);
}
if (project.modules.iterator ().hasNext ()) {
ModuleHelper.patchFile (outputFile);
}
if (project.targetFlags.exists ("minify") || buildType == "final") {
HTML5Helper.minify (project, targetDirectory + "/bin/" + project.app.file + ".js");
}
}
} else {
var haxeArgs = [ hxml ];
@@ -307,6 +390,216 @@ class WindowsPlatform extends PlatformTarget {
}
}
public override function update ():Void {
project = project.clone ();
var destination = targetDirectory + "/bin/";
PathHelper.mkdir (destination);
var webfontDirectory = targetDirectory + "/obj/webfont";
var useWebfonts = true;
for (haxelib in project.haxelibs) {
if (haxelib.name == "openfl-html5-dom" || haxelib.name == "openfl-bitfive") {
useWebfonts = false;
}
}
var fontPath;
for (asset in project.assets) {
if (asset.type == AssetType.FONT) {
if (useWebfonts) {
fontPath = PathHelper.combine (webfontDirectory, Path.withoutDirectory (asset.targetPath));
if (!FileSystem.exists (fontPath)) {
PathHelper.mkdir (webfontDirectory);
FileHelper.copyFile (asset.sourcePath, fontPath);
asset.sourcePath = fontPath;
HTML5Helper.generateWebfonts (project, asset);
}
asset.sourcePath = fontPath;
asset.targetPath = Path.withoutExtension (asset.targetPath);
} else {
project.haxeflags.push (HTML5Helper.generateFontData (project, asset));
}
}
}
if (project.targetFlags.exists ("xml")) {
project.haxeflags.push ("-xml " + targetDirectory + "/types.xml");
}
if (LogHelper.verbose) {
project.haxedefs.set ("verbose", 1);
}
ModuleHelper.updateProject (project);
var libraryNames = new Map<String, Bool> ();
for (asset in project.assets) {
if (asset.library != null && !libraryNames.exists (asset.library)) {
libraryNames[asset.library] = true;
}
}
//for (library in libraryNames.keys ()) {
//
//project.haxeflags.push ("-resource " + targetDirectory + "/obj/manifest/" + library + ".json@__ASSET_MANIFEST__" + library);
//
//}
//project.haxeflags.push ("-resource " + targetDirectory + "/obj/manifest/default.json@__ASSET_MANIFEST__default");
var context = project.templateContext;
context.WIN_FLASHBACKGROUND = project.window.background != null ? StringTools.hex (project.window.background, 6) : "";
context.OUTPUT_DIR = targetDirectory;
context.OUTPUT_FILE = outputFile;
if (project.targetFlags.exists ("webgl")) {
context.CPP_DIR = targetDirectory + "/obj";
}
context.favicons = [];
var icons = project.icons;
if (icons.length == 0) {
icons = [ new Icon (PathHelper.findTemplate (project.templatePaths, "default/icon.svg")) ];
}
//if (IconHelper.createWindowsIcon (icons, PathHelper.combine (destination, "favicon.ico"))) {
//
//context.favicons.push ({ rel: "icon", type: "image/x-icon", href: "./favicon.ico" });
//
//}
if (IconHelper.createIcon (icons, 192, 192, PathHelper.combine (destination, "favicon.png"))) {
context.favicons.push ({ rel: "shortcut icon", type: "image/png", href: "./favicon.png" });
}
context.linkedLibraries = [];
for (dependency in project.dependencies) {
if (StringTools.endsWith (dependency.name, ".js")) {
context.linkedLibraries.push (dependency.name);
} else if (StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
var name = Path.withoutDirectory (dependency.path);
context.linkedLibraries.push ("./lib/" + name);
FileHelper.copyIfNewer (dependency.path, PathHelper.combine (destination, PathHelper.combine ("lib", name)));
}
}
for (asset in project.assets) {
var path = PathHelper.combine (destination, asset.targetPath);
if (asset.type != AssetType.TEMPLATE) {
if (asset.type != AssetType.FONT) {
PathHelper.mkdir (Path.directory (path));
FileHelper.copyAssetIfNewer (asset, path);
} else if (useWebfonts) {
PathHelper.mkdir (Path.directory (path));
var ext = "." + Path.extension (asset.sourcePath);
var source = Path.withoutExtension (asset.sourcePath);
for (extension in [ ext, ".eot", ".woff", ".svg" ]) {
if (FileSystem.exists (source + extension)) {
FileHelper.copyIfNewer (source + extension, path + extension);
} else {
LogHelper.warn ("Could not find generated font file \"" + source + extension + "\"");
}
}
}
}
}
FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/template", destination, context);
if (project.app.main != null) {
FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context);
FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/haxe", targetDirectory + "/haxe", context, true, false);
FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/hxml", targetDirectory + "/haxe", context);
if (project.targetFlags.exists ("webgl")) {
FileHelper.recursiveCopyTemplate (project.templatePaths, "webgl/hxml", targetDirectory + "/haxe", context, true, false);
}
}
for (asset in project.assets) {
var path = PathHelper.combine (destination, asset.targetPath);
if (asset.type == AssetType.TEMPLATE) {
PathHelper.mkdir (Path.directory (path));
FileHelper.copyAsset (asset, path, context);
}
}
}
/*
public override function update ():Void {
@@ -375,12 +668,12 @@ class WindowsPlatform extends PlatformTarget {
}
/*if (IconHelper.createIcon (project.icons, 32, 32, PathHelper.combine (applicationDirectory, "icon.png"))) {
*//*if (IconHelper.createIcon (project.icons, 32, 32, PathHelper.combine (applicationDirectory, "icon.png"))) {
context.HAS_ICON = true;
context.WIN_ICON = "icon.png";
}*/
}*//*
for (asset in project.assets) {
@@ -404,7 +697,7 @@ class WindowsPlatform extends PlatformTarget {
}
}
}*/
@ignore public override function install ():Void {}

View File

@@ -0,0 +1,6 @@
-main ApplicationMain ::HAXE_FLAGS::
-js ::OUTPUT_FILE::
-cp ::OUTPUT_DIR::/haxe
-D html5
-D html
-debug

View File

@@ -0,0 +1,8 @@
-main ApplicationMain ::HAXE_FLAGS::
-js ::OUTPUT_FILE::
-cp ::OUTPUT_DIR::/haxe
-D html5
-D html
-D final
-D js-flatten
-dce full

View File

@@ -0,0 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-js ::OUTPUT_FILE::
-cp ::OUTPUT_DIR::/haxe
-D html5
-D html

BIN
templates/windows/hxswfml.n Normal file

Binary file not shown.

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>::APP_TITLE::</title>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
::if favicons::::foreach (favicons)::
<link rel="::__current__.rel::" type="::__current__.type::" href="::__current__.href::">::end::::end::
::if linkedLibraries::::foreach (linkedLibraries)::
<script type="text/javascript" src="::__current__::"></script>::end::::end::
<script type="text/javascript" src="./::APP_FILE::.js"></script>
<script>
window.addEventListener ("touchmove", function (event) { event.preventDefault (); }, false);
if (typeof window.devicePixelRatio != 'undefined' && window.devicePixelRatio > 2) {
var meta = document.getElementById ("viewport");
meta.setAttribute ('content', 'width=device-width, initial-scale=' + (2 / window.devicePixelRatio) + ', user-scalable=no');
}
</script>
<style>
html,body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
#content { background: #000000; width: ::if (WIN_RESIZABLE)::100%::elseif (WIN_WIDTH > 0)::::WIN_WIDTH::px::else::100%::end::; height: ::if (WIN_RESIZABLE)::100%::elseif (WIN_WIDTH > 0)::::WIN_HEIGHT::px::else::100%::end::; }
::foreach assets::::if (type == "font")::
@font-face {
font-family: '::fontName::';
src: url('::targetPath::.eot');
src: url('::targetPath::.eot?#iefix') format('embedded-opentype'),
url('::targetPath::.svg#my-font-family') format('svg'),
url('::targetPath::.woff') format('woff'),
url('::targetPath::.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}::end::::end::
</style>
</head>
<body>
::foreach assets::::if (type == "font")::
<span style="font-family: ::id::"> </span>::end::::end::
<div id="content"></div>
<script type="text/javascript">
lime.embed ("::APP_FILE::", "content", ::WIN_WIDTH::, ::WIN_HEIGHT::);
</script>
</body>
</html>