From 11374664725d1fa3219dcebb40042932290a6c70 Mon Sep 17 00:00:00 2001 From: Patedam Date: Wed, 7 Jan 2026 19:46:12 -0500 Subject: [PATCH] Fastbuild all work for static linking Need : Dll for game and lib to do hot reload Need : static for release only Way to compile only julietapp only shader app, only juliet.dll and game.dll --- External/SDK/VisualStudio/VS2022.bff | 10 +++ Game/Entity/Entity.h | 2 +- Game/Entity/EntityManager.cpp | 2 +- Game/Game.bff | 51 ++++++++++++++ Game/game.cpp | 6 +- Juliet/Juliet.bff | 6 +- Juliet/include/Core/Common/CRC32.h | 2 +- JulietApp/JulietApp.bff | 102 +++++++++++++++++++++++++++ JulietApp/main.cpp | 4 +- fbuild.bff | 22 +++--- 10 files changed, 186 insertions(+), 21 deletions(-) create mode 100644 Game/Game.bff create mode 100644 JulietApp/JulietApp.bff diff --git a/External/SDK/VisualStudio/VS2022.bff b/External/SDK/VisualStudio/VS2022.bff index c36b6b7..ee13134 100644 --- a/External/SDK/VisualStudio/VS2022.bff +++ b/External/SDK/VisualStudio/VS2022.bff @@ -186,6 +186,16 @@ Compiler( 'Compiler-VS2022-ARM64' ) + ' libvcruntime.lib' + ' libucrt.lib' + .CRTLibs_Dynamic = ' msvcrt.lib' + + ' vcruntime.lib' + + ' ucrt.lib' + + ' msvcprt.lib' + + .CRTLibs_DynamicDebug = ' msvcrtd.lib' + + ' vcruntimed.lib' + + ' ucrtd.lib' + + ' msvcprtd.lib' + // File Extensions .LibExtension = '.lib' .ExeExtension = '.exe' diff --git a/Game/Entity/Entity.h b/Game/Entity/Entity.h index 4e1db31..03c167a 100644 --- a/Game/Entity/Entity.h +++ b/Game/Entity/Entity.h @@ -8,7 +8,7 @@ #include // Add any new fields into the concept below -#define DECLARE_ENTITY(entity) \ +#define DECLARE_ENTITY() \ Entity* Base; \ static const Juliet::Class* Kind; diff --git a/Game/Entity/EntityManager.cpp b/Game/Entity/EntityManager.cpp index e41b908..556412a 100644 --- a/Game/Entity/EntityManager.cpp +++ b/Game/Entity/EntityManager.cpp @@ -18,7 +18,7 @@ namespace Game return Manager; } - void RegisterEntity(EntityManager& manager, Entity* entity) + void RegisterEntity(EntityManager& /*manager*/, Entity* entity) { entity->ID = EntityManager::ID++; } diff --git a/Game/Game.bff b/Game/Game.bff new file mode 100644 index 0000000..cb441ad --- /dev/null +++ b/Game/Game.bff @@ -0,0 +1,51 @@ +// Juliet - Lib +//------------------------------------------------------------------------------ +{ + .ProjectName = 'Game' + .ProjectPath = 'Game' + .JulietIncludePath = ' "-IJuliet/include"' + + // Library + //-------------------------------------------------------------------------- + .ProjectConfigs = {} + ForEach( .BuildConfig in .BuildConfigs ) + { + Using( .BuildConfig ) + .OutputBase + '\$Platform$-$BuildConfigName$' + + // Unity + //-------------------------------------------------------------------------- + Unity( '$ProjectName$-Unity-$Platform$-$BuildConfigName$' ) + { + .UnityInputPath = '$ProjectPath$/' + .UnityOutputPath = '$OutputBase$/$ProjectPath$/' + .UnityOutputPattern = '$ProjectName$_Unity*.cpp' + } + + // Library + //-------------------------------------------------------------------------- + ObjectList( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' ) + { + // Input (Unity) + .CompilerInputUnity = '$ProjectName$-Unity-$Platform$-$BuildConfigName$' + + // Extra Compiler Options + .CompilerOptions + .JulietIncludePath + + ' "-IGame"' + + #if __WINDOWS__ + .CompilerOptions + ' -DJULIET_WIN32' + #endif + + // Output + .CompilerOutputPath = '$OutputBase$/$ProjectPath$/' + } + Alias( '$ProjectName$-$Platform$-$BuildConfigName$' ) { .Targets = '$ProjectName$-Lib-$Platform$-$BuildConfigName$' } + ^'Targets_$Platform$_$BuildConfigName$' + { '$ProjectName$-$Platform$-$BuildConfigName$' } + + #if __WINDOWS__ + .ProjectConfig = [ Using( .'Project_$Platform$_$BuildConfigName$' ) .Target = '$ProjectName$-$Platform$-$BuildConfigName$' ] + ^ProjectConfigs + .ProjectConfig + #endif + } +} \ No newline at end of file diff --git a/Game/game.cpp b/Game/game.cpp index 8dec9dc..8a6703f 100644 --- a/Game/game.cpp +++ b/Game/game.cpp @@ -1,5 +1,5 @@ #include -#include // TODO: remove because our dll should not be platform dependant +#include // TODO: remove because our dll should not be platform dependant #undef min #undef max @@ -42,7 +42,7 @@ extern "C" __declspec(dllexport) void __cdecl GameInit() door->IsOpened = true; Entity* ent = door->Base; - Door* stillDoor = DownCast(ent); + [[maybe_unused]] Door* stillDoor = DownCast(ent); Assert(door == stillDoor); Rock* rock = MakeEntity(manager, 1.f, 2.f); @@ -64,7 +64,7 @@ extern "C" __declspec(dllexport) void __cdecl GameShutdown() printf("Shutting down game...\n"); } -extern "C" __declspec(dllexport) void __cdecl GameUpdate(float deltaTime) +extern "C" __declspec(dllexport) void __cdecl GameUpdate([[maybe_unused]] float deltaTime) { //printf("Updating game...\n"); } diff --git a/Juliet/Juliet.bff b/Juliet/Juliet.bff index e6da80b..3b2eb90 100644 --- a/Juliet/Juliet.bff +++ b/Juliet/Juliet.bff @@ -25,7 +25,7 @@ // Library //-------------------------------------------------------------------------- - ObjectList( '$ProjectName$-CPP-$Platform$-$BuildConfigName$' ) + ObjectList( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' ) { // Input (Unity) .CompilerInputUnity = '$ProjectName$-Unity-$Platform$-$BuildConfigName$' @@ -41,10 +41,6 @@ // Output .CompilerOutputPath = '$OutputBase$/$ProjectPath$/' } - Alias( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' ) - { - .Targets = { '$ProjectName$-CPP-$Platform$-$BuildConfigName$' } - } Alias( '$ProjectName$-$Platform$-$BuildConfigName$' ) { .Targets = '$ProjectName$-Lib-$Platform$-$BuildConfigName$' } ^'Targets_$Platform$_$BuildConfigName$' + { '$ProjectName$-$Platform$-$BuildConfigName$' } diff --git a/Juliet/include/Core/Common/CRC32.h b/Juliet/include/Core/Common/CRC32.h index c2c0117..3cc2403 100644 --- a/Juliet/include/Core/Common/CRC32.h +++ b/Juliet/include/Core/Common/CRC32.h @@ -45,7 +45,7 @@ namespace Juliet uint32_t crc = ~0U; while (length--) { - crc = details::crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + crc = details::crc32_tab[(crc ^ static_cast(*p++)) & 0xFF] ^ (crc >> 8); } return crc ^ ~0U; } diff --git a/JulietApp/JulietApp.bff b/JulietApp/JulietApp.bff new file mode 100644 index 0000000..5c32a51 --- /dev/null +++ b/JulietApp/JulietApp.bff @@ -0,0 +1,102 @@ +// Juliet - Lib +//------------------------------------------------------------------------------ +{ + .ProjectName = 'JulietApp' + .ProjectPath = 'JulietApp' + .JulietIncludePath = ' "-IJuliet/include"' + .ProjectDefPath = '$_WORKING_DIR_$/$ProjectName$/$ProjectName$.def' + + // Library + //-------------------------------------------------------------------------- + .ProjectConfigs = {} + ForEach( .BuildConfig in .BuildConfigs ) + { + Using( .BuildConfig ) + .OutputBase + '\$Platform$-$BuildConfigName$' + + // Unity + //-------------------------------------------------------------------------- + Unity( '$ProjectName$-Unity-$Platform$-$BuildConfigName$' ) + { + .UnityInputPath = '$ProjectPath$/' + .UnityOutputPath = '$OutputBase$/$ProjectPath$/' + .UnityOutputPattern = '$ProjectName$_Unity*.cpp' + } + + // Library + //-------------------------------------------------------------------------- + ObjectList( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' ) + { + // Input (Unity) + .CompilerInputUnity = '$ProjectName$-Unity-$Platform$-$BuildConfigName$' + + // Extra Compiler Options + .CompilerOptions + .JulietIncludePath + + #if __WINDOWS__ + .CompilerOptions + ' -DJULIET_WIN32' + #endif + + // Output + .CompilerOutputPath = '$OutputBase$/$ProjectPath$/' + } + + // Windows Manifest + //-------------------------------------------------------------------------- + #if __WINDOWS__ + .ManifestFile = '$OutputBase$/$ProjectPath$/$ProjectName$$ExeExtension$.manifest.tmp' + //CreateManifest( '$ProjectName$-Manifest-$Platform$-$BuildConfigName$' + // .ManifestFile ) + #endif + + // Executable + //-------------------------------------------------------------------------- + Executable( '$ProjectName$-Exe-$Platform$-$BuildConfigName$' ) + { + .Libraries = { + 'JulietApp-Lib-$Platform$-$BuildConfigName$', + 'Juliet-Lib-$Platform$-$BuildConfigName$', + 'Game-Lib-$Platform$-$BuildConfigName$' + } + + .LinkerOutput = '$OutputBase$/$ProjectPath$/JulietApp$ExeExtension$' + + // TODO : Only use when using DLL and not static link + //.LinkerOptions + ' /DEF:"$ProjectDefPath$"' + + #if __WINDOWS__ + .LinkerOptions + ' /SUBSYSTEM:CONSOLE' + + ' kernel32.lib' + + ' user32.lib' + + + ' gdi32.lib' + + + ' dxguid.lib' + + ' Ws2_32.lib' + + ' dxgi.lib' + //+ .CRTLibs_Static + + // Chose appropriate CRT + .CRTLibs = .CRTLibs_Dynamic + If ( .BuildConfigName == 'Debug' ) + { + ^CRTLibs = .CRTLibs_DynamicDebug + } + .LinkerOptions + .CRTLibs + + // Manifest + .LinkerAssemblyResources = .ManifestFile + .LinkerOptions + ' /MANIFEST:EMBED' + // + ' /MANIFESTINPUT:%3' + #endif + } + + Alias( '$ProjectName$-$Platform$-$BuildConfigName$' ) { .Targets = '$ProjectName$-Exe-$Platform$-$BuildConfigName$' } + ^'Targets_$Platform$_$BuildConfigName$' + { '$ProjectName$-$Platform$-$BuildConfigName$' } + + #if __WINDOWS__ + .ProjectConfig = [ Using( .'Project_$Platform$_$BuildConfigName$' ) .Target = '$ProjectName$-$Platform$-$BuildConfigName$' ] + ^ProjectConfigs + .ProjectConfig + #endif + } +} \ No newline at end of file diff --git a/JulietApp/main.cpp b/JulietApp/main.cpp index 55d9e2a..2045816 100644 --- a/JulietApp/main.cpp +++ b/JulietApp/main.cpp @@ -1,4 +1,4 @@ -#include +#include "main.h" #include #include @@ -279,7 +279,7 @@ JulietApplication& GetEditorApplication() return EditorApplication; } -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { // Allow only one instance to be launched. // Need to create Mutex code in the lib because i dont want to include windows.h in this file anymore diff --git a/fbuild.bff b/fbuild.bff index 5b06776..e3dafd4 100644 --- a/fbuild.bff +++ b/fbuild.bff @@ -59,12 +59,12 @@ Settings #if __WINDOWS__ .Debug_Optimizations_MSVC = [ - .CompilerOptions = ' /MTd /Od /RTC1 /GS /Oy-' + .CompilerOptions = ' /MDd /Od /RTC1 /GS /Oy-' .CompilerOptionsC = .CompilerOptions ] .Profile_Optimizations_MSVC = [ - .CompilerOptions = ' /MT /Ox /Oy /Oi /GS- /GF /Gy /Gw /Zo' + .CompilerOptions = ' /MD /Ox /Oy /Oi /GS- /GF /Gy /Gw /Zo' .CompilerOptionsC = .CompilerOptions .LinkerOptions = ' /OPT:REF,ICF' ] @@ -83,7 +83,7 @@ Settings .Debug_Optimizations = [ #if __WINDOWS__ // Using clang-cl.exe on Windows - .CompilerOptions = ' /Od' + .CompilerOptions = ' /MDd /Od' #else .CompilerOptions = ' -O0' #endif @@ -92,6 +92,11 @@ Settings .Profile_Optimizations = [ .CompilerOptions = ' -O2' + + #if __WINDOWS__ // Using clang-cl.exe on Windows + .CompilerOptions + ' /MD' + #endif + .CompilerOptionsC = .CompilerOptions ] .Release_Optimizations = @@ -148,9 +153,9 @@ Settings [ .ProjectBuildCommand = 'cd ^$(SolutionDir)\..\..\Code\ & fbuild -vs -dist -monitor -cache ^$(ProjectName)-^$(Configuration)' .ProjectRebuildCommand = 'cd ^$(SolutionDir)\..\..\Code\ & fbuild -vs -dist -monitor -cache -clean ^$(ProjectName)-^$(Configuration)' - .OutputDirectory = '^$(SolutionDir)\Temp' - .IntermediateDirectory = '^$(SolutionDir)\Temp' - .BuildLogFile = '^$(SolutionDir)\Temp\^$(ProjectName)-^$(Configuration).log' + .OutputDirectory = '^$(SolutionDir)\Intermediate' + .IntermediateDirectory = '^$(SolutionDir)\Intermediate' + .BuildLogFile = '^$(SolutionDir)\Intermediate\^$(ProjectName)-^$(Configuration).log' .Platform = 'x64' .PlatformToolset = '$VS_PlatformToolset$' ] @@ -179,6 +184,8 @@ Settings // Include all projects to build #include "Juliet/Juliet.bff" +#include "Game/Game.bff" +#include "JulietApp/JulietApp.Bff" // Aliases : All-$Platform$-$Config$ //------------------------------------------------------------------------------ @@ -193,8 +200,7 @@ ForEach( .BuildConfig in .BuildConfigs ) //------------------------------------------------------------------------------ Alias( 'Exes' ) { - .Targets = { 'FBuildWorker-Debug', 'FBuildWorker-Profile', 'FBuildWorker-Release' - 'FBuild-Debug', 'FBuild-Profile', 'FBuild-Release' } + .Targets = { 'JulietApp-Debug', 'JulietApp-Profile', 'JulietApp-Release' } } // Aliases : All-$Platform$