Fixes for UWP build
This commit is contained in:
@@ -43,7 +43,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
const auto uwpDataPath = platformDataPath / (isXboxOne ? TEXT("XboxOne") : TEXT("UWP")) / TEXT("Binaries");
|
||||
const auto gameSettings = GameSettings::Get();
|
||||
const auto platformSettings = UWPPlatformSettings::Get();
|
||||
Array<byte> fileTemplate;
|
||||
StringAnsi fileTemplate;
|
||||
|
||||
// Copy binaries
|
||||
const auto binPath = data.GetGameBinariesPath();
|
||||
@@ -149,12 +149,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (!FileSystem::FileExists(dstAssemblyInfoPath))
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcAssemblyInfoPath, fileTemplate))
|
||||
if (File::ReadAllText(srcAssemblyInfoPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load AssemblyInfo.cs template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Write data to file
|
||||
auto file = FileWriteStream::Open(dstAssemblyInfoPath);
|
||||
@@ -163,7 +162,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
{
|
||||
auto now = DateTime::Now();
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, gameSettings->ProductName.ToStringAnsi()
|
||||
, gameSettings->CompanyName.ToStringAnsi()
|
||||
, now.GetYear()
|
||||
@@ -182,12 +181,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (!FileSystem::FileExists(dstAppPath))
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcAppPath, fileTemplate))
|
||||
if (File::ReadAllText(srcAppPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load App.cs template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Write data to file
|
||||
auto file = FileWriteStream::Open(dstAppPath);
|
||||
@@ -195,7 +193,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (file)
|
||||
{
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, defaultNamespace.ToStringAnsi() // {0} Default Namespace
|
||||
);
|
||||
hasError = file->HasError();
|
||||
@@ -211,12 +209,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
const auto srcFlaxGeneratedPath = uwpDataPath / TEXT("FlaxGenerated.cs");
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcFlaxGeneratedPath, fileTemplate))
|
||||
if (File::ReadAllText(srcFlaxGeneratedPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load FlaxGenerated.cs template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Prepare
|
||||
StringAnsi autoRotationPreferences;
|
||||
@@ -252,7 +249,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (file)
|
||||
{
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, autoRotationPreferences.Get()
|
||||
, preferredLaunchWindowingMode.Get()
|
||||
);
|
||||
@@ -272,12 +269,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (!FileSystem::FileExists(dstSolutionPath))
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcSolutionPath, fileTemplate))
|
||||
if (File::ReadAllText(srcSolutionPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load Solution.sln template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Write data to file
|
||||
auto file = FileWriteStream::Open(dstSolutionPath);
|
||||
@@ -285,7 +281,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (file)
|
||||
{
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, projectName.ToStringAnsi() // {0} Project Name
|
||||
, mode // {1} Platform Mode
|
||||
, projectGuid.ToStringAnsi() // {2} Project ID
|
||||
@@ -305,12 +301,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
const auto srcProjectPath = uwpDataPath / TEXT("Project.csproj");
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcProjectPath, fileTemplate))
|
||||
if (File::ReadAllText(srcProjectPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load Project.csproj template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Build included files data
|
||||
StringBuilder filesInclude(2048);
|
||||
@@ -334,7 +329,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (file)
|
||||
{
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, projectName.ToStringAnsi() // {0} Project Name
|
||||
, mode // {1} Platform Mode
|
||||
, projectGuid.Get() // {2} Project ID
|
||||
@@ -357,12 +352,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (!FileSystem::FileExists(dstManifestPath))
|
||||
{
|
||||
// Get template
|
||||
if (File::ReadAllBytes(srcManifestPath, fileTemplate))
|
||||
if (File::ReadAllText(srcManifestPath, fileTemplate))
|
||||
{
|
||||
data.Error(TEXT("Failed to load Package.appxmanifest template."));
|
||||
return true;
|
||||
}
|
||||
fileTemplate[fileTemplate.Count() - 1] = 0;
|
||||
|
||||
// Build included files data
|
||||
StringBuilder filesInclude(2048);
|
||||
@@ -385,7 +379,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
if (file)
|
||||
{
|
||||
file->WriteTextFormatted(
|
||||
(char*)fileTemplate.Get()
|
||||
fileTemplate.Get()
|
||||
, projectName.ToStringAnsi() // {0} Display Name
|
||||
, gameSettings->CompanyName.ToStringAnsi() // {1} Company Name
|
||||
, productId.ToStringAnsi() // {2} Product ID
|
||||
|
||||
@@ -65,22 +65,6 @@ void Game::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs
|
||||
|
||||
void Game::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
|
||||
{
|
||||
/*
|
||||
// Save app state asynchronously after requesting a deferral. Holding a deferral
|
||||
// indicates that the application is busy performing suspending operations. Be
|
||||
// aware that a deferral may not be held indefinitely. After about five seconds,
|
||||
// the app will be forced to exit.
|
||||
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
|
||||
|
||||
create_task([this, deferral]()
|
||||
{
|
||||
m_deviceResources->Trim();
|
||||
|
||||
m_main->Suspend();
|
||||
|
||||
deferral->Complete();
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
void Game::OnResuming(Platform::Object^ sender, Platform::Object^ args)
|
||||
@@ -396,9 +380,10 @@ int PlatformImpl::GetSpecialFolderPath(const SpecialFolder type, wchar_t* buffer
|
||||
path = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
|
||||
break;
|
||||
case SpecialFolder::ProgramData:
|
||||
path = Windows::Storage::ApplicationData::Current->RoamingFolder->Path;
|
||||
break;
|
||||
//case SpecialFolder::Temporary: path = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path; break;
|
||||
case SpecialFolder::Temporary:
|
||||
//path = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path;
|
||||
path = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
|
||||
break;
|
||||
}
|
||||
@@ -409,7 +394,7 @@ int PlatformImpl::GetSpecialFolderPath(const SpecialFolder type, wchar_t* buffer
|
||||
if (length >= bufferLength)
|
||||
length = bufferLength - 1;
|
||||
const wchar_t* data = path->Data();
|
||||
for (int i = 0; i<length; i++)
|
||||
for (int i = 0; i < length; i++)
|
||||
buffer[i] = data[i];
|
||||
buffer[length] = 0;
|
||||
return length;
|
||||
|
||||
@@ -318,14 +318,15 @@ void Win32Platform::Free(void* ptr)
|
||||
void* Win32Platform::AllocatePages(uint64 numPages, uint64 pageSize)
|
||||
{
|
||||
const uint64 numBytes = numPages * pageSize;
|
||||
|
||||
// Use VirtualAlloc to allocate page-aligned memory
|
||||
#if PLATFORM_UWP
|
||||
return VirtualAllocFromApp(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
#else
|
||||
return VirtualAlloc(nullptr, (SIZE_T)numBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Win32Platform::FreePages(void* ptr)
|
||||
{
|
||||
// Free page-aligned memory
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="Game.Build.json" />
|
||||
<None Include="WSACertificate.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>{3}
|
||||
@@ -70,7 +71,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\**" />
|
||||
<MonoDataFiles Include="Mono\**" />
|
||||
<MonoDataFiles Include="$(ProjectDir)Mono\**" />
|
||||
<DataSecondary Include="DataSecondary\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="Game.Build.json" />
|
||||
<None Include="WSACertificate.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>{3}
|
||||
@@ -70,7 +71,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\**" />
|
||||
<MonoDataFiles Include="Mono\**" />
|
||||
<MonoDataFiles Include="$(ProjectDir)Mono\**" />
|
||||
<DataSecondary Include="DataSecondary\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -67,10 +67,10 @@ namespace Flax.Build.Platforms
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("PLATFORM_UWP");
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("WINAPI_FAMILY=WINAPI_FAMILY_PC_APP");
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("_WINRT_DLL");
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("_WINDLL");
|
||||
options.CompileEnv.PreprocessorDefinitions.Add("__WRL_NO_DEFAULT_LIB__");
|
||||
|
||||
options.LinkEnv.InputLibraries.Add("WindowsApp.lib");
|
||||
options.LinkEnv.InputLibraries.Add("dloadhelper.lib");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,6 +680,8 @@ namespace Flax.Build.Platforms
|
||||
args.Add("/WINMD");
|
||||
args.Add(string.Format("/WINMDFILE:\"{0}\"", Path.ChangeExtension(outputFilePath, "winmd")));
|
||||
args.Add("/APPCONTAINER");
|
||||
if (linkEnvironment.Output == LinkerOutput.SharedLibrary)
|
||||
args.Add("/DYNAMICBASE");
|
||||
}
|
||||
|
||||
if (linkEnvironment.LinkTimeCodeGeneration)
|
||||
@@ -937,7 +939,7 @@ namespace Flax.Build.Platforms
|
||||
xmlTextWriter.WriteStartElement("Properties");
|
||||
|
||||
// TODO: better logo handling
|
||||
var logoSrcPath = Path.Combine(Environment.CurrentDirectory, "Source", "Logo.png");
|
||||
var logoSrcPath = Path.Combine(Globals.EngineRoot, "Source", "Logo.png");
|
||||
var logoDstPath = Path.Combine(options.IntermediateFolder, "Logo.png");
|
||||
if (!File.Exists(logoDstPath))
|
||||
Utilities.FileCopy(logoSrcPath, logoDstPath);
|
||||
|
||||
Reference in New Issue
Block a user