From 96b7f1180a6360a5ce5ec20eb91cbb5e689cdad2 Mon Sep 17 00:00:00 2001 From: Supermario1313 Date: Sun, 2 Oct 2022 23:45:28 +0200 Subject: [PATCH] Removed/changed comments and debug stuff and improved Makefile --- CMakeLists.txt | 13 ++---------- CrossCompilation/Makefile | 18 ++++++++--------- LunaDll/CMakeLists.txt | 1 - LunaDll/Misc/ErrorReporter.cpp | 2 +- LunaDll/Misc/RuntimeHook.h | 36 ++-------------------------------- 5 files changed, 14 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bbf275a..d3398949 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required (VERSION 3.7.2) project(LunaLua C CXX) -#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LunaLua_BINARY_DIR}") - if(NOT MSVC) message(FATAL_ERROR "NON-Microsoft Compilers are not supported right now") endif() @@ -11,9 +9,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() -# /Fd\"Release\\vc140.pdb\" -#set(CMAKE_CXX_FLAGS "" CACHE -# STRING "compiler flags" FORCE) + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /Gm- /O2 /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /EHsc /nologo /FAcs /Ot" CACHE STRING "compiler flags" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE @@ -23,8 +19,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) -#set(CMAKE_C_FLAGS "" CACHE -# STRING "compiler flags" FORCE) set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Zi /Gm- /O2 /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /EHsc /nologo /FAcs /Ot" CACHE STRING "compiler flags" FORCE) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE @@ -34,10 +28,7 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) -# /PDB:"C:\Repos\LunaLUA\Release\LunaDll.pdb" -#set(CMAKE_SHARED_LINKER_FLAGS "" CACHE -# STRING "compiler flags" FORCE) -set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/VERBOSE /NXCOMPAT /DYNAMICBASE /MAPINFO:EXPORTS /DEBUG /DLL /MACHINE:X86 /OPT:REF /SAFESEH:NO /INCREMENTAL:NO /SUBSYSTEM:WINDOWS\",5.01\" /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /MAP /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1" CACHE +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/NXCOMPAT /DYNAMICBASE /MAPINFO:EXPORTS /DEBUG /DLL /MACHINE:X86 /OPT:REF /SAFESEH:NO /INCREMENTAL:NO /SUBSYSTEM:WINDOWS\",5.01\" /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /MAP /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1" CACHE STRING "compiler flags" FORCE) set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}" CACHE STRING "compiler flags" FORCE) diff --git a/CrossCompilation/Makefile b/CrossCompilation/Makefile index 91f6b20a..e0623ff3 100644 --- a/CrossCompilation/Makefile +++ b/CrossCompilation/Makefile @@ -1,14 +1,13 @@ .PHONY: all clean -.EXPORT_ALL_VARIABLES: +CURRENT_FOLDER = $(shell pwd) +export MSVC_BASE = $(CURRENT_FOLDER)/msvc +export WINSDK_BASE = $(CURRENT_FOLDER)/winsdk +export WINSDK_VER = v7.1A +export HOST_ARCH = x86 +export MSVC_VER = 1900 -MSVC_BASE = $(shell pwd)/msvc -WINSDK_BASE = $(shell pwd)/winsdk -WINSDK_VER = v7.1A -HOST_ARCH = x86 -MSVC_VER = 1900 - -all: LunaDLL.dll +all: compile_commands.json LunaDLL.dll LunaDLL.dll: build/build.ninja cmake --build build @@ -19,8 +18,9 @@ compile_commands.json: build/build.ninja build/build.ninja: mkdir -p build cd build && cmake ../.. -G Ninja \ - -DCMAKE_TOOLCHAIN_FILE=$(shell pwd)/clang-cl-msvc.cmake \ + -DCMAKE_TOOLCHAIN_FILE=$(CURRENT_FOLDER)/clang-cl-msvc.cmake \ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 clean: rm -rf build + rm ../compile_commands.json diff --git a/LunaDll/CMakeLists.txt b/LunaDll/CMakeLists.txt index 9de2d00e..4e69ba52 100644 --- a/LunaDll/CMakeLists.txt +++ b/LunaDll/CMakeLists.txt @@ -297,7 +297,6 @@ target_link_libraries(LunaLuaLibShared odbccp32 winmm shlwapi - #libluabind lua51 dbghelp ws2_32 diff --git a/LunaDll/Misc/ErrorReporter.cpp b/LunaDll/Misc/ErrorReporter.cpp index 12197392..1d36238e 100644 --- a/LunaDll/Misc/ErrorReporter.cpp +++ b/LunaDll/Misc/ErrorReporter.cpp @@ -103,7 +103,7 @@ void ErrorReport::SnapshotError(EXCEPTION_RECORD* exception, CONTEXT* context) fullErrorDescription << "== Crash Summary ==\n"; fullErrorDescription << "LunaLua Version: " + std::string(LUNALUA_VERSION) + "\n"; #ifdef __clang__ - fullErrorDescription << "This LunaLua build has been compiled with Clang. Clang support is still experimental so errors might happen.\n"; + fullErrorDescription << "This LunaLua build has been compiled with Clang. Support for this compiler is still experimental so errors might happen.\n"; #endif fullErrorDescription << "Exception Code: 0x" << std::hex << exception->ExceptionCode; diff --git a/LunaDll/Misc/RuntimeHook.h b/LunaDll/Misc/RuntimeHook.h index eb5bff21..6a708551 100644 --- a/LunaDll/Misc/RuntimeHook.h +++ b/LunaDll/Misc/RuntimeHook.h @@ -187,20 +187,6 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookImpl() { "call %P[getRenderer]\n" // Pointer to the renderer is put in eax "mov ecx, eax\n" // The pointer to this is stored in ecx in the __thiscall convention - - /* - ".if %c[priorityAbove100]\n" - "push 0x7FEFFFFF\n" // Push most significant dword of DBL_MAX - "push 0xFFFFFFFF\n" // Push least significant dword of DBL_MAX - ".else\n" - "push eax\n" // Allocate the first 4 bytes on the stack for the priority argument of Renderer::RenderBelowPriority, the next four bytes will be allocated by push priority. - - // The following 3 instructions are for converting priority to a dfloat. - "push %c[priorityValue]\n" - "fild dword ptr [esp]\n" - "fstp qword ptr [esp]\n" - ".endif\n" - */ "push %c[PriorityMostSignificantDWord]\n" // Push most significant dword of priority "push %c[PriorityLeastSignificantDWord]\n" // Push least significant dword of priority @@ -214,9 +200,7 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookImpl() { "ret\n" ".att_syntax\n" : - : //[priorityAbove100] "i" (priority >= 100), - //[priorityValue] "i" (priority), - [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + : [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), [PriorityLeastSignificantDWord] "i" (DoubleLeastSignificantDWord(priority >= 100 ? DBL_MAX : priority)), [getRenderer] "i" (&Renderer::Get), [RenderBelowPriority] "i" (&Renderer::RenderBelowPriority) @@ -258,20 +242,6 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookWithSkipImpl() { "call %P[getRenderer]\n" // Pointer to the renderer is put in eax "mov ecx, eax\n" // The pointer to this is stored in ecx in the __thiscall convention - /* - ".if %c[priorityAbove100]\n" - "push 0x7FEFFFFF\n" // Push most significant dword of DBL_MAX - "push 0xFFFFFFFF\n" // Push least significant dword of DBL_MAX - ".else\n" - "push eax\n" // Allocate the first 4 bytes on the stack for the priority argument of Renderer::RenderBelowPriority, the next four bytes will be allocated by push priority. - - // The following 3 instructions are for converting priority to a dfloat. - "push %c[priorityValue]\n" - "fild dword ptr [esp]\n" - "fstp qword ptr [esp]\n" - ".endif\n" - */ - "push %c[PriorityMostSignificantDWord]\n" // Push most significant dword of priority "push %c[PriorityLeastSignificantDWord]\n" // Push least significant dword of priority @@ -289,9 +259,7 @@ _declspec(naked) static void __stdcall _RenderBelowPriorityHookWithSkipImpl() { "ret\n" ".att_syntax\n" : - : //[priorityAbove100] "i" (priority >= 100), - //[priorityValue] "i" (priority), - [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), + : [PriorityMostSignificantDWord] "i" (DoubleMostSignificantDWord(priority >= 100 ? DBL_MAX : priority)), [PriorityLeastSignificantDWord] "i" (DoubleLeastSignificantDWord(priority >= 100 ? DBL_MAX : priority)), [skipTargetAddrValue] "i" (skipTargetAddr), [skipAddrValue] "i" (skipAddr),