Skip to content

Commit

Permalink
Merge pull request #21 from Dudi119/development
Browse files Browse the repository at this point in the history
Release build, Constructor fix.
  • Loading branch information
dulikvor authored Aug 1, 2018
2 parents 8eeb2ca + d3fd224 commit 498b347
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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()
12 changes: 8 additions & 4 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
4 changes: 2 additions & 2 deletions cmake/FindCore.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 3 additions & 3 deletions cmake/InstallCore.cmake
Original file line number Diff line number Diff line change
@@ -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 <SOURCE_DIR> && cmake -DCORE_3RD_PARTY_DIR:STRING=<INSTALL_DIR> -DCORE_SPDLOG_SUPPORT=OFF -DCORE_COMPILE_STEP=ON .
URL https://github.com/Dudi119/Core/archive/v1.0.1.tar.gz
CONFIGURE_COMMAND cd <SOURCE_DIR> && cmake -DCORE_3RD_PARTY_DIR:STRING=<INSTALL_DIR> -DCORE_SPDLOG_SUPPORT=OFF -DCORE_COMPILE_STEP=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .
BUILD_COMMAND cd <SOURCE_DIR> && make
INSTALL_COMMAND mkdir -p <INSTALL_DIR>/lib && cp <SOURCE_DIR>/bin/libCore.so <INSTALL_DIR>/lib
INSTALL_COMMAND mkdir -p <INSTALL_DIR>/lib && cp <SOURCE_DIR>/bin/libCore${CMAKE_DEBUG_POSTFIX}.so <INSTALL_DIR>/lib
TEST_COMMAND ""
)

Expand Down
9 changes: 6 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
2 changes: 1 addition & 1 deletion src/CPyModuleContainer.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <Python.h>
#include <unordered_map>
#include <memory>
#include <string>
#include <Python.h>

namespace sweetPy{

Expand Down
5 changes: 2 additions & 3 deletions src/CPythonConstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ namespace sweetPy {
new((char*)self + sizeof(PyObject))ClassType(std::forward<Args>(Object<typename base<Args>::Type>::GetTyped(
pythonArgsBuffer + ObjectOffset<FromPython, ObjectWrapper<typename base<Args>::Type, I>,ObjectWrapper<typename base<Args>::Type, I>...>::value,
nativeArgsBuffer + ObjectOffset<ToNative, ObjectWrapper<typename base<Args>::Type, I>,ObjectWrapper<typename base<Args>::Type, I>...>::value))...);

ObjectWrapper<int, 0>::MultiInvoker(ObjectWrapper<typename base<Args>::Type, I>::Destructor(nativeArgsBuffer +
ObjectOffset<ToNative, ObjectWrapper<typename base<Args>::Type, I>,
ObjectOffset<ToNative, ObjectWrapper<typename base<Args>::Type, I>,
ObjectWrapper<typename base<Args>::Type, I>...>::value)...);
return 0;
}

static int Wrapper(PyObject *self, PyObject *args, PyObject *kwargs) {
WrapperImpl(self, args, std::make_index_sequence<sizeof...(Args)>{});
return WrapperImpl(self, args, std::make_index_sequence<sizeof...(Args)>{});
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/CPythonType.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <Python.h>
#include <iostream>
#include <string>
#include <memory>
#include <iterator>
#include <algorithm>
#include <Python.h>
#include <structmember.h>

namespace sweetPy {
Expand Down
2 changes: 1 addition & 1 deletion src/Exception.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <memory>
#include <Python.h>
#include <memory>
#include "core/Exception.h"
#include "Deleter.h"

Expand Down

0 comments on commit 498b347

Please sign in to comment.