diff --git a/build/android/build_depends_android.bat b/build/android/build_depends_android.bat index 5b220a1d1b..ab412b97db 100644 --- a/build/android/build_depends_android.bat +++ b/build/android/build_depends_android.bat @@ -13,7 +13,7 @@ set CONFIGURATION=%1 @echo Starting android dependencies build %CONFIGURATION% configuration... set ANDROID_NDK_VERSION=27.1.12297006 -set ANDROID_CMAKE_VERSION=3.30.3 +set ANDROID_CMAKE_VERSION=3.30.4 set ANDROID_PLATFORM_VERSION=21 set ANDROID_PLATFORM=android-%ANDROID_PLATFORM_VERSION% diff --git a/cmake/macro_template.cmake b/cmake/macro_template.cmake index 3bfd80c3ec..01ed1f45d2 100644 --- a/cmake/macro_template.cmake +++ b/cmake/macro_template.cmake @@ -780,8 +780,46 @@ MACRO(ADD_MENGINE_SHARED) SET(APPLICATION_DEPENDENCIES ${APPLICATION_DEPENDENCIES} ${PROJECT_NAME} PARENT_SCOPE) ENDMACRO() +MACRO(ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE) + ADD_DEFINITIONS(-DMENGINE_LIBRARY_NAME="${PROJECT_NAME}") + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") + + ADD_EXECUTABLE(${PROJECT_NAME} WIN32 ${SRC_FILES}) + + if(MSVC) + target_sources(${PROJECT_NAME} INTERFACE ${MENGINE_REPOSITORY}/contributing/codestyle/mengine.natvis) + endif() + + if(MENGINE_EXTERNAL_PDB) + if(MSVC) + set_target_properties(${PROJECT_NAME} PROPERTIES + COMPILE_PDB_NAME ${PROJECT_NAME} + PDB_OUTPUT_DIRECTORY ${MENGINE_EXTERNAL_PDB_PATH} + ) + elseif(MINGW) + target_compile_options(${PROJECT_NAME} PRIVATE -gcodeview) + target_link_options(${PROJECT_NAME} PRIVATE -Wl,-pdb=${MENGINE_EXTERNAL_PDB_PATH}/${PROJECT_NAME}.pdb) + endif() + else() + if(MENGINE_BUILD_TYPE_DEBUG) + if(MINGW) + target_compile_options(${PROJECT_NAME} PRIVATE -gcodeview) + target_link_options(${PROJECT_NAME} PRIVATE -Wl,-pdb=) + endif() + endif() + endif() + + IF(MSVC AND MENGINE_USE_PRECOMPILED_HEADER) + ADD_DEPENDENCIES(${PROJECT_NAME} PrecompiledHeader) + TARGET_LINK_LIBRARIES(${PROJECT_NAME} PrecompiledHeader) + ENDIF() +ENDMACRO() + MACRO(ADD_MENGINE_EXECUTABLE_WIN32) ADD_DEFINITIONS(-DMENGINE_LIBRARY_NAME="${PROJECT_NAME}") + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS") ADD_EXECUTABLE(${PROJECT_NAME} WIN32 ${SRC_FILES}) diff --git a/cmake/mingw64_template.cmake b/cmake/mingw64_template.cmake index cd70a7fa9d..3f3560238e 100644 --- a/cmake/mingw64_template.cmake +++ b/cmake/mingw64_template.cmake @@ -11,9 +11,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -femulated-tls -fuse-ld=lld -DWIN32 -D_WIN64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -femulated-tls -fuse-ld=lld -DWIN32 -D_WIN64 -m64") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O0") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O0 -UMBCS -D_UNICODE -DUNICODE") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O3 -DNDEBUG -UMBCS -D_UNICODE -DUNICODE") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O2 -DNDEBUG -UMBCS -D_UNICODE -DUNICODE") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") diff --git a/cmake/mingw_template.cmake b/cmake/mingw_template.cmake index 0bd5095dad..94539f3ec0 100644 --- a/cmake/mingw_template.cmake +++ b/cmake/mingw_template.cmake @@ -11,9 +11,9 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -femulated-tls -fuse-ld=lld -DWIN32 -m32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -femulated-tls -fuse-ld=lld -DWIN32 -m32") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O0 -D_DEBUG") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c11 -O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O0 -D_DEBUG -UMBCS -D_UNICODE -DUNICODE") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O3 -DNDEBUG -UMBCS -D_UNICODE -DUNICODE") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing -fomit-frame-pointer -std=c++17 -O2 -DNDEBUG -UMBCS -D_UNICODE -DUNICODE") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") \ No newline at end of file diff --git a/gradle/build.gradle b/gradle/build.gradle index 30e78a0c89..f4abfeb9d2 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -13,7 +13,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.6.1' + classpath 'com.android.tools.build:gradle:8.7.0' if (Utils.existAppPlugin(project, "MENGINE_APP_PLUGIN_GOOGLE_SERVICE") == true) { classpath 'com.google.gms:google-services:4.4.2' @@ -64,7 +64,7 @@ allprojects { if (ANDROID_APP_CMAKE_VERSION != null) { cmakeVersion = ANDROID_APP_CMAKE_VERSION } else { - cmakeVersion = "3.30.3" + cmakeVersion = "3.30.4" } if (ANDROID_APP_MULTIDEX_ENABLE != null) { diff --git a/gradle/gradle/wrapper/gradle-wrapper.properties b/gradle/gradle/wrapper/gradle-wrapper.properties index 52f3ef1999..cf6fe93754 100644 --- a/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Dec 21 15:34:45 EET 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/Interface/LoggerServiceInterface.h b/src/Interface/LoggerServiceInterface.h index 55b7c43396..cac8976a34 100644 --- a/src/Interface/LoggerServiceInterface.h +++ b/src/Interface/LoggerServiceInterface.h @@ -23,6 +23,10 @@ namespace Mengine virtual void setVerboseFilter( uint32_t _filter ) = 0; virtual uint32_t getVerboseFilter() const = 0; + public: + virtual void setThreadMode( bool _threadMode ) = 0; + virtual bool getThreadMode() const = 0; + public: virtual void setSilent( bool _silent ) = 0; virtual bool isSilent() const = 0; diff --git a/src/Kernel/AssertionAllocator.h b/src/Kernel/AssertionAllocator.h index cdd1773533..2664a44fb0 100644 --- a/src/Kernel/AssertionAllocator.h +++ b/src/Kernel/AssertionAllocator.h @@ -7,7 +7,7 @@ # include "Interface/UnknownAllocatorDebugReportInterface.h" # define MENGINE_ASSERTION_ALLOCATOR(C) ([=](){\ - UnknownAllocatorDebugReportInterface * debugReport = ALLOCATOR_SYSTEM()->getUnknown();\ + Mengine::UnknownAllocatorDebugReportInterface * debugReport = ALLOCATOR_SYSTEM()->getUnknown();\ if( debugReport == nullptr ){ return; }\ size_t alloc_count = debugReport->findAllocatorReportInfo( C );\ MENGINE_ASSERTION( alloc_count == 0, "'%s' memleak [%zu]", C , alloc_count);\ diff --git a/src/Kernel/AssertionCharacter.h b/src/Kernel/AssertionCharacter.h index c9dbd61d24..7ad07ed87f 100644 --- a/src/Kernel/AssertionCharacter.h +++ b/src/Kernel/AssertionCharacter.h @@ -18,9 +18,9 @@ namespace Mengine } } -# define MENGINE_ASSERTION_STANDARD_CHARACTER_SET(Value, Len) Detail::assertionStandardCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) -# define MENGINE_ASSERTION_LOWER_CHARACTER_SET(Value, Len) Detail::assertionLowerCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) -# define MENGINE_ASSERTION_UPPER_CHARACTER_SET(Value, Len) Detail::assertionUpperCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_STANDARD_CHARACTER_SET(Value, Len) Mengine::Detail::assertionStandardCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_LOWER_CHARACTER_SET(Value, Len) Mengine::Detail::assertionLowerCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_UPPER_CHARACTER_SET(Value, Len) Mengine::Detail::assertionUpperCharacterSet(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_STANDARD_CHARACTER_SET(Value, Len) # define MENGINE_ASSERTION_LOWER_CHARACTER_SET(Value, Len) diff --git a/src/Kernel/AssertionFactory.h b/src/Kernel/AssertionFactory.h index 4a3217477d..80d94529ab 100644 --- a/src/Kernel/AssertionFactory.h +++ b/src/Kernel/AssertionFactory.h @@ -14,7 +14,7 @@ namespace Mengine } } ////////////////////////////////////////////////////////////////////////// -# define MENGINE_ASSERTION_FACTORY_EMPTY(F) Detail::assertionFactoryEmpty(MENGINE_CODE_LIBRARY, F, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_FACTORY_EMPTY(F) Mengine::Detail::assertionFactoryEmpty(MENGINE_CODE_LIBRARY, F, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_FACTORY_EMPTY(F) #endif diff --git a/src/Kernel/AssertionIdentity.h b/src/Kernel/AssertionIdentity.h index ee80616766..6c57d1393a 100644 --- a/src/Kernel/AssertionIdentity.h +++ b/src/Kernel/AssertionIdentity.h @@ -17,7 +17,7 @@ namespace Mengine } } -# define MENGINE_ASSERTION_IDENTITY(Identity) Detail::assertionIdentity(MENGINE_CODE_LIBRARY, Identity, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_IDENTITY(Identity) Mengine::Detail::assertionIdentity(MENGINE_CODE_LIBRARY, Identity, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_IDENTITY(Identity) #endif \ No newline at end of file diff --git a/src/Kernel/AssertionResourceType.h b/src/Kernel/AssertionResourceType.h index 577a952753..9a7a9c9676 100644 --- a/src/Kernel/AssertionResourceType.h +++ b/src/Kernel/AssertionResourceType.h @@ -11,7 +11,7 @@ # define MENGINE_ASSERTION_RESOURCE_TYPE_BY_NAME( ResourceName, ResourceType, Ret, ... )\ if( RESOURCE_SERVICE()->hasResource(ConstString::none(), ResourceName, false, nullptr) == true )\ {\ - if( Helper::dynamicResourceCast(RESOURCE_SERVICE()->getResourceReference(ConstString::none(), ResourceName)) == nullptr )\ + if( Mengine::Helper::dynamicResourceCast(RESOURCE_SERVICE()->getResourceReference(Mengine::ConstString::none(), ResourceName)) == nullptr )\ {\ Mengine::Helper::Assertion(MENGINE_CODE_LIBRARY, Mengine::ASSERTION_LEVEL_FATAL, #ResourceType, MENGINE_CODE_FILE, MENGINE_CODE_LINE, __VA_ARGS__);\ return Ret;\ @@ -20,7 +20,7 @@ # define MENGINE_ASSERTION_RESOURCE_TYPE_BY_NAME_VOID( ResourceName, ResourceType, Ret, ... )\ if( RESOURCE_SERVICE()->hasResource(ConstString::none(), ResourceName, false, nullptr) == true )\ {\ - if( Helper::dynamicResourceCast(RESOURCE_SERVICE()->getResourceReference(ConstString::none(), ResourceName)) == nullptr )\ + if( Mengine::Helper::dynamicResourceCast(RESOURCE_SERVICE()->getResourceReference(Mengine::ConstString::none(), ResourceName)) == nullptr )\ {\ Mengine::Helper::Assertion(MENGINE_CODE_LIBRARY, Mengine::ASSERTION_LEVEL_FATAL, #ResourceType, MENGINE_CODE_FILE, MENGINE_CODE_LINE, __VA_ARGS__);\ return;\ diff --git a/src/Kernel/AssertionStatistic.h b/src/Kernel/AssertionStatistic.h index 48f6e87c3c..caba864a17 100644 --- a/src/Kernel/AssertionStatistic.h +++ b/src/Kernel/AssertionStatistic.h @@ -15,7 +15,7 @@ namespace Mengine } } -# define MENGINE_ASSERTION_STATISTIC_EMPTY(ID) Detail::assertionStatisticEmpty(MENGINE_CODE_LIBRARY, ID, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_STATISTIC_EMPTY(ID) Mengine::Detail::assertionStatisticEmpty(MENGINE_CODE_LIBRARY, ID, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_STATISTIC_EMPTY(ID) #endif \ No newline at end of file diff --git a/src/Kernel/AssertionType.h b/src/Kernel/AssertionType.h index 1cd335e5a0..a128cafa90 100644 --- a/src/Kernel/AssertionType.h +++ b/src/Kernel/AssertionType.h @@ -5,7 +5,7 @@ #if defined(MENGINE_ASSERTION_DEBUG_ENABLE) # include "Config/DynamicCast.h" -# define MENGINE_ASSERTION_TYPE(Ptr, Type, ...) if(Helper::dynamicCast(Ptr) == nullptr) Mengine::Helper::AssertionOperator( MENGINE_CODE_LIBRARY, Mengine::ASSERTION_LEVEL_FATAL, #Ptr " invalid type: '" #Type "'", MENGINE_CODE_FILE, MENGINE_CODE_LINE ) (__VA_ARGS__) +# define MENGINE_ASSERTION_TYPE(Ptr, Type, ...) if(Mengine::Helper::dynamicCast(Ptr) == nullptr) Mengine::Helper::AssertionOperator( MENGINE_CODE_LIBRARY, Mengine::ASSERTION_LEVEL_FATAL, #Ptr " invalid type: '" #Type "'", MENGINE_CODE_FILE, MENGINE_CODE_LINE ) (__VA_ARGS__) #else # define MENGINE_ASSERTION_TYPE(Ptr, Type, ...) #endif \ No newline at end of file diff --git a/src/Kernel/AssertionUtf8.h b/src/Kernel/AssertionUtf8.h index c2cba7a36b..f774c828aa 100644 --- a/src/Kernel/AssertionUtf8.h +++ b/src/Kernel/AssertionUtf8.h @@ -15,7 +15,7 @@ namespace Mengine } } -# define MENGINE_ASSERTION_VALIDATE_UTF8(Value, Len) Detail::assertionValidateUtf8(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_VALIDATE_UTF8(Value, Len) Mengine::Detail::assertionValidateUtf8(MENGINE_CODE_LIBRARY, Value, Len, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_VALIDATE_UTF8(Value, Len) #endif \ No newline at end of file diff --git a/src/Kernel/AssertionVSNPRINTF.h b/src/Kernel/AssertionVSNPRINTF.h index af15fc1b1b..db30785477 100644 --- a/src/Kernel/AssertionVSNPRINTF.h +++ b/src/Kernel/AssertionVSNPRINTF.h @@ -16,7 +16,7 @@ namespace Mengine } } -# define MENGINE_ASSERTION_VSNPRINTF(CAPACITY, FORMAT, ARGS) Detail::assertionVSNPRINTF(MENGINE_CODE_LIBRARY, CAPACITY, FORMAT, ARGS, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_VSNPRINTF(CAPACITY, FORMAT, ARGS) Mengine::Detail::assertionVSNPRINTF(MENGINE_CODE_LIBRARY, CAPACITY, FORMAT, ARGS, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_VSNPRINTF(CAPACITY, FORMAT, ARGS) #endif diff --git a/src/Kernel/AssertionVocabulary.h b/src/Kernel/AssertionVocabulary.h index 90823369ca..4c7cf4c012 100644 --- a/src/Kernel/AssertionVocabulary.h +++ b/src/Kernel/AssertionVocabulary.h @@ -16,7 +16,7 @@ namespace Mengine } } -# define MENGINE_ASSERTION_VOCABULARY_EMPTY(Key) Detail::assertionVocabularyEmpty(MENGINE_CODE_LIBRARY, Key, MENGINE_CODE_FILE, MENGINE_CODE_LINE) +# define MENGINE_ASSERTION_VOCABULARY_EMPTY(Key) Mengine::Detail::assertionVocabularyEmpty(MENGINE_CODE_LIBRARY, Key, MENGINE_CODE_FILE, MENGINE_CODE_LINE) #else # define MENGINE_ASSERTION_VOCABULARY_EMPTY(Key) #endif \ No newline at end of file diff --git a/src/Platforms/Win32Platform/Win32DynamicLibrary.cpp b/src/Platforms/Win32Platform/Win32DynamicLibrary.cpp index 0b6acf14d7..ef2c153ba7 100644 --- a/src/Platforms/Win32Platform/Win32DynamicLibrary.cpp +++ b/src/Platforms/Win32Platform/Win32DynamicLibrary.cpp @@ -48,8 +48,8 @@ namespace Mengine if( hInstance == NULL ) { - LOGGER_ERROR( "invalid load '%s' %ls" - , name + LOGGER_ERROR( "invalid load '%ls' %ls" + , unicode_name , Helper::Win32GetLastErrorMessageW() ); diff --git a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp index a133b640fd..6b1dff8afc 100644 --- a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp +++ b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp @@ -86,7 +86,7 @@ namespace Mengine full_output += outputFilePath; WChar command[MENGINE_MAX_COMMAND_LENGTH] = {'\0'}; - MENGINE_SWPRINTF( command, MENGINE_MAX_COMMAND_LENGTH, L"/nologo /T ps_1_1 /O3 /Gec /Fo \"%S\" \"%S\"" + MENGINE_SWPRINTF( command, MENGINE_MAX_COMMAND_LENGTH, L"/nologo /T ps_2_0 /O3 /Gec /Fo \"%S\" \"%S\"" , full_output.c_str() , full_input.c_str() ); diff --git a/src/Services/LoggerService/LoggerService.cpp b/src/Services/LoggerService/LoggerService.cpp index 952af24f60..3eff381bcd 100644 --- a/src/Services/LoggerService/LoggerService.cpp +++ b/src/Services/LoggerService/LoggerService.cpp @@ -60,6 +60,7 @@ namespace Mengine , m_silentMessageRelease( false ) , m_historically( true ) , m_threadly( false ) + , m_threadMode( MENGINE_BUILD_PUBLISH_VALUE( true, false ) ) { m_staticsticLevel[LM_SILENT] = STATISTIC_LOGGER_MESSAGE_SILENT; m_staticsticLevel[LM_FATAL] = STATISTIC_LOGGER_MESSAGE_FATAL; @@ -333,6 +334,16 @@ namespace Mengine return m_verboseFilter; } ////////////////////////////////////////////////////////////////////////// + void LoggerService::setThreadMode( bool _threadMode ) + { + m_threadMode = _threadMode; + } + ////////////////////////////////////////////////////////////////////////// + bool LoggerService::getThreadMode() const + { + return m_threadMode; + } + ////////////////////////////////////////////////////////////////////////// void LoggerService::setSilent( bool _silent ) { m_silent = _silent; @@ -524,11 +535,12 @@ namespace Mengine this->clearHistory(); -#if defined(MENGINE_BUILD_PUBLISH_ENABLE) - MENGINE_THREAD_MUTEX_SCOPE( m_mutexMessageBlock ); + if( m_threadMode == true ) + { + MENGINE_THREAD_MUTEX_SCOPE( m_mutexMessageBlock ); - m_threadly = true; -#endif + m_threadly = true; + } } ////////////////////////////////////////////////////////////////////////// void LoggerService::processMessages_( const ThreadIdentityRunnerInterfacePtr & _runner ) diff --git a/src/Services/LoggerService/LoggerService.h b/src/Services/LoggerService/LoggerService.h index 44a4cebf5a..0c1e23986c 100644 --- a/src/Services/LoggerService/LoggerService.h +++ b/src/Services/LoggerService/LoggerService.h @@ -34,6 +34,10 @@ namespace Mengine void setVerboseFilter( uint32_t _filter ) override; uint32_t getVerboseFilter() const override; + public: + void setThreadMode( bool _threadMode ) override; + bool getThreadMode() const override; + public: void setSilent( bool _silent ) override; bool isSilent() const override; @@ -126,6 +130,7 @@ namespace Mengine bool m_historically; bool m_threadly; + bool m_threadMode; MemoryInterfacePtr m_memoryOldLog; ContentInterfacePtr m_currentContentLog; diff --git a/src/Tools/AlphaPremultiplier/AlphaPremultiplier.cpp b/src/Tools/AlphaPremultiplier/AlphaPremultiplier.cpp index 9c32b0ec9b..5c43e087d9 100644 --- a/src/Tools/AlphaPremultiplier/AlphaPremultiplier.cpp +++ b/src/Tools/AlphaPremultiplier/AlphaPremultiplier.cpp @@ -1,4 +1,6 @@ -#include "ToolUtils/ToolUtils.h" +#include "Config/Config.h" + +#include "ToolUtils/ToolUtils.h" #define STBI_ONLY_PNG #define STB_IMAGE_IMPLEMENTATION @@ -10,12 +12,10 @@ #include ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - (void)hInstance; - (void)hPrevInstance; - (void)lpCmdLine; - (void)nShowCmd; + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); PWSTR pwCmdLine = ::GetCommandLineW(); diff --git a/src/Tools/AlphaPremultiplier/CMakeLists.txt b/src/Tools/AlphaPremultiplier/CMakeLists.txt index 83814d7fa9..cd35278a6a 100644 --- a/src/Tools/AlphaPremultiplier/CMakeLists.txt +++ b/src/Tools/AlphaPremultiplier/CMakeLists.txt @@ -11,6 +11,6 @@ add_definitions(-D_UNICODE) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/stb_image) LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) -ADD_EXECUTABLE(${PROJECT_NAME} WIN32 ${SRC_FILES}) +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ToolUtils) \ No newline at end of file diff --git a/src/Tools/AlphaSpreading/AlphaSpreading.cpp b/src/Tools/AlphaSpreading/AlphaSpreading.cpp index 2ec1b3f03f..5192971ca7 100644 --- a/src/Tools/AlphaSpreading/AlphaSpreading.cpp +++ b/src/Tools/AlphaSpreading/AlphaSpreading.cpp @@ -1,4 +1,6 @@ -#include "ToolUtils/ToolUtils.h" +#include "Config/Config.h" + +#include "ToolUtils/ToolUtils.h" #define STBI_ONLY_PNG #define STB_IMAGE_IMPLEMENTATION @@ -10,12 +12,10 @@ #include ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - (void)hInstance; - (void)hPrevInstance; - (void)lpCmdLine; - (void)nShowCmd; + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); PWSTR pwCmdLine = ::GetCommandLineW(); diff --git a/src/Tools/AlphaSpreading/CMakeLists.txt b/src/Tools/AlphaSpreading/CMakeLists.txt index 848939ff11..6e8beba6a5 100644 --- a/src/Tools/AlphaSpreading/CMakeLists.txt +++ b/src/Tools/AlphaSpreading/CMakeLists.txt @@ -11,6 +11,6 @@ add_definitions(-D_UNICODE) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/stb_image) LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ToolUtils) \ No newline at end of file diff --git a/src/Tools/AstralaxCompiler/AstralaxCompiler.cpp b/src/Tools/AstralaxCompiler/AstralaxCompiler.cpp index b05dd8c854..fb6a5a8d4b 100644 --- a/src/Tools/AstralaxCompiler/AstralaxCompiler.cpp +++ b/src/Tools/AstralaxCompiler/AstralaxCompiler.cpp @@ -40,12 +40,10 @@ extern "C" ////////////////////////////////////////////////////////////////////////// } ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - MENGINE_UNUSED( hInstance ); - MENGINE_UNUSED( hPrevInstance ); - MENGINE_UNUSED( lpCmdLine ); - MENGINE_UNUSED( nShowCmd ); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); PWSTR pwCmdLine = ::GetCommandLineW(); diff --git a/src/Tools/AstralaxCompiler/CMakeLists.txt b/src/Tools/AstralaxCompiler/CMakeLists.txt index ba80f32b7d..3fdd76c2bd 100644 --- a/src/Tools/AstralaxCompiler/CMakeLists.txt +++ b/src/Tools/AstralaxCompiler/CMakeLists.txt @@ -17,7 +17,7 @@ INCLUDE_DIRECTORIES( ) LINK_DIRECTORIES( ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() if(MENGINE_TOOLCHAIN_MINGW) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_DIR}/astralax/libmagic3d.a) diff --git a/src/Tools/DazzleCompiler/CMakeLists.txt b/src/Tools/DazzleCompiler/CMakeLists.txt index 9f40f465b7..cf71144c20 100644 --- a/src/Tools/DazzleCompiler/CMakeLists.txt +++ b/src/Tools/DazzleCompiler/CMakeLists.txt @@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/lz4/lib) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/dazzle/include) LINK_DIRECTORIES( ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}stdex${MENGINE_LIB_SUFFIX}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}lz4${MENGINE_LIB_SUFFIX}) diff --git a/src/Tools/DazzleCompiler/DazzleCompiler.cpp b/src/Tools/DazzleCompiler/DazzleCompiler.cpp index 0155f9c9cd..fcb02a6e9a 100644 --- a/src/Tools/DazzleCompiler/DazzleCompiler.cpp +++ b/src/Tools/DazzleCompiler/DazzleCompiler.cpp @@ -129,12 +129,10 @@ static bool writeCompress( const std::wstring & _filepath, const std::vector ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - MENGINE_UNUSED( hInstance ); - MENGINE_UNUSED( hPrevInstance ); - MENGINE_UNUSED( lpCmdLine ); - MENGINE_UNUSED( nShowCmd ); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); PWSTR pwCmdLine = ::GetCommandLineW(); diff --git a/src/Tools/ImageTrimmer/CMakeLists.txt b/src/Tools/ImageTrimmer/CMakeLists.txt index ee437f871e..161fa4dd5b 100644 --- a/src/Tools/ImageTrimmer/CMakeLists.txt +++ b/src/Tools/ImageTrimmer/CMakeLists.txt @@ -11,7 +11,7 @@ INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/tinyini/include) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/libmath/include) LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} Windows) TARGET_LINK_LIBRARIES(${PROJECT_NAME} Kernel) diff --git a/src/Tools/ImageTrimmer/ImageTrimmer.cpp b/src/Tools/ImageTrimmer/ImageTrimmer.cpp index 5f50f8f0ba..c8ecbb90bd 100644 --- a/src/Tools/ImageTrimmer/ImageTrimmer.cpp +++ b/src/Tools/ImageTrimmer/ImageTrimmer.cpp @@ -96,7 +96,7 @@ namespace Mengine SERVICE_CREATE( LoggerService, MENGINE_DOCUMENT_FUNCTION ); LOGGER_SERVICE() - ->setVerboseLevel( LM_WARNING ); + ->setVerboseLevel( LM_MESSAGE ); LOGGER_SERVICE() ->registerLogger( Helper::makeFactorableUnique( MENGINE_DOCUMENT_FUNCTION ) ); @@ -616,12 +616,10 @@ namespace Mengine } } ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - MENGINE_UNUSED( hInstance ); - MENGINE_UNUSED( hPrevInstance ); - MENGINE_UNUSED( lpCmdLine ); - MENGINE_UNUSED( nShowCmd ); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); try { diff --git a/src/Tools/Metawrite/CMakeLists.txt b/src/Tools/Metawrite/CMakeLists.txt index f57bfab1d1..a37d0d7815 100644 --- a/src/Tools/Metawrite/CMakeLists.txt +++ b/src/Tools/Metawrite/CMakeLists.txt @@ -10,7 +10,7 @@ add_definitions(-DMETABUF_EXTERNAL_CONFIG) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/tiniini/include) LINK_DIRECTORIES( ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} Kernel) diff --git a/src/Tools/Metawrite/Metawrite.cpp b/src/Tools/Metawrite/Metawrite.cpp index 5e9f9528aa..1c5adaa299 100644 --- a/src/Tools/Metawrite/Metawrite.cpp +++ b/src/Tools/Metawrite/Metawrite.cpp @@ -95,7 +95,7 @@ namespace Mengine SERVICE_CREATE( LoggerService, MENGINE_DOCUMENT_FUNCTION ); LOGGER_SERVICE() - ->setVerboseLevel( LM_WARNING ); + ->setVerboseLevel( LM_MESSAGE ); LOGGER_SERVICE() ->registerLogger( Helper::makeFactorableUnique( MENGINE_DOCUMENT_FUNCTION ) ); @@ -115,12 +115,10 @@ namespace Mengine } } ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - MENGINE_UNUSED( hInstance ); - MENGINE_UNUSED( hPrevInstance ); - MENGINE_UNUSED( lpCmdLine ); - MENGINE_UNUSED( nShowCmd ); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); try { diff --git a/src/Tools/MovieCompiler/CMakeLists.txt b/src/Tools/MovieCompiler/CMakeLists.txt index 0ca6c87edb..65992984c8 100644 --- a/src/Tools/MovieCompiler/CMakeLists.txt +++ b/src/Tools/MovieCompiler/CMakeLists.txt @@ -10,7 +10,7 @@ INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/lz4/lib) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/libmovie/include) LINK_DIRECTORIES( ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}stdex${MENGINE_LIB_SUFFIX}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}lz4${MENGINE_LIB_SUFFIX}) diff --git a/src/Tools/MovieCompiler/MovieCompiler.cpp b/src/Tools/MovieCompiler/MovieCompiler.cpp index 664ac31400..dd8c7b6843 100644 --- a/src/Tools/MovieCompiler/MovieCompiler.cpp +++ b/src/Tools/MovieCompiler/MovieCompiler.cpp @@ -128,12 +128,10 @@ static bool writeCompress( const std::wstring & _filepath, const std::vectorsetVerboseLevel( LM_MESSAGE ); + + LOGGER_SERVICE() + ->setThreadMode( false ); + LOGGER_SERVICE() ->registerLogger( Helper::makeFactorableUnique( MENGINE_DOCUMENT_FUNCTION ) ); @@ -428,9 +435,12 @@ static PyObject * py_writeBin( PyObject * _self, PyObject * _args ) wchar_t binPath[MENGINE_MAX_PATH] = {L'\0'}; PyUnicode_AsWideChar( py_binPath, binPath, MENGINE_MAX_PATH ); - Mengine::writeBin( protocolPath, xmlPath, binPath ); + if( Mengine::writeBin( protocolPath, xmlPath, binPath ) == false ) + { + return Py_False; + } - return Py_None; + return Py_True; } ////////////////////////////////////////////////////////////////////////// static PyObject * py_writeAek( PyObject * _self, PyObject * _args ) @@ -455,9 +465,12 @@ static PyObject * py_writeAek( PyObject * _self, PyObject * _args ) wchar_t aekPath[MENGINE_MAX_PATH] = {L'\0'}; PyUnicode_AsWideChar( py_aekPath, aekPath, MENGINE_MAX_PATH ); - Mengine::writeAek( protocolPath, xmlPath, aekPath ); + if( Mengine::writeAek( protocolPath, xmlPath, aekPath ) == false ) + { + return Py_False; + } - return Py_None; + return Py_True; } ////////////////////////////////////////////////////////////////////////// static PyObject * py_convert( PyObject * _self, PyObject * _args ) @@ -641,7 +654,7 @@ static PyObject * py_isPow2SquadImageFile( PyObject * _self, PyObject * _args ) const Mengine::ImageCodecDataInfo * dataInfo = imageDecoder->getCodecDataInfo(); uint32_t width = dataInfo->width; - uint32_t height = dataInfo->height; + uint32_t height = dataInfo->height; if( Mengine::Helper::isTexturePow2( width ) == false ) { @@ -661,9 +674,11 @@ static PyObject * py_isPow2SquadImageFile( PyObject * _self, PyObject * _args ) return Py_True; } ////////////////////////////////////////////////////////////////////////// -static void py_deleteImage( void * _ptr ) +static void py_deleteImage( PyObject * _capsule ) { - delete _ptr; + Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( _capsule, "Image" ); + + delete image; } ////////////////////////////////////////////////////////////////////////// static PyObject * py_loadImage( PyObject * _self, PyObject * _args ) @@ -705,11 +720,6 @@ static PyObject * py_saveImage( PyObject * _self, PyObject * _args ) Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( py_image, "Image" ); - if( image == nullptr ) - { - return nullptr; - } - const char * utf8_path = PyUnicode_AsUTF8AndSize( py_path, nullptr ); Mengine::FilePath c_path = Mengine::Helper::stringizeFilePath( utf8_path ); @@ -764,11 +774,6 @@ static PyObject * py_getImageWidth( PyObject * _self, PyObject * _args ) Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( py_image, "Image" ); - if( image == nullptr ) - { - return nullptr; - } - uint32_t width = image->getWidth(); return PyLong_FromUnsignedLongLong( width ); @@ -787,11 +792,6 @@ static PyObject * py_getImageHeight( PyObject * _self, PyObject * _args ) Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( py_image, "Image" ); - if( image == nullptr ) - { - return nullptr; - } - uint32_t height = image->getHeight(); return PyLong_FromUnsignedLongLong( height ); @@ -810,11 +810,6 @@ static PyObject * py_getImageChannels( PyObject * _self, PyObject * _args ) Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( py_image, "Image" ); - if( image == nullptr ) - { - return nullptr; - } - uint32_t channels = image->getChannels(); return PyLong_FromUnsignedLongLong( channels ); @@ -899,9 +894,9 @@ static PyObject * py_rotateImage( PyObject * _self, PyObject * _args ) Mengine::Image * image = (Mengine::Image *)PyCapsule_GetPointer( py_image, "Image" ); - bool result = image->rotate( angle ); + Mengine::Image * rotate_image = image->rotate( angle ); - return PyBool_FromLong( result ); + return PyCapsule_New( rotate_image, "Image", &py_deleteImage ); } ////////////////////////////////////////////////////////////////////////// static PyObject * py_getImageExtremColor( PyObject * _self, PyObject * _args ) @@ -970,7 +965,10 @@ static PyObject * py_splitImage( PyObject * _self, PyObject * _args ) Mengine::Image * imageAlpha; image->split( &imageRGB, &imageAlpha ); - return PyTuple_Pack( 2, PyCapsule_New( imageRGB, "Image", &py_deleteImage ), PyCapsule_New( imageAlpha, "Image", &py_deleteImage ) ); + PyObject * py_imageRGB = PyCapsule_New( imageRGB, "Image", &py_deleteImage ); + PyObject * py_imageAlpha = PyCapsule_New( imageAlpha, "Image", &py_deleteImage ); + + return PyTuple_Pack( 2, py_imageRGB, py_imageAlpha ); } ////////////////////////////////////////////////////////////////////////// static PyObject * py_releaseImage( PyObject * _self, PyObject * _args ) @@ -1079,6 +1077,19 @@ static PyObject * py_pathSHA1( PyObject * _self, PyObject * _args ) ////////////////////////////////////////////////////////////////////////// static char g_message[MENGINE_LOGGER_MAX_MESSAGE + 1] = {'\0'}; ////////////////////////////////////////////////////////////////////////// +bool is_ascii( const char * str ) +{ + while( *str ) + { + if( (unsigned char)*str > 0x7F ) + { + return false; + } + str++; + } + return true; +} +////////////////////////////////////////////////////////////////////////// static PyObject * py_log( PyObject * _self, PyObject * _args ) { (void)_self; @@ -1099,6 +1110,8 @@ static PyObject * py_log( PyObject * _self, PyObject * _args ) return Py_None; } + MENGINE_ASSERTION_VALIDATE_UTF8( g_message, MENGINE_UNKNOWN_SIZE ); + LOGGER_MESSAGE( "%s" , g_message ); @@ -1191,16 +1204,22 @@ static bool run() return false; } - LOGGER_ERROR( "initialize complete" ); + LOGGER_MESSAGE( "initialize complete" ); WCHAR currentPath[MENGINE_MAX_PATH] = {L'\0'}; DWORD len = ::GetCurrentDirectory( MENGINE_MAX_PATH, currentPath ); if( len == 0 ) { + LOGGER_MESSAGE( "invalid get current directory" ); + return false; } + LOGGER_MESSAGE( "current directory: %ls" + , currentPath + ); + currentPath[len + 0] = MENGINE_PATH_WDELIM; currentPath[len + 1] = L'\0'; @@ -1232,6 +1251,10 @@ static bool run() return false; } + LOGGER_MESSAGE( "load python dll '%ls'" + , python3DllPath + ); + Py_InitializeEx = (PY_INITIALIZEEX)::GetProcAddress( hPythonDll, "Py_InitializeEx" ); Py_GetPath = (PY_GETPATH)::GetProcAddress( hPythonDll, "Py_GetPath" ); Py_SetPath = (PY_SETPATH)::GetProcAddress( hPythonDll, "Py_SetPath" ); @@ -1275,19 +1298,25 @@ static bool run() Py_SetPath( python3LibPath ); + LOGGER_MESSAGE( "Python initialize" ); + Py_InitializeEx( 0 ); if( CheckPythonException() == false ) { + LOGGER_ERROR( "Invalid python initialize" ); + return false; } + LOGGER_MESSAGE( "Python successful" ); + PyObject * py_tools_module = PyImport_AddModule( "ToolsBuilderPlugin" ); AddCFunctionToModule( py_tools_module, "writeBin", &py_writeBin ); AddCFunctionToModule( py_tools_module, "writeAek", &py_writeAek ); AddCFunctionToModule( py_tools_module, "convert", &py_convert ); - + AddCFunctionToModule( py_tools_module, "isAlphaInImageFile", &py_isAlphaInImageFile ); AddCFunctionToModule( py_tools_module, "isUselessAlphaInImageFile", &py_isUselessAlphaInImageFile ); AddCFunctionToModule( py_tools_module, "isPow2SquadImageFile", &py_isPow2SquadImageFile ); @@ -1308,13 +1337,10 @@ static bool run() AddCFunctionToModule( py_tools_module, "getImageData", &py_getImageData ); AddCFunctionToModule( py_tools_module, "pathSHA1", &py_pathSHA1 ); - + AddCFunctionToModule( py_tools_module, "log", &py_log ); - if( CheckPythonException() == false ) - { - return false; - } + LOGGER_MESSAGE( "ToolsBuilderPlugin python module successful" ); WCHAR python3LibPathCount[MENGINE_MAX_PATH] = {L'\0'}; Mengine::StdString::wcscpy( python3LibPathCount, python3LibPath ); @@ -1323,53 +1349,74 @@ static bool run() Mengine::StdString::wcscpy( python3LibPathItem, python3LibPath ); wchar_t * token; - wchar_t * context; + wchar_t * context; - token = ::wcstok( python3LibPathCount, L";", &context); + token = ::wcstok( python3LibPathCount, L";", &context ); - Py_ssize_t pathCount = 1; + Py_ssize_t pathCount = 0; while( token != NULL ) { ++pathCount; - token = ::wcstok( NULL, L";", &context ); + token = ::wcstok( nullptr, L";", &context ); } - PyObject * py_syspath = PyList_New( pathCount + 1 ); + PyObject * py_syspath = PyList_New( pathCount * 2 + 1 ); - PyList_SetItem( py_syspath, 0, PyUnicode_FromWideChar( currentPath, -1 ) ); + Py_ssize_t pathIndex = 0; - token = ::wcstok( python3LibPathItem, L";", &context ); + PyList_SetItem( py_syspath, pathIndex, PyUnicode_FromWideChar( currentPath, -1 ) ); - Py_ssize_t pathIndex = 0; - while( token != NULL ) + ++pathIndex; + + token = ::wcstok( python3LibPathItem, L";", &context ); + + while( token != nullptr ) { - PyList_SetItem( py_syspath, pathIndex + 1, PyUnicode_FromWideChar( token, -1 ) ); + WCHAR token_site[MENGINE_MAX_PATH] = {L'\0'}; + ::PathCombineW( token_site, token, L"site-packages\\" ); + LOGGER_MESSAGE( "ToolsBuilderPlugin python add sys path: %ls" + , token + ); + + LOGGER_MESSAGE( "ToolsBuilderPlugin python add sys path: %ls" + , token_site + ); + + PyList_SetItem( py_syspath, pathIndex + 0, PyUnicode_FromWideChar( token, -1 ) ); + PyList_SetItem( py_syspath, pathIndex + 1, PyUnicode_FromWideChar( token_site, -1 ) ); + + ++pathIndex; ++pathIndex; token = ::wcstok( NULL, L";", &context ); } - PyList_SetItem( py_syspath, pathIndex + 1, PyUnicode_FromWideChar( L"C:\\Users\\irov1\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\", -1 ) ); - PySys_SetObject( "path", py_syspath ); + LOGGER_MESSAGE( "ToolsBuilderPlugin python setup sys path successful" ); + if( CheckPythonException() == false ) { + LOGGER_ERROR( "invalid set python path" ); + return false; } - //kernel->incref( py_tools_module ); - //kernel->module_addobject( module_builtins, "ToolsBuilderPlugin", py_tools_module ); - LPWSTR lpwCmdLine = ::GetCommandLineW(); + LOGGER_MESSAGE( "ToolsBuilderPlugin command line: %ls" + , lpwCmdLine + ); + int nArgs = 0; LPWSTR * szArglist = ::CommandLineToArgvW( lpwCmdLine, &nArgs ); if( nArgs < 3 ) { + LOGGER_ERROR( "invalid command line" ); + return false; } @@ -1383,7 +1430,7 @@ static bool run() Mengine::Char utf8_FunctionName[256] = {'\0'}; Mengine::Helper::unicodeToUtf8( szFunctionName, utf8_FunctionName, 256 ); - LOGGER_ERROR( "Module '%s' Function '%s'" + LOGGER_MESSAGE( "ToolsBuilderPlugin run module '%s' function '%s'" , utf8_ModuleName , utf8_FunctionName ); @@ -1392,6 +1439,10 @@ static bool run() if( CheckPythonException() == false ) { + LOGGER_ERROR( "invalid import module '%s'" + , utf8_ModuleName + ); + return false; } @@ -1410,40 +1461,38 @@ static bool run() if( CheckPythonException() == false ) { + LOGGER_ERROR( "invalid call function '%s'" + , utf8_FunctionName + ); + return false; } if( PyObject_IsTrue( presult ) == 0 ) { + LOGGER_ERROR( "invalid call function '%s' result" + , utf8_FunctionName + ); + return false; } + LOGGER_MESSAGE( "build successful" ); + Mengine::finalize(); return true; } /////////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow ) -#elif __MINGW32__ int main( int argc, char * argv[] ) -#else -# error unsupport -#endif { -#ifdef _MSC_VER - ( void )hInstance; - (void)hPrevInstance; - (void)lpCmdLine; - (void)nCmdShow; -#elif __MINGW32__ - ( void )argc; - (void)argv; -#else -# error unsupport -#endif - - Mengine::createConsole(); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); + + if( ::IsDebuggerPresent() == TRUE ) + { + Mengine::createConsole(); + } try { diff --git a/src/Tools/ProjectBuilder/XmlToAekConverter.cpp b/src/Tools/ProjectBuilder/XmlToAekConverter.cpp index e634978544..4f75ce49f4 100644 --- a/src/Tools/ProjectBuilder/XmlToAekConverter.cpp +++ b/src/Tools/ProjectBuilder/XmlToAekConverter.cpp @@ -32,7 +32,7 @@ namespace Mengine { ////////////////////////////////////////////////////////////////////////// - static bool s_writeAek( const WString & _protocolPath, const WString & _xmlPath, const WString & _aekPath ) + bool writeAek( const wchar_t * _protocolPath, const wchar_t * _xmlPath, const wchar_t * _aekPath ) { String utf8_protocolPath; Helper::unicodeToUtf8( _protocolPath, &utf8_protocolPath ); @@ -48,9 +48,9 @@ namespace Mengine LOADER_SERVICE() ->setProtocolPath( fp_protocolPath ); - String framePackPath( utf8_xmlPath.c_str(), utf8_xmlPath.size() ); + String framePackPath = utf8_xmlPath; - String::size_type size = framePackPath.size(); + String::size_type size = utf8_xmlPath.size(); framePackPath[size - 3] = L'x'; framePackPath[size - 2] = L'm'; framePackPath[size - 1] = L'l'; @@ -95,13 +95,5 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - void writeAek( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * aekPath ) - { - if( s_writeAek( protocolPath, xmlPath, aekPath ) == false ) - { - LOGGER_ERROR( "writeAek: error write bin" ); - } - } - ////////////////////////////////////////////////////////////////////////// } diff --git a/src/Tools/ProjectBuilder/XmlToAekConverter.h b/src/Tools/ProjectBuilder/XmlToAekConverter.h index 2b10924d41..1f9e719f59 100644 --- a/src/Tools/ProjectBuilder/XmlToAekConverter.h +++ b/src/Tools/ProjectBuilder/XmlToAekConverter.h @@ -4,5 +4,5 @@ namespace Mengine { - void writeAek( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * aekPath ); + bool writeAek( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * aekPath ); } \ No newline at end of file diff --git a/src/Tools/ProjectBuilder/XmlToBinDecoder.cpp b/src/Tools/ProjectBuilder/XmlToBinDecoder.cpp index 47cdd24347..681227a729 100644 --- a/src/Tools/ProjectBuilder/XmlToBinDecoder.cpp +++ b/src/Tools/ProjectBuilder/XmlToBinDecoder.cpp @@ -28,7 +28,7 @@ namespace Mengine { ////////////////////////////////////////////////////////////////////////// - static bool s_writeBin( const WString & _protocolPath, const WString & _xmlPath, const WString & _binPath ) + bool writeBin( const wchar_t * _protocolPath, const wchar_t * _xmlPath, const wchar_t * _binPath ) { String utf8_protocolPath; Helper::unicodeToUtf8( _protocolPath, &utf8_protocolPath ); @@ -80,13 +80,5 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - void writeBin( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * binPath ) - { - if( s_writeBin( protocolPath, xmlPath, binPath ) == false ) - { - LOGGER_ERROR( "writeBin: error write bin" ); - } - } - ////////////////////////////////////////////////////////////////////////// } diff --git a/src/Tools/ProjectBuilder/XmlToBinDecoder.h b/src/Tools/ProjectBuilder/XmlToBinDecoder.h index 998a515c8d..8d6ea831c7 100644 --- a/src/Tools/ProjectBuilder/XmlToBinDecoder.h +++ b/src/Tools/ProjectBuilder/XmlToBinDecoder.h @@ -4,5 +4,5 @@ namespace Mengine { - void writeBin( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * binPath ); + bool writeBin( const wchar_t * protocolPath, const wchar_t * xmlPath, const wchar_t * binPath ); } \ No newline at end of file diff --git a/src/Tools/Ravinggen/CMakeLists.txt b/src/Tools/Ravinggen/CMakeLists.txt index 0992b2d240..604ded69f5 100644 --- a/src/Tools/Ravinggen/CMakeLists.txt +++ b/src/Tools/Ravinggen/CMakeLists.txt @@ -1,14 +1,12 @@ MENGINE_PROJECT(Ravinggen) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - ADD_FILTER( src Ravinggen.cpp ) LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}stdex${MENGINE_LIB_SUFFIX}) diff --git a/src/Tools/TexturePacker/CMakeLists.txt b/src/Tools/TexturePacker/CMakeLists.txt index 7228053aec..de448fe505 100644 --- a/src/Tools/TexturePacker/CMakeLists.txt +++ b/src/Tools/TexturePacker/CMakeLists.txt @@ -14,7 +14,7 @@ INCLUDE_DIRECTORIES(${THIRDPARTY_CONFIG_DIR}/jansson/include) INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/jansson/include) LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) -ADD_MENGINE_EXECUTABLE_WIN32() +ADD_MENGINE_EXECUTABLE_WIN32_CONSOLE() TARGET_LINK_LIBRARIES(${PROJECT_NAME} ToolUtils) diff --git a/src/Tools/TexturePacker/TexturePacker.cpp b/src/Tools/TexturePacker/TexturePacker.cpp index 2e609b362c..ace5c470ef 100644 --- a/src/Tools/TexturePacker/TexturePacker.cpp +++ b/src/Tools/TexturePacker/TexturePacker.cpp @@ -11,12 +11,10 @@ #include "jansson.h" ////////////////////////////////////////////////////////////////////////// -int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) +int main( int argc, char * argv[] ) { - MENGINE_UNUSED( hInstance ); - MENGINE_UNUSED( hPrevInstance ); - MENGINE_UNUSED( lpCmdLine ); - MENGINE_UNUSED( nShowCmd ); + MENGINE_UNUSED( argc ); + MENGINE_UNUSED( argv ); PWSTR pwCmdLine = ::GetCommandLineW();