Fix Web build issues

This commit is contained in:
Wojtek Figat
2026-02-16 21:31:12 +01:00
parent 489c4a3661
commit 0835a6559c
4 changed files with 13 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ bool WebPlatformTools::IsNativeCodeFile(CookingData& data, const String& file)
void WebPlatformTools::OnBuildStarted(CookingData& data)
{
// Adjust the cooking output folder for the data files so file_packager tool can build the and output final data inside the cooker output folder
// Adjust the cooking output folder for the data files so file_packager tool can compress and output final data inside the cooker output folder
data.DataOutputPath = data.CacheDirectory / TEXT("Files");
}
@@ -122,11 +122,11 @@ bool WebPlatformTools::OnPostProcess(CookingData& data)
}
const String filesIncludeBegin = TEXT("// include: files.js");
const String filesIncludeEnd = TEXT("// end include: files.js");
String fileJs = data.OriginalOutputPath / TEXT("files.js");
if (!gameJsText.Contains(filesIncludeBegin))
{
// Insert generated files.js into the main game file after the minimum_runtime_check.js include
String fileJsText;
String fileJs = data.OriginalOutputPath / TEXT("files.js");
if (File::ReadAllText(fileJs, fileJsText))
{
data.Error(String::Format(TEXT("Failed to load file '{}'"), fileJs));
@@ -140,6 +140,9 @@ bool WebPlatformTools::OnPostProcess(CookingData& data)
gameJsText.Insert(location, fileJsText);
File::WriteAllText(gameJs, gameJsText, Encoding::UTF8);
}
// Remove the generated files.js as it's now included in the main game JS file
FileSystem::DeleteFile(fileJs);
}
const auto buildSettings = BuildSettings::Get();

View File

@@ -96,10 +96,10 @@ public class Platform : EngineModule
if (EngineConfiguration.WithSDL(options))
{
options.PublicDependencies.Add("SDL");
options.PrivateDependencies.Add("SDL");
options.SourcePaths.Add(Path.Combine(FolderPath, "SDL"));
if (options.Platform.Target == TargetPlatform.Linux)
options.PublicDependencies.Add("Wayland");
options.PrivateDependencies.Add("Wayland");
}
if (options.Target.IsEditor)
{

View File

@@ -49,7 +49,6 @@ CPUInfo WebPlatform::GetCPUInfo()
MemoryStats WebPlatform::GetMemoryStats()
{
// Mock memory stats
MemoryStats result;
result.TotalPhysicalMemory = emscripten_get_heap_max();
result.UsedPhysicalMemory = emscripten_get_heap_size();
@@ -116,7 +115,7 @@ void WebPlatform::GetSystemTime(int32& year, int32& month, int32& dayOfWeek, int
hour = time.tm_hour;
minute = time.tm_min;
second = time.tm_sec;
millisecond = (int64)emscripten_get_now() % 1000; // Fake it based on other timer
millisecond = abs((int64)emscripten_get_now()) % 1000; // Fake it based on other timer
}
void WebPlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond)
@@ -135,7 +134,7 @@ void WebPlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32&
hour = time.tm_hour;
minute = time.tm_min;
second = time.tm_sec;
millisecond = (int64)emscripten_get_now() % 1000; // Fake it based on other timer
millisecond = abs((int64)emscripten_get_now()) % 1000; // Fake it based on other timer
}
#if !BUILD_RELEASE

View File

@@ -153,6 +153,10 @@ namespace Flax.Build.Platforms
commonArgs.Add("-c");
AddSharedArgs(commonArgs, options, options.CompileEnv.DebugInformation, options.CompileEnv.Optimization);
// Hack to pull SDL3 port via emcc
if (options.CompileEnv.PreprocessorDefinitions.Contains("PLATFORM_SDL"))
commonArgs.Add("--use-port=sdl3");
}
// Add preprocessor definitions