Add OutputName to Build Settings for game output exe/package renaming
#1174
This commit is contained in:
@@ -295,7 +295,7 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
||||
|
||||
// Copy result package
|
||||
const String apk = data.OriginalOutputPath / (distributionPackage ? TEXT("app/build/outputs/apk/release/app-release-unsigned.apk") : TEXT("app/build/outputs/apk/debug/app-debug.apk"));
|
||||
const String outputApk = data.OriginalOutputPath / gameSettings->ProductName + TEXT(".apk");
|
||||
const String outputApk = data.OriginalOutputPath / EditorUtilities::GetOutputName() + TEXT(".apk");
|
||||
if (FileSystem::CopyFile(outputApk, apk))
|
||||
{
|
||||
LOG(Error, "Failed to copy package from {0} to {1}", apk, outputApk);
|
||||
|
||||
@@ -42,11 +42,11 @@ bool WindowsPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
{
|
||||
const auto platformSettings = WindowsPlatformSettings::Get();
|
||||
|
||||
// Apply executable icon
|
||||
Array<String> files;
|
||||
FileSystem::DirectoryGetFiles(files, data.NativeCodeOutputPath, TEXT("*.exe"), DirectorySearchOption::TopDirectoryOnly);
|
||||
if (files.HasItems())
|
||||
{
|
||||
// Apply executable icon
|
||||
TextureData iconData;
|
||||
if (!EditorUtilities::GetApplicationImage(platformSettings->OverrideIcon, iconData))
|
||||
{
|
||||
@@ -56,11 +56,31 @@ bool WindowsPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Rename app
|
||||
const String newName = EditorUtilities::GetOutputName();
|
||||
if (newName != StringUtils::GetFileNameWithoutExtension(files[0]))
|
||||
{
|
||||
if (FileSystem::MoveFile(data.NativeCodeOutputPath / newName + TEXT(".exe"), files[0], true))
|
||||
{
|
||||
data.Error(TEXT("Failed to change output executable name."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowsPlatformTools::OnBuildStarted(CookingData& data)
|
||||
{
|
||||
// Remove old executable
|
||||
Array<String> files;
|
||||
FileSystem::DirectoryGetFiles(files, data.NativeCodeOutputPath, TEXT("*.exe"), DirectorySearchOption::TopDirectoryOnly);
|
||||
for (auto& file : files)
|
||||
FileSystem::DeleteFile(file);
|
||||
}
|
||||
|
||||
void WindowsPlatformTools::OnRun(CookingData& data, String& executableFile, String& commandLineFormat, String& workingDir)
|
||||
{
|
||||
// Pick the first executable file
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
ArchitectureType GetArchitecture() const override;
|
||||
bool UseSystemDotnet() const override;
|
||||
bool OnDeployBinaries(CookingData& data) override;
|
||||
void OnBuildStarted(CookingData& data) override;
|
||||
void OnRun(CookingData& data, String& executableFile, String& commandLineFormat, String& workingDir) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Engine/Tools/TextureTool/TextureTool.h"
|
||||
#include "Engine/Core/Math/Color32.h"
|
||||
#include "Engine/Core/Config/GameSettings.h"
|
||||
#include "Engine/Core/Config/BuildSettings.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Content/AssetReference.h"
|
||||
#include "Engine/Content/Assets/Texture.h"
|
||||
@@ -511,6 +512,18 @@ bool EditorUtilities::UpdateExeIcon(const String& path, const TextureData& icon)
|
||||
return false;
|
||||
}
|
||||
|
||||
String EditorUtilities::GetOutputName()
|
||||
{
|
||||
const auto gameSettings = GameSettings::Get();
|
||||
const auto buildSettings = BuildSettings::Get();
|
||||
String outputName = buildSettings->OutputName;
|
||||
outputName.Replace(TEXT("${PROJECT_NAME}"), *gameSettings->ProductName, StringSearchCase::IgnoreCase);
|
||||
outputName.Replace(TEXT("${COMPANY_NAME}"), *gameSettings->CompanyName, StringSearchCase::IgnoreCase);
|
||||
if (outputName.IsEmpty())
|
||||
outputName = TEXT("FlaxGame");
|
||||
return outputName;
|
||||
}
|
||||
|
||||
bool EditorUtilities::FormatAppPackageName(String& packageName)
|
||||
{
|
||||
const auto gameSettings = GameSettings::Get();
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
/// <returns>True if fails, otherwise false.</returns>
|
||||
static bool UpdateExeIcon(const String& path, const TextureData& icon);
|
||||
|
||||
static String GetOutputName();
|
||||
static bool FormatAppPackageName(String& packageName);
|
||||
static bool GetApplicationImage(const Guid& imageId, TextureData& imageData, ApplicationImageType type = ApplicationImageType::Icon);
|
||||
static bool GetTexture(const Guid& textureId, TextureData& textureData);
|
||||
|
||||
@@ -17,6 +17,12 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(BuildSettings);
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Name of the output app created by the build system. Used to rename main executable (eg. MyGame.exe) or final package name (eg. MyGame.apk). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
|
||||
String OutputName = TEXT("${PROJECT_NAME}");
|
||||
|
||||
/// <summary>
|
||||
/// The maximum amount of assets to include into a single assets package. Asset packages will split into several packages if need to.
|
||||
/// </summary>
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GameActivity extends NativeActivity {
|
||||
static {
|
||||
try {
|
||||
// Load native libraries
|
||||
System.loadLibrary("FlaxGame");
|
||||
System.loadLibrary("FlaxEngine");
|
||||
} catch (UnsatisfiedLinkError error) {
|
||||
Log.e("Flax", error.getMessage());
|
||||
}
|
||||
|
||||
@@ -76,10 +76,10 @@ namespace Flax.Build
|
||||
/// <inheritdoc />
|
||||
public override string GetOutputFilePath(BuildOptions options, TargetOutputType? outputType)
|
||||
{
|
||||
var useSeparateMainExe = UseSeparateMainExecutable(options);
|
||||
var asLib = UseSeparateMainExecutable(options) || BuildAsLibrary(options);
|
||||
|
||||
// If building engine executable for platform doesn't support referencing it when linking game shared libraries
|
||||
if (outputType == null && useSeparateMainExe)
|
||||
if (outputType == null && asLib)
|
||||
{
|
||||
// Build into shared library
|
||||
outputType = TargetOutputType.Library;
|
||||
@@ -87,7 +87,7 @@ namespace Flax.Build
|
||||
|
||||
// Override output name to shared library name when building library for the separate main executable
|
||||
var outputName = OutputName;
|
||||
if (useSeparateMainExe && (outputType ?? OutputType) == TargetOutputType.Library)
|
||||
if (asLib && (outputType ?? OutputType) == TargetOutputType.Library)
|
||||
OutputName = LibraryName;
|
||||
|
||||
var result = base.GetOutputFilePath(options, outputType);
|
||||
@@ -101,7 +101,7 @@ namespace Flax.Build
|
||||
base.SetupTargetEnvironment(options);
|
||||
|
||||
// If building engine executable for platform doesn't support referencing it when linking game shared libraries
|
||||
if (UseSeparateMainExecutable(options))
|
||||
if (UseSeparateMainExecutable(options) || BuildAsLibrary(options))
|
||||
{
|
||||
// Build into shared library
|
||||
options.LinkEnv.Output = LinkerOutput.SharedLibrary;
|
||||
@@ -127,7 +127,7 @@ namespace Flax.Build
|
||||
base.PostBuild(graph, buildOptions);
|
||||
|
||||
// If building engine executable for platform doesn't support referencing it when linking game shared libraries
|
||||
if (UseSeparateMainExecutable(buildOptions))
|
||||
if (UseSeparateMainExecutable(buildOptions) && !BuildAsLibrary(buildOptions))
|
||||
{
|
||||
// Build additional executable with Main module only that uses shared library
|
||||
using (new ProfileEventScope("BuildExecutable"))
|
||||
@@ -152,6 +152,16 @@ namespace Flax.Build
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool BuildAsLibrary(BuildOptions buildOptions)
|
||||
{
|
||||
switch (buildOptions.Platform.Target)
|
||||
{
|
||||
case TargetPlatform.UWP:
|
||||
case TargetPlatform.Android: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildMainExecutable(TaskGraph graph, BuildOptions buildOptions)
|
||||
{
|
||||
if (IsPreBuilt)
|
||||
|
||||
@@ -35,9 +35,12 @@ namespace Flax.Deploy
|
||||
// For Linux don't deploy engine libs used by C++ scripting linking (engine source required)
|
||||
if (platform == TargetPlatform.Linux)
|
||||
{
|
||||
File.Delete(Path.Combine(dst, "Binaries", "Game", "x64", "Debug", "FlaxGame.a"));
|
||||
File.Delete(Path.Combine(dst, "Binaries", "Game", "x64", "Development", "FlaxGame.a"));
|
||||
File.Delete(Path.Combine(dst, "Binaries", "Game", "x64", "Release", "FlaxGame.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Debug", "FlaxGame.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Development", "FlaxGame.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Release", "FlaxGame.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Debug", "FlaxEngine.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Development", "FlaxEngine.a"));
|
||||
Utilities.FileDelete(Path.Combine(dst, "Binaries", "Game", "x64", "Release", "FlaxEngine.a"));
|
||||
}
|
||||
|
||||
// Sign binaries
|
||||
@@ -62,15 +65,15 @@ namespace Flax.Deploy
|
||||
{
|
||||
var binaries = Path.Combine(dst, "Binaries", "Game", "arm64", "Debug");
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame.dylib"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxEngine.dylib"));
|
||||
|
||||
binaries = Path.Combine(dst, "Binaries", "Game", "arm64", "Development");
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame.dylib"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxEngine.dylib"));
|
||||
|
||||
binaries = Path.Combine(dst, "Binaries", "Game", "arm64", "Release");
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxGame.dylib"));
|
||||
CodeSign(Path.Combine(binaries, "FlaxEngine.dylib"));
|
||||
}
|
||||
|
||||
// Don't distribute engine deps
|
||||
|
||||
@@ -396,7 +396,7 @@ namespace Flax.Build.Platforms
|
||||
rpathTask.DependentTasks.Add(lastTask);
|
||||
lastTask = rpathTask;
|
||||
}
|
||||
// TODO: fix dylib ID: 'install_name_tool -id @rpath/FlaxGame.dylib FlaxGame.dylib'
|
||||
// TODO: fix dylib ID: 'install_name_tool -id @rpath/FlaxEngine.dylib FlaxEngine.dylib'
|
||||
if (!options.LinkEnv.DebugInformation)
|
||||
{
|
||||
// Strip debug symbols
|
||||
|
||||
Reference in New Issue
Block a user