Add favicon to Emscripten output

This commit is contained in:
Joshua Granick
2023-05-19 23:22:16 -07:00
parent eec6e5e0fa
commit 7c73bff438
2 changed files with 27 additions and 6 deletions

View File

@@ -9,6 +9,9 @@
<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::
@@ -46,7 +49,6 @@
</div>
<script type="text/javascript">
var Module = {};
Module.canvas = document.getElementById ("canvas");
//::if DEBUG::Module.setStatus = function (msg) { console.log (msg); };::else::Module.setStatus = function(_) {};::end::
@@ -56,17 +58,14 @@
Module.canvas.width = container.clientWidth;
Module.canvas.height = container.clientHeight;
window.addEventListener ("resize", function (e) {
window.addEventListener ("resize", function (e)
{
Module.canvas.width = container.clientWidth;
Module.canvas.height = container.clientHeight;
}, true);::end::::end::
</script>
::if DEBUG::<script type="text/javascript" src="./webgl-debug.js"></script>::end::
<script type="text/javascript" src="./::APP_FILE::.js"></script>
</body>

View File

@@ -13,6 +13,8 @@ import lime.tools.CPPHelper;
import lime.tools.DeploymentHelper;
import lime.tools.HTML5Helper;
import lime.tools.HXProject;
import lime.tools.Icon;
import lime.tools.IconHelper;
import lime.tools.Orientation;
import lime.tools.PlatformTarget;
import lime.tools.ProjectHelper;
@@ -384,6 +386,26 @@ class EmscriptenPlatform extends PlatformTarget
context.CPP_DIR = targetDirectory + "/obj";
context.USE_COMPRESSION = project.targetFlags.exists("compress");
context.favicons = [];
var icons = project.icons;
if (icons.length == 0)
{
icons = [new Icon(System.findTemplate(project.templatePaths, "default/icon.svg"))];
}
// if (IconHelper.createWindowsIcon (icons, Path.combine (destination, "favicon.ico"))) {
//
// context.favicons.push ({ rel: "icon", type: "image/x-icon", href: "./favicon.ico" });
//
// }
if (IconHelper.createIcon(icons, 192, 192, Path.combine(destination, "favicon.png")))
{
context.favicons.push({rel: "shortcut icon", type: "image/png", href: "./favicon.png"});
}
for (asset in project.assets)
{
var path = Path.combine(targetDirectory + "/obj/assets", asset.targetPath);