Add debug flag when building emscripten in debug mode.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/35/head
Nic0Nic0Nii 10 months ago
parent 973813f0b5
commit 2e3e8dd910
  1. 50
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 14
      Adventures in Lestoria/Error.h
  3. 2
      Adventures in Lestoria/assets/config/configuration.txt
  4. 6
      CMakeLists.txt
  5. 2
      debug.sh
  6. 2
      emscripten_debug_build.ps1

@ -2233,31 +2233,35 @@ int main()
}
#ifdef _DEBUG
HANDLE hLogFile;
hLogFile = CreateFile(L"assets/memoryleak.txt", GENERIC_WRITE,
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
_CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN,hLogFile);
_CrtDumpMemoryLeaks();
CloseHandle(hLogFile);
std::ifstream file("assets/memoryleak.txt");
bool leaked=false;
while(file.good()){
std::string line;
std::getline(file,line);
if(line.find("AiL\\")!=std::string::npos){
if(!leaked){
leaked=true;
std::cout<<std::endl<<std::endl<<std::endl<<"Memory leak detected!"<<std::endl;
}
std::cout<<line<<std::endl;
#ifndef __EMSCRIPTEN__
#ifndef __linux__
HANDLE hLogFile;
hLogFile = CreateFile(L"assets/memoryleak.txt", GENERIC_WRITE,
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
_CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN,hLogFile);
_CrtDumpMemoryLeaks();
CloseHandle(hLogFile);
std::ifstream file("assets/memoryleak.txt");
bool leaked=false;
while(file.good()){
std::string line;
std::getline(file,line);
std::cout<<line<<std::endl;
if(line.find("AiL\\")!=std::string::npos){
if(!leaked){
leaked=true;
std::cout<<std::endl<<std::endl<<std::endl<<"Memory leak detected!"<<std::endl;
}
std::cout<<line<<std::endl;
std::getline(file,line);
std::cout<<line<<std::endl;
}
}
}
if(leaked)ERR("")
if(leaked)ERR("")
#endif
#endif
#endif
return 0;

@ -44,9 +44,17 @@ All rights reserved.
#include <source_location>
#ifdef _DEBUG
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#ifndef __EMSCRIPTEN__
#ifndef __linux__
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#else
#define NEW new
#endif
#else
#define NEW new
#endif
#else
#define NEW new
#endif

@ -120,7 +120,7 @@ debug_access_options = 0
debug_menu_navigation_info = 0
# Shows map loading output
debug_map_load_info = 1
debug_map_load_info = 0
# Shows state transition information
debug_transition_info = 0

@ -311,6 +311,12 @@ if (EMSCRIPTEN)
# Build Cache: SDL2_mixer, libpng, zlib
execute_process(COMMAND "${EMSCRIPTEN_ROOT_PATH}/embuilder${EMCC_SUFFIX}" build sdl2_mixer freetype libpng zlib)
target_compile_definitions(
${OutputExecutable}
PUBLIC
$<$<CONFIG:Debug>:_DEBUG>
)
if(EXISTS "${SOURCE_DATA_DIR}" AND IS_DIRECTORY "${SOURCE_DATA_DIR}")
target_link_options(

@ -1 +1 @@
cmake -DCMAKE_BUILD_TYPE=Debug .;make -j 8
cmake -DCMAKE_BUILD_TYPE=Debug -D_DEBUG=1 .;make -j 8

@ -1,3 +1,3 @@
clear
emcmake cmake -DCMAKE_BUILD_TYPE=Debug .
emcmake cmake -DCMAKE_BUILD_TYPE=Debug -D_DEBUG=1 .
cmake --build . -j 8
Loading…
Cancel
Save