Skip to content

Commit c4cc642

Browse files
Merge pull request #1905 from MAJigsaw77/feature/resource-file-windows
Initial support for Windows resource file.
2 parents d3aeb9f + df3f816 commit c4cc642

4 files changed

Lines changed: 70 additions & 7 deletions

File tree

src/lime/tools/MetaData.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ abstract MetaData({
1010
@:optional var packageName:String;
1111
@:optional var title:String;
1212
@:optional var version:String;
13+
@:optional var copyrightYears:String;
1314
}) from Dynamic
1415
{
1516
@:noCompletion
@@ -21,6 +22,7 @@ abstract MetaData({
2122
description: "",
2223
packageName: "",
2324
title: "",
24-
version: ""
25+
version: "",
26+
copyrightYears: ""
2527
};
2628
}

src/lime/tools/ProjectXMLParser.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class ProjectXMLParser extends HXProject
683683
{
684684
switch (attribute)
685685
{
686-
case "title", "description", "package", "version", "company", "company-id", "build-number", "company-url":
686+
case "title", "description", "package", "version", "company", "company-id", "build-number", "company-url", "copyright-years":
687687
var value = substitute(element.att.resolve(attribute));
688688

689689
defines.set("APP_" + StringTools.replace(attribute, "-", "_").toUpperCase(), value);
@@ -1738,7 +1738,7 @@ class ProjectXMLParser extends HXProject
17381738

17391739
case "gradle-version":
17401740
config.set("android.gradle-version", value);
1741-
1741+
17421742
case "gradle-plugin":
17431743
config.set("android.gradle-plugin", value);
17441744

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "winres.h"
2+
3+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
4+
5+
VS_VERSION_INFO VERSIONINFO
6+
FILEVERSION ::VERSION_NUMBER::
7+
PRODUCTVERSION ::VERSION_NUMBER::
8+
FILEFLAGSMASK 0x3fL
9+
FILEFLAGS 0x0L
10+
FILEOS 0x40004L
11+
FILETYPE 0x2L
12+
FILESUBTYPE 0x0L
13+
14+
BEGIN
15+
BLOCK "StringFileInfo"
16+
BEGIN
17+
BLOCK "040904b0"
18+
BEGIN
19+
VALUE "CompanyName", "::APP_COMPANY::"
20+
VALUE "FileDescription", "::APP_DESCRIPTION::"
21+
VALUE "FileVersion", "::FILE_VERSION::"
22+
VALUE "InternalName", "::APP_FILE::"
23+
VALUE "LegalCopyright", "Copyright (C) ::APP_COPYRIGHT_YEARS:: ::APP_COMPANY::"
24+
VALUE "OriginalFilename", "::APP_FILE::"
25+
VALUE "ProductName", "::APP_PACKAGE::"
26+
VALUE "ProductVersion", "::FILE_VERSION::"
27+
END
28+
END
29+
BLOCK "VarFileInfo"
30+
BEGIN
31+
VALUE "Translation", 0x409, 1200
32+
END
33+
END

tools/platforms/WindowsPlatform.hx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ class WindowsPlatform extends PlatformTarget
549549
}
550550
else
551551
{
552-
var haxeArgs = [hxml];
553-
var flags = [];
552+
var haxeArgs = [hxml, "-D", "resourceFile=ApplicationMain.rc"];
553+
var flags = ["-DresourceFile=ApplicationMain.rc"];
554554

555555
if (is64)
556556
{
@@ -679,6 +679,29 @@ class WindowsPlatform extends PlatformTarget
679679
}
680680
else
681681
{
682+
if (targetType == "cpp")
683+
{
684+
if (context.APP_DESCRIPTION == null || context.APP_DESCRIPTION == "")
685+
{
686+
context.APP_DESCRIPTION = project.meta.title;
687+
}
688+
689+
if (context.APP_COPYRIGHT_YEARS == null || context.APP_COPYRIGHT_YEARS == "")
690+
{
691+
context.APP_COPYRIGHT_YEARS = Std.string(Date.now().getFullYear());
692+
}
693+
694+
var versionParts = project.meta.version.split(".");
695+
696+
if (versionParts.length == 3)
697+
{
698+
versionParts.push("0");
699+
}
700+
701+
context.FILE_VERSION = versionParts.join(".");
702+
context.VERSION_NUMBER = versionParts.join(",");
703+
}
704+
682705
context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n";
683706
context.NODE_FILE = targetDirectory + "/bin/ApplicationMain.js";
684707
context.HL_FILE = targetDirectory + "/obj/ApplicationMain" + (project.defines.exists("hlc") ? ".c" : ".hl");
@@ -987,9 +1010,14 @@ class WindowsPlatform extends PlatformTarget
9871010
ProjectHelper.recursiveSmartCopyTemplate(project, "winrt/temp", targetDirectory + "/haxe/temp", context, false, true);
9881011
ProjectHelper.recursiveSmartCopyTemplate(project, "winrt/scripts", targetDirectory + "/scripts", context, true, true);
9891012
}
990-
else if (targetType == "cpp" && project.targetFlags.exists("static"))
1013+
else if (targetType == "cpp")
9911014
{
992-
ProjectHelper.recursiveSmartCopyTemplate(project, "cpp/static", targetDirectory + "/obj", context);
1015+
ProjectHelper.recursiveSmartCopyTemplate(project, "windows/resource", targetDirectory + "/obj", context);
1016+
1017+
if (project.targetFlags.exists("static"))
1018+
{
1019+
ProjectHelper.recursiveSmartCopyTemplate(project, "cpp/static", targetDirectory + "/obj", context);
1020+
}
9931021
}
9941022

9951023
/*if (IconHelper.createIcon (project.icons, 32, 32, Path.combine (applicationDirectory, "icon.png"))) {

0 commit comments

Comments
 (0)