From 3357284b24ac8d0907c0a902a13d8c3549b4efe2 Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Sun, 27 Aug 2017 23:11:16 +0500 Subject: [PATCH] Implemented post-build symlink to assets folder for windows builds --- .dir-locals.el | 28 ++- README.md | 4 + build/genie.lua | 58 +++-- build/win_vs2017/Symmetry/Symmetry.sln | 28 --- build/win_vs2017/Symmetry/Symmetry.vcxproj | 193 ----------------- .../Symmetry/Symmetry.vcxproj.filters | 201 ------------------ src/common/hashmap.c | 6 +- src/game/file_io.c | 2 +- src/libsymmetry/scene.c | 4 +- 9 files changed, 73 insertions(+), 451 deletions(-) delete mode 100644 build/win_vs2017/Symmetry/Symmetry.sln delete mode 100644 build/win_vs2017/Symmetry/Symmetry.vcxproj delete mode 100644 build/win_vs2017/Symmetry/Symmetry.vcxproj.filters diff --git a/.dir-locals.el b/.dir-locals.el index c356c54..1ef497b 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,6 +1,22 @@ -((c-mode . - ((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include")) - (flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include"))) - ) - ((c++-mode . ((mode . c)))) - ) +(cond + ((string-equal system-type "windows-nt") ; Microsoft Windows + (progn + ((c-mode . + ((company-clang-arguments . ("-IE:/Projects/symmerty/include" "-IE:\\Projects\\symmerty\\third_party\\windows\\SDL2-2.0.5\\include")) + (flycheck-clang-include-path . ("E:/Projects/symmerty/include"))) + ) + ((c++-mode . ((mode . c)))) + ) + )) + ((string-equal system-type "gnu/linux") ; linux + (progn + ((c-mode . + ((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include")) + (flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include"))) + ) + ((c++-mode . ((mode . c)))) + ) + ))) + + + diff --git a/README.md b/README.md index 3d075d6..6ae2a35 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,10 @@ - ## TODO + - Implement file copy and file delete on windows and linux. + - Implement a work-around for dll locking on windows by creating a copy of the game lib at launch and when reloading, + unload the current dll, delete it and create new copy of the updated dll and load that. + - Find a solution for the asset import/export situation by either updating the blender exporter or adding assimp as dependancy - Fix bugs with sound sources not updating - Add creating distributable build and uploading to itch.io account support to GENie under windows and linux. - Remove hardcoded numerical values from sscanf and other format strings. diff --git a/build/genie.lua b/build/genie.lua index 0566b49..5ee501c 100644 --- a/build/genie.lua +++ b/build/genie.lua @@ -21,10 +21,10 @@ solution "Symmetry" local openal_lib_dir = "../third_party/windows/OpenAL/lib/" defines {"_CRT_SECURE_NO_WARNINGS"} - flags {"NoIncrementalLink"} + flags {"NoIncrementalLink", "NoEditAndContinue"} configuration "Debug" - if _ACTION ~= nil and _ACTION ~= "post_build_copy_dll" then + if (_ACTION ~= nil and _ACTION ~= "postbuild_copy") then os.mkdir(_ACTION .. "/debug") targetdir (_ACTION .. "/debug") end @@ -32,7 +32,7 @@ solution "Symmetry" flags { "Symbols" } configuration "Release" - if _ACTION ~= nil and _ACTION ~= "post_build_copy_dll" then + if (_ACTION ~= nil and _ACTION ~= "postbuild_copy") then os.mkdir(_ACTION .. "/release") targetdir (_ACTION .. "/release") end @@ -59,29 +59,53 @@ solution "Symmetry" links {"SDL2", "OpenAL32"} newaction { - trigger = "post_build_copy_dll", + trigger = "postbuild_copy", description = "Action to copy relevant dlls to executable directory after build", execute = function () - printf("Copying DLLs to executable directory...\n") + local copy_dest_dir = "" + local symlink_dest_dir = "" + + if(_ARGS[1] == "vs2017") then + copy_dest_dir = "vs2017" + symlink_dest_dir = "..\\..\\..\\assets" + printf("Copying DLLs to visual studio build directory...\n") + else + copy_dest_dir = "projects/qbs" + symlink_dest_dir = "..\\..\\..\\..\\assets" + printf("Copying DLLs to qbs build directory...\n") + end + local success = false - success = os.copyfile(sdl_lib_dir .. "SDL2.dll", "vs2017/debug/SDL2.dll") - success = os.copyfile(sdl_lib_dir .. "SDL2.dll", "vs2017/release/SDL2.dll") - success = os.copyfile("../third_party/windows/OpenAL/bin/OpenAL32.dll", "vs2017/debug/OpenAL32.dll") - success = os.copyfile("../third_party/windows/OpenAL/bin/OpenAL32.dll", "vs2017/release/OpenAL32.dll") + success = os.copyfile(sdl_lib_dir .. "SDL2.dll", copy_dest_dir .. "/debug/SDL2.dll") + success = os.copyfile(sdl_lib_dir .. "SDL2.dll", copy_dest_dir .. "/release/SDL2.dll") + success = os.copyfile("../third_party/windows/OpenAL/bin/OpenAL32.dll", copy_dest_dir .. "/debug/OpenAL32.dll") + success = os.copyfile("../third_party/windows/OpenAL/bin/OpenAL32.dll", copy_dest_dir .. "/release/OpenAL32.dll") if success ~= true then - printf("Copying dlls failed.") + printf("Copying one or more dlls failed.") else printf("Copying dlls successful.") end + + -- Create sym links + local output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\debug\\assets " .. symlink_dest_dir) + printf("MKlink debug output : %s", output) + output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\release\\assets " ..symlink_dest_dir) + printf("MKlink release output : %s", output) end } - postbuildcommands - { - _PREMAKE_COMMAND .. " post_build_copy_dll" - } - + if(_ACTION == "vs2017") then + postbuildcommands + { + _PREMAKE_COMMAND .. " postbuild_copy vs2017" + } + else + postbuildcommands + { + _PREMAKE_COMMAND .. " postbuild_copy qbs" + } + end ------------------------- -- libSymmetry ------------------------- @@ -92,5 +116,5 @@ solution "Symmetry" defines {"GAME_LIB"} files { "../src/common/**.c", "../src/common/**.h", "../src/libsymmetry/**.h", "../src/libsymmetry/**.c" } - configuration "Debug" - defines {"GL_DEBUG_CONTEXT", "AL_DEBUG"} + configuration "Debug" + defines {"GL_DEBUG_CONTEXT", "AL_DEBUG"} diff --git a/build/win_vs2017/Symmetry/Symmetry.sln b/build/win_vs2017/Symmetry/Symmetry.sln deleted file mode 100644 index cf280b7..0000000 --- a/build/win_vs2017/Symmetry/Symmetry.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Symmetry", "Symmetry.vcxproj", "{3244103F-4798-4086-A683-B11F168625D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3244103F-4798-4086-A683-B11F168625D3}.Debug|x64.ActiveCfg = Debug|x64 - {3244103F-4798-4086-A683-B11F168625D3}.Debug|x64.Build.0 = Debug|x64 - {3244103F-4798-4086-A683-B11F168625D3}.Debug|x86.ActiveCfg = Debug|Win32 - {3244103F-4798-4086-A683-B11F168625D3}.Debug|x86.Build.0 = Debug|Win32 - {3244103F-4798-4086-A683-B11F168625D3}.Release|x64.ActiveCfg = Release|x64 - {3244103F-4798-4086-A683-B11F168625D3}.Release|x64.Build.0 = Release|x64 - {3244103F-4798-4086-A683-B11F168625D3}.Release|x86.ActiveCfg = Release|Win32 - {3244103F-4798-4086-A683-B11F168625D3}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/build/win_vs2017/Symmetry/Symmetry.vcxproj b/build/win_vs2017/Symmetry/Symmetry.vcxproj deleted file mode 100644 index afb1e03..0000000 --- a/build/win_vs2017/Symmetry/Symmetry.vcxproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {3244103F-4798-4086-A683-B11F168625D3} - Symmetry - 10.0.14393.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - - - - - Level3 - Disabled - true - $(MSBuildProjectDirectory)\..\..\..\include;%(AdditionalIncludeDirectories) - USE_GLAD;_CRT_SECURE_NO_WARNINGS;AL_LIBTYPE_STATIC;AL_DEBUG;GL_DEBUG_CONTEXT;%(PreprocessorDefinitions) - MultiThreaded - - - $(MSBuildProjectDirectory)\..\..\..\libs\debug\win64_msvc;%(AdditionalLibraryDirectories) - version.lib;imm32.lib;winmm.lib;opengl32.lib;SDL2.lib;OpenAL32.lib;%(AdditionalDependencies) - Console - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - MultiThreaded - $(MSBuildProjectDirectory)\..\..\..\include;%(AdditionalIncludeDirectories) - USE_GLAD;_CRT_SECURE_NO_WARNINGS;AL_LIBTYPE_STATIC;%(PreprocessorDefinitions) - - - true - true - version.lib;imm32.lib;winmm.lib;opengl32.lib;SDL2.lib;OpenAL32.lib;%(AdditionalDependencies) - F:\Projects\symmetry\build\win_vs2017\Symmetry\..\..\..\libs\release\win64_msvc;%(AdditionalLibraryDirectories) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/win_vs2017/Symmetry/Symmetry.vcxproj.filters b/build/win_vs2017/Symmetry/Symmetry.vcxproj.filters deleted file mode 100644 index 5d30eeb..0000000 --- a/build/win_vs2017/Symmetry/Symmetry.vcxproj.filters +++ /dev/null @@ -1,201 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/src/common/hashmap.c b/src/common/hashmap.c index e19fa6c..9f8dbba 100644 --- a/src/common/hashmap.c +++ b/src/common/hashmap.c @@ -127,19 +127,19 @@ void hashmap_value_remove(struct Hashmap* hashmap, const char* key) } -void hashmap_float_set(struct Hashmap* hashmap, const char* key, float value) +void hashmap_float_set(struct Hashmap* hashmap, const char* key, const float value) { struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); variant_assign_float(&new_entry->value, value); } -void hashmap_int_set(struct Hashmap* hashmap, const char* key, int value) +void hashmap_int_set(struct Hashmap* hashmap, const char* key, const int value) { struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); variant_assign_int(&new_entry->value, value); } -void hashmap_double_set(struct Hashmap* hashmap, const char* key, double value) +void hashmap_double_set(struct Hashmap* hashmap, const char* key, const double value) { struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); variant_assign_double(&new_entry->value, value); diff --git a/src/game/file_io.c b/src/game/file_io.c index a6fd2f1..cf9e4d3 100644 --- a/src/game/file_io.c +++ b/src/game/file_io.c @@ -59,7 +59,7 @@ char* io_file_read(const int directory_type, const char* path, const char* mode, return data; } -FILE* io_file_open(int directory_type, const char* path, const char* mode) +FILE* io_file_open(const int directory_type, const char* path, const char* mode) { assert(directory_type >= 0 && directory_type <= DT_INSTALL); diff --git a/src/libsymmetry/scene.c b/src/libsymmetry/scene.c index f1653fd..caad57b 100644 --- a/src/libsymmetry/scene.c +++ b/src/libsymmetry/scene.c @@ -128,8 +128,8 @@ bool scene_load(const char* filename, int directory_type) FILE* entity_file = platform->file.open(directory_type, filename, "r"); if(!entity_file) { - log_error("scene:load", "Failed to open scenefile %s for writing", filename); - return NULL; + log_error("scene:load", "Failed to open scenefile %s for reading", filename); + return false; } struct Entity* root = entity_get(root_node);