Add debug flag when building emscripten in debug mode.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
973813f0b5
commit
2e3e8dd910
@ -2233,31 +2233,35 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
HANDLE hLogFile;
|
#ifndef __EMSCRIPTEN__
|
||||||
hLogFile = CreateFile(L"assets/memoryleak.txt", GENERIC_WRITE,
|
#ifndef __linux__
|
||||||
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
HANDLE hLogFile;
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
hLogFile = CreateFile(L"assets/memoryleak.txt", GENERIC_WRITE,
|
||||||
_CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE);
|
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
||||||
_CrtSetReportFile(_CRT_WARN,hLogFile);
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
_CrtDumpMemoryLeaks();
|
_CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE);
|
||||||
CloseHandle(hLogFile);
|
_CrtSetReportFile(_CRT_WARN,hLogFile);
|
||||||
|
_CrtDumpMemoryLeaks();
|
||||||
std::ifstream file("assets/memoryleak.txt");
|
CloseHandle(hLogFile);
|
||||||
bool leaked=false;
|
|
||||||
while(file.good()){
|
std::ifstream file("assets/memoryleak.txt");
|
||||||
std::string line;
|
bool leaked=false;
|
||||||
std::getline(file,line);
|
while(file.good()){
|
||||||
if(line.find("AiL\\")!=std::string::npos){
|
std::string line;
|
||||||
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::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
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,9 +44,17 @@ All rights reserved.
|
|||||||
#include <source_location>
|
#include <source_location>
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
|
#ifndef __EMSCRIPTEN__
|
||||||
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
|
#ifndef __linux__
|
||||||
// allocations to be of _CLIENT_BLOCK type
|
#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
|
#else
|
||||||
#define NEW new
|
#define NEW new
|
||||||
#endif
|
#endif
|
||||||
|
@ -120,7 +120,7 @@ debug_access_options = 0
|
|||||||
debug_menu_navigation_info = 0
|
debug_menu_navigation_info = 0
|
||||||
|
|
||||||
# Shows map loading output
|
# Shows map loading output
|
||||||
debug_map_load_info = 1
|
debug_map_load_info = 0
|
||||||
|
|
||||||
# Shows state transition information
|
# Shows state transition information
|
||||||
debug_transition_info = 0
|
debug_transition_info = 0
|
||||||
|
@ -311,6 +311,12 @@ if (EMSCRIPTEN)
|
|||||||
|
|
||||||
# Build Cache: SDL2_mixer, libpng, zlib
|
# Build Cache: SDL2_mixer, libpng, zlib
|
||||||
execute_process(COMMAND "${EMSCRIPTEN_ROOT_PATH}/embuilder${EMCC_SUFFIX}" build sdl2_mixer freetype 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}")
|
if(EXISTS "${SOURCE_DATA_DIR}" AND IS_DIRECTORY "${SOURCE_DATA_DIR}")
|
||||||
target_link_options(
|
target_link_options(
|
||||||
|
2
debug.sh
2
debug.sh
@ -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
|
clear
|
||||||
emcmake cmake -DCMAKE_BUILD_TYPE=Debug .
|
emcmake cmake -DCMAKE_BUILD_TYPE=Debug -D_DEBUG=1 .
|
||||||
cmake --build . -j 8
|
cmake --build . -j 8
|
Loading…
x
Reference in New Issue
Block a user