Add better win32 resource file injection to be done during linker call
This commit is contained in:
@@ -14,7 +14,6 @@ public class FlaxEditor : EngineTarget
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
// Initialize
|
|
||||||
IsEditor = true;
|
IsEditor = true;
|
||||||
OutputName = "FlaxEditor";
|
OutputName = "FlaxEditor";
|
||||||
ConfigurationName = "Editor";
|
ConfigurationName = "Editor";
|
||||||
@@ -31,7 +30,6 @@ public class FlaxEditor : EngineTarget
|
|||||||
TargetArchitecture.ARM64,
|
TargetArchitecture.ARM64,
|
||||||
};
|
};
|
||||||
GlobalDefinitions.Add("USE_EDITOR");
|
GlobalDefinitions.Add("USE_EDITOR");
|
||||||
Win32ResourceFile = Path.Combine(Globals.EngineRoot, "Source", "FlaxEditor.rc");
|
|
||||||
|
|
||||||
Modules.Add("Editor");
|
Modules.Add("Editor");
|
||||||
Modules.Add("CSG");
|
Modules.Add("CSG");
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ BEGIN
|
|||||||
BLOCK "040004b0"
|
BLOCK "040004b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", FLAXENGINE_COMPANY
|
VALUE "CompanyName", FLAXENGINE_COMPANY
|
||||||
VALUE "FileDescription", "Flax Editor"
|
VALUE "FileDescription", PRODUCT_NAME
|
||||||
VALUE "FileVersion", FLAXENGINE_VERSION_TEXT
|
VALUE "FileVersion", FLAXENGINE_VERSION_TEXT
|
||||||
VALUE "InternalName", "FlaxEditor"
|
VALUE "InternalName", PRODUCT_NAME_INTERNAL
|
||||||
VALUE "LegalCopyright", FLAXENGINE_COPYRIGHT
|
VALUE "LegalCopyright", FLAXENGINE_COPYRIGHT
|
||||||
VALUE "OriginalFilename", "FlaxEditor.exe"
|
VALUE "OriginalFilename", ORIGINAL_FILENAME
|
||||||
VALUE "ProductName", "Flax Editor"
|
VALUE "ProductName", PRODUCT_NAME
|
||||||
VALUE "ProductVersion", FLAXENGINE_VERSION_TEXT
|
VALUE "ProductVersion", FLAXENGINE_VERSION_TEXT
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
@@ -14,11 +14,10 @@ public class FlaxGame : EngineTarget
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
// Initialize
|
|
||||||
OutputName = "FlaxGame";
|
OutputName = "FlaxGame";
|
||||||
ConfigurationName = "Game";
|
ConfigurationName = "Game";
|
||||||
IsPreBuilt = false;
|
IsPreBuilt = false;
|
||||||
Win32ResourceFile = Path.Combine(Globals.EngineRoot, "Source", "FlaxGame.rc");
|
IsMonolithicExecutable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
// Microsoft Visual C++ generated resource script.
|
|
||||||
//
|
|
||||||
#include "resource.h"
|
|
||||||
#include "FlaxEngine.Gen.h"
|
|
||||||
|
|
||||||
#define APSTUDIO_READONLY_SYMBOLS
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generated from the TEXTINCLUDE 2 resource.
|
|
||||||
//
|
|
||||||
#include "winres.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
#undef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Polish (Poland) resources
|
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK)
|
|
||||||
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// TEXTINCLUDE
|
|
||||||
//
|
|
||||||
|
|
||||||
1 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"resource.h\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
2 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"#include ""winres.h""\r\n"
|
|
||||||
"\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
3 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"\r\n"
|
|
||||||
"\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
#endif // APSTUDIO_INVOKED
|
|
||||||
|
|
||||||
// Icon
|
|
||||||
IDR_MAINFRAME ICON "Icon.ico"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Version
|
|
||||||
//
|
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
|
||||||
FILEVERSION FLAXENGINE_VERSION_MAJOR,FLAXENGINE_VERSION_MINOR,FLAXENGINE_VERSION_BUILD
|
|
||||||
PRODUCTVERSION FLAXENGINE_VERSION_MAJOR,FLAXENGINE_VERSION_MINOR,FLAXENGINE_VERSION_BUILD
|
|
||||||
FILEFLAGSMASK 0x3fL
|
|
||||||
#ifdef _DEBUG
|
|
||||||
FILEFLAGS 0x1L
|
|
||||||
#else
|
|
||||||
FILEFLAGS 0x0L
|
|
||||||
#endif
|
|
||||||
FILEOS 0x40004L
|
|
||||||
FILETYPE 0x1L
|
|
||||||
FILESUBTYPE 0x0L
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "040004b0"
|
|
||||||
BEGIN
|
|
||||||
VALUE "CompanyName", FLAXENGINE_COMPANY
|
|
||||||
VALUE "FileDescription", "Flax Engine"
|
|
||||||
VALUE "FileVersion", FLAXENGINE_VERSION_TEXT
|
|
||||||
VALUE "InternalName", "FlaxEngine"
|
|
||||||
VALUE "LegalCopyright", FLAXENGINE_COPYRIGHT
|
|
||||||
VALUE "OriginalFilename", "FlaxGame.exe"
|
|
||||||
VALUE "ProductName", "Flax Engine"
|
|
||||||
VALUE "ProductVersion", FLAXENGINE_VERSION_TEXT
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x400, 1200
|
|
||||||
END
|
|
||||||
END
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef APSTUDIO_INVOKED
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generated from the TEXTINCLUDE 3 resource.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
#endif // not APSTUDIO_INVOKED
|
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ namespace Flax.Build
|
|||||||
|
|
||||||
Modules.Add("Main");
|
Modules.Add("Main");
|
||||||
Modules.Add("Engine");
|
Modules.Add("Engine");
|
||||||
|
Win32ResourceFile = Path.Combine(Globals.EngineRoot, "Source", "FlaxEngine.rc");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -194,6 +195,7 @@ namespace Flax.Build
|
|||||||
mainModuleOptions.SourcePaths.Add(mainModule.FolderPath);
|
mainModuleOptions.SourcePaths.Add(mainModule.FolderPath);
|
||||||
mainModule.Setup(mainModuleOptions);
|
mainModule.Setup(mainModuleOptions);
|
||||||
mainModuleOptions.MergeSourcePathsIntoSourceFiles();
|
mainModuleOptions.MergeSourcePathsIntoSourceFiles();
|
||||||
|
mainModuleOptions.CompileEnv.PrecompiledHeaderUsage = PrecompiledHeaderFileUsage.None;
|
||||||
mainModuleOptions.CompileEnv.PreprocessorDefinitions.Add("FLAXENGINE_API=" + buildOptions.Toolchain.DllImport);
|
mainModuleOptions.CompileEnv.PreprocessorDefinitions.Add("FLAXENGINE_API=" + buildOptions.Toolchain.DllImport);
|
||||||
Builder.BuildModuleInner(buildData, mainModule, mainModuleOptions, false);
|
Builder.BuildModuleInner(buildData, mainModule, mainModuleOptions, false);
|
||||||
|
|
||||||
|
|||||||
@@ -127,8 +127,7 @@ namespace Flax.Build.NativeCpp
|
|||||||
LinkAsConsoleProgram = LinkAsConsoleProgram,
|
LinkAsConsoleProgram = LinkAsConsoleProgram,
|
||||||
GenerateDocumentation = GenerateDocumentation
|
GenerateDocumentation = GenerateDocumentation
|
||||||
};
|
};
|
||||||
foreach (var e in InputFiles)
|
clone.InputFiles.AddRange(InputFiles);
|
||||||
clone.InputFiles.Add(e);
|
|
||||||
clone.DocumentationFiles.AddRange(DocumentationFiles);
|
clone.DocumentationFiles.AddRange(DocumentationFiles);
|
||||||
clone.InputLibraries.AddRange(InputLibraries);
|
clone.InputLibraries.AddRange(InputLibraries);
|
||||||
clone.LibraryPaths.AddRange(LibraryPaths);
|
clone.LibraryPaths.AddRange(LibraryPaths);
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ namespace Flax.Build.Platforms
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreBuild(TaskGraph graph, BuildOptions options)
|
public override void LinkFiles(TaskGraph graph, BuildOptions options, string outputFilePath)
|
||||||
{
|
{
|
||||||
base.PreBuild(graph, options);
|
|
||||||
|
|
||||||
// Compile and include resource file if need to
|
// Compile and include resource file if need to
|
||||||
if (options.Target.Win32ResourceFile != null && !options.Target.IsPreBuilt && options.Target.OutputType == TargetOutputType.Executable)
|
if (options.Target.Win32ResourceFile != null &&
|
||||||
|
!options.Target.IsPreBuilt &&
|
||||||
|
(options.LinkEnv.Output == LinkerOutput.Executable || options.LinkEnv.Output == LinkerOutput.SharedLibrary))
|
||||||
{
|
{
|
||||||
var task = graph.Add<CompileCppTask>();
|
var task = graph.Add<CompileCppTask>();
|
||||||
var args = new List<string>();
|
var args = new List<string>();
|
||||||
@@ -62,24 +62,22 @@ namespace Flax.Build.Platforms
|
|||||||
|
|
||||||
// Add preprocessor definitions
|
// Add preprocessor definitions
|
||||||
foreach (var definition in options.CompileEnv.PreprocessorDefinitions)
|
foreach (var definition in options.CompileEnv.PreprocessorDefinitions)
|
||||||
{
|
|
||||||
args.Add(string.Format("/D \"{0}\"", definition));
|
args.Add(string.Format("/D \"{0}\"", definition));
|
||||||
}
|
args.Add(string.Format("/D \"ORIGINAL_FILENAME=\\\"{0}\\\"\"", Path.GetFileName(outputFilePath)));
|
||||||
|
args.Add(string.Format("/D \"PRODUCT_NAME=\\\"{0}\\\"\"", options.Target.ProjectName + " " + options.Target.ConfigurationName));
|
||||||
|
args.Add(string.Format("/D \"PRODUCT_NAME_INTERNAL=\\\"{0}\\\"\"", options.Target.Name));
|
||||||
|
|
||||||
// Add include paths
|
// Add include paths
|
||||||
foreach (var includePath in options.CompileEnv.IncludePaths)
|
foreach (var includePath in options.CompileEnv.IncludePaths)
|
||||||
{
|
|
||||||
AddIncludePath(args, includePath);
|
AddIncludePath(args, includePath);
|
||||||
}
|
|
||||||
|
|
||||||
// Add the resource file to the produced item list
|
// Add the resource file to the produced item list
|
||||||
var outputFile = Path.Combine(options.IntermediateFolder, Path.GetFileNameWithoutExtension(sourceFile) + ".res");
|
var outputFile = Path.Combine(options.IntermediateFolder, Path.GetFileName(outputFilePath) + ".res");
|
||||||
args.Add(string.Format("/Fo\"{0}\"", outputFile));
|
args.Add(string.Format("/Fo\"{0}\"", outputFile));
|
||||||
options.LinkEnv.InputFiles.Add(outputFile);
|
options.LinkEnv.InputFiles.Add(outputFile);
|
||||||
|
|
||||||
// Request included files to exist
|
// Request included files to exist
|
||||||
var includes = IncludesCache.FindAllIncludedFiles(sourceFile);
|
task.PrerequisiteFiles.AddRange(IncludesCache.FindAllIncludedFiles(sourceFile));
|
||||||
task.PrerequisiteFiles.AddRange(includes);
|
|
||||||
|
|
||||||
// Add the source file
|
// Add the source file
|
||||||
args.Add(string.Format("\"{0}\"", sourceFile));
|
args.Add(string.Format("\"{0}\"", sourceFile));
|
||||||
@@ -91,6 +89,8 @@ namespace Flax.Build.Platforms
|
|||||||
task.PrerequisiteFiles.Add(sourceFile);
|
task.PrerequisiteFiles.Add(sourceFile);
|
||||||
task.Cost = 1;
|
task.Cost = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base.LinkFiles(graph, options, outputFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user