From d3fd224419256a83cb08786270cefbc4e4e27f93 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 1 Aug 2018 00:36:42 -0700 Subject: [PATCH] Release build, Constructor fix. 1) Constructor bug fix. 2) Build system now supports both Debug/Release builds. --- .travis.yml | 4 ++-- CMakeLists.txt | 10 ++++++---- Tests/CMakeLists.txt | 12 ++++++++---- cmake/FindCore.cmake | 4 ++-- cmake/InstallCore.cmake | 6 +++--- example/CMakeLists.txt | 9 ++++++--- src/CPyModuleContainer.h | 2 +- src/CPythonConstructor.h | 5 ++--- src/CPythonType.h | 2 +- src/Exception.h | 2 +- 10 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfef512..a31b8ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,11 +22,11 @@ before_install: - g++ --version install: - sudo apt-get install -y gdb # install gdb -- cmake -DsweetPy_3RD_PARTY_INSTALL_STEP=ON -DsweetPy_TEST_SUPPORT=ON . && make +- cmake -DsweetPy_3RD_PARTY_INSTALL_STEP=ON -DsweetPy_TEST_SUPPORT=ON -DCMAKE_BUILD_TYPE=Release . && make before_script: - ulimit -c unlimited -S # enable core dumps script: -- cmake -DsweetPy_COMPILE_STEP=ON -DsweetPy_TEST_SUPPORT=ON . && make +- cmake -DsweetPy_COMPILE_STEP=ON -DsweetPy_TEST_SUPPORT=ON -DCMAKE_BUILD_TYPE=Release . && make - ./Tests/bin/sweetPyTests after_failure: - COREFILE=$(find . -maxdepth 1 -name "core*" | head -n 1) # find core file diff --git a/CMakeLists.txt b/CMakeLists.txt index 50e8b75..d19eb75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,15 @@ endif() if (NOT CMAKE_BUILD_TYPE) message(STATUS "Default build type 'Debug'") - set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "" FORCE ) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE ) else() - string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") endif() +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_DEBUG_POSTFIX d) +endif() + set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) if(NOT sweetPy_3RD_PARTY_DIR) set(sweetPy_3RD_PARTY_DIR ${PROJECT_DIR}/Third_Party/) @@ -62,7 +65,6 @@ if(sweetPy_COMPILE_STEP) add_subdirectory(${PROJECT_DIR}/Tests) endif() - add_definitions(-DA_DLL) add_library(sweetPy SHARED src/CPythonModule.h src/CPythonModule.cpp src/CPythonModule.h src/Common.h src/Exception.cpp src/Exception.h src/CPythonClass.h src/Lock.h src/Deleter.h src/CPythonFunction.h src/CPythonMember.h src/CPyModuleContainer.cpp src/CPyModuleContainer.h src/CPythonMetaClass.cpp src/CPythonMetaClass.h src/CPythonConstructor.h src/CPythonObject.h Tests/PythonEmbedder.h src/CPythonEnum.h src/CPythonEnumValue.h src/CPythonEnum.cpp src/CPythonType.h src/ICPythonFunction.h src/InitModule.h src/CPythonRef.cpp src/CPythonType.cpp src/CPythonClassType.h src/MemberAccessor.h src/IMemberAccessor.h src/CPythonGlobalFunction.h src/CPythonGlobalVariable.h src/CPythonVariable.h src/ICPythonVariable.h) - target_link_libraries(sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore.so) + target_link_libraries(sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore${CMAKE_DEBUG_POSTFIX}.so) endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 803c90e..2e7c27d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -8,12 +8,16 @@ set (CMAKE_CXX_EXTENSIONS OFF) if (NOT CMAKE_BUILD_TYPE) message(STATUS "Default build type 'Debug'") - set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "" FORCE ) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE ) else() - string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") endif() +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_DEBUG_POSTFIX) + set(CORE_DEBUG_POSTFIX d) +endif() + set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -28,9 +32,9 @@ include_directories(. .. ${PROJECT_DIR} ${sweetPy_3RD_PARTY_DIR}/include) link_directories(${sweetPy_3RD_PARTY_DIR}/lib ${PROJECT_DIR}/../bin) add_library(CPythonClassTestModule SHARED CPythonClassTestModule.cpp) -target_link_libraries(CPythonClassTestModule sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore.so pthread ) +target_link_libraries(CPythonClassTestModule sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore${CORE_DEBUG_POSTFIX}.so pthread ) set_target_properties(CPythonClassTestModule PROPERTIES PREFIX "") add_executable(sweetPyTests Tests.cpp CPythonClassTestModule.h) -set(TO_LINK_LIBS gtest ${PYTHON_LIBRARIES} util dl CPythonClassTestModule ${sweetPy_3RD_PARTY_DIR}/lib/libCore.so pthread) +set(TO_LINK_LIBS gtest ${PYTHON_LIBRARIES} util dl CPythonClassTestModule ${sweetPy_3RD_PARTY_DIR}/lib/libCore${CORE_DEBUG_POSTFIX}.so pthread) target_link_libraries(sweetPyTests ${TO_LINK_LIBS}) diff --git a/cmake/FindCore.cmake b/cmake/FindCore.cmake index 97b1870..cf425eb 100644 --- a/cmake/FindCore.cmake +++ b/cmake/FindCore.cmake @@ -1,6 +1,6 @@ message(STATUS "3rd party loc - ${sweetPy_3RD_PARTY_DIR}") -find_path(CORE_INCLUDE_DIR NAMES core/Exception.h PATHS ${sweetPy_3RD_PARTY_DIR}/include NO_DEFAULT_PATH) -find_program(CORE_LIBRARY_DIR NAMES libCore.so PATHS ${sweetPy_3RD_PARTY_DIR}/lib NO_DEFAULT_PATH) +find_path(CORE_INCLUDE_DIR NAMES core/Exception.h PATHS ${sweetPy_3RD_PARTY_DIR}/include) +find_program(CORE_LIBRARY_DIR NAMES libCore${CMAKE_DEBUG_POSTFIX}.so PATHS ${sweetPy_3RD_PARTY_DIR}/lib) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Core REQUIRED_VARS CORE_INCLUDE_DIR CORE_LIBRARY_DIR) diff --git a/cmake/InstallCore.cmake b/cmake/InstallCore.cmake index f8e81f6..ddb451e 100644 --- a/cmake/InstallCore.cmake +++ b/cmake/InstallCore.cmake @@ -1,9 +1,9 @@ if (NOT Core_FOUND) ExternalProject_Add(Core - URL https://github.com/Dudi119/Core/archive/v1.0.0.tar.gz - CONFIGURE_COMMAND cd && cmake -DCORE_3RD_PARTY_DIR:STRING= -DCORE_SPDLOG_SUPPORT=OFF -DCORE_COMPILE_STEP=ON . + URL https://github.com/Dudi119/Core/archive/v1.0.1.tar.gz + CONFIGURE_COMMAND cd && cmake -DCORE_3RD_PARTY_DIR:STRING= -DCORE_SPDLOG_SUPPORT=OFF -DCORE_COMPILE_STEP=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} . BUILD_COMMAND cd && make - INSTALL_COMMAND mkdir -p /lib && cp /bin/libCore.so /lib + INSTALL_COMMAND mkdir -p /lib && cp /bin/libCore${CMAKE_DEBUG_POSTFIX}.so /lib TEST_COMMAND "" ) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 3e688b3..26a2363 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -8,12 +8,15 @@ set (CMAKE_CXX_EXTENSIONS OFF) if (NOT CMAKE_BUILD_TYPE) message(STATUS "Default build type 'Debug'") - set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "" FORCE ) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE ) else() - string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") endif() +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_DEBUG_POSTFIX d) +endif() + set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -26,5 +29,5 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_DIR}/bin) include_directories(. .. ${PROJECT_DIR} ${PYTHON_INCLUDE_DIRS}) add_executable(example example.cpp) -set(TO_LINK_LIBS ${PYTHON_LIBRARIES} sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore.so util dl pthread) +set(TO_LINK_LIBS ${PYTHON_LIBRARIES} sweetPy ${sweetPy_3RD_PARTY_DIR}/lib/libCore${CMAKE_DEBUG_POSTFIX}.so util dl pthread) target_link_libraries(example ${TO_LINK_LIBS}) diff --git a/src/CPyModuleContainer.h b/src/CPyModuleContainer.h index ca12e99..1154827 100644 --- a/src/CPyModuleContainer.h +++ b/src/CPyModuleContainer.h @@ -1,9 +1,9 @@ #pragma once +#include #include #include #include -#include namespace sweetPy{ diff --git a/src/CPythonConstructor.h b/src/CPythonConstructor.h index ee04f40..8657f04 100644 --- a/src/CPythonConstructor.h +++ b/src/CPythonConstructor.h @@ -34,15 +34,14 @@ namespace sweetPy { new((char*)self + sizeof(PyObject))ClassType(std::forward(Object::Type>::GetTyped( pythonArgsBuffer + ObjectOffset::Type, I>,ObjectWrapper::Type, I>...>::value, nativeArgsBuffer + ObjectOffset::Type, I>,ObjectWrapper::Type, I>...>::value))...); - ObjectWrapper::MultiInvoker(ObjectWrapper::Type, I>::Destructor(nativeArgsBuffer + - ObjectOffset::Type, I>, + ObjectOffset::Type, I>, ObjectWrapper::Type, I>...>::value)...); return 0; } static int Wrapper(PyObject *self, PyObject *args, PyObject *kwargs) { - WrapperImpl(self, args, std::make_index_sequence{}); + return WrapperImpl(self, args, std::make_index_sequence{}); } private: diff --git a/src/CPythonType.h b/src/CPythonType.h index cab2498..effd749 100644 --- a/src/CPythonType.h +++ b/src/CPythonType.h @@ -1,11 +1,11 @@ #pragma once +#include #include #include #include #include #include -#include #include namespace sweetPy { diff --git a/src/Exception.h b/src/Exception.h index bf5b813..082fce6 100644 --- a/src/Exception.h +++ b/src/Exception.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include "core/Exception.h" #include "Deleter.h"