Skip to content

Commit 38d9fde

Browse files
committed
Fix PythonSystem_test issues and fix other build issues.
1 parent ec93b4d commit 38d9fde

8 files changed

Lines changed: 87 additions & 83 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ add_library(entityx_python STATIC ${sources})
145145
set_target_properties(entityx_python PROPERTIES DEBUG_POSTFIX -d FOLDER entityx)
146146
target_link_libraries(entityx_python ${ENTITYX_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
147147

148-
if (ENTITYX_BUILD_SHARED)
149-
message("-- Building shared libraries (-DENTITYX_BUILD_SHARED=0 to only build static librarires)")
148+
# Enable python shared builds (untested)
149+
if (ENTITYX_PYTHON_BUILD_SHARED)
150+
message("-- Building shared libraries (-DENTITYX_PYTHON_BUILD_SHARED=0 to only build static librarires)")
150151
add_library(entityx_python_shared SHARED ${sources})
151152
target_link_libraries(entityx_python_shared)
152153
set_target_properties(entityx_python_shared PROPERTIES
@@ -156,12 +157,13 @@ if (ENTITYX_BUILD_SHARED)
156157
SOVERSION ${ENTITYX_MAJOR_VERSION}
157158
FOLDER entityx/python/)
158159
list(APPEND install_libs entityx_python_shared)
159-
endif (ENTITYX_BUILD_SHARED)
160+
endif (ENTITYX_PYTHON_BUILD_SHARED)
160161

161-
if (ENTITYX_BUILD_TESTING)
162+
if (ENTITYX_PYTHON_BUILD_TESTING)
162163
enable_testing()
163-
create_test(pool_test entityx/python/PythonSystem_test.cc)
164-
endif (ENTITYX_BUILD_TESTING)
164+
add_definitions(-DENTITYX_PYTHON_TEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/")
165+
create_test(PythonSystem_test entityx/python/PythonSystem_test.cc)
166+
endif (ENTITYX_PYTHON_BUILD_TESTING)
165167

166168

167169
configure_file(

cmake/FindEntityX.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ find_path(ENTITYX_INCLUDE_DIR entityx/entityx.h PATH_SUFFIXES include PATHS ${EN
2222
find_library(ENTITYX_LIBRARY NAMES entityx PATH_SUFFIXES lib PATHS ${ENTITYX_PATHS})
2323
find_library(ENTITYX_LIBRARY_DEBUG NAMES entityx-d PATH_SUFFIXES lib PATHS ${ENTITYX_PATHS})
2424

25-
set(ENTITYX_LIBRARIES ${ENTITYX_LIBRARY})
25+
set(ENTITYX_LIBRARIES optimized ${ENTITYX_LIBRARY_RELEASE} debug ${ENTITYX_LIBRARY_DEBUG})
2626
set(ENTITYX_INCLUDE_DIRS ${ENTITYX_INCLUDE_DIR})
2727

2828
include(FindPackageHandleStandardArgs)

entityx/python/PythonSystem.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
// http://docs.python.org/2/extending/extending.html
12-
#include <Python.h>
12+
#include <boost/python.hpp>
1313
#include <boost/noncopyable.hpp>
1414
#include <cassert>
1515
#include <string>
@@ -66,7 +66,7 @@ struct PythonEntity {
6666

6767
operator Entity () const { return _entity; }
6868

69-
virtual void update(float dt, int frame) {}
69+
virtual void update(float dt) {}
7070

7171
Entity::Id _entity_id() const {
7272
return _entity.id();
@@ -217,8 +217,8 @@ void PythonSystem::configure(EventManager& ev) {
217217
}
218218

219219
py::object entityx = py::import("_entityx");
220-
entityx.attr("_entity_manager") = boost::ref(em_);
221-
entityx.attr("_event_manager") = boost::ref(ev);
220+
entityx.attr("_entity_manager") = boost::ref<EntityManager>(em_);
221+
entityx.attr("_event_manager") = boost::ref<EventManager>(ev);
222222
}
223223
catch ( ... ) {
224224
PyErr_Print();

entityx/python/PythonSystem.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#pragma once
1212

1313
// http://docs.python.org/2/extending/extending.html
14-
#include <Python.h>
1514
#include <boost/python.hpp>
1615
#include <boost/function.hpp>
1716
#include <list>
@@ -218,7 +217,7 @@ class PythonSystem : public entityx::System<PythonSystem>, public entityx::Recei
218217
template <typename Event, typename Proxy>
219218
void add_event_proxy(EventManager& event_manager, std::shared_ptr<Proxy> proxy) {
220219
event_manager.subscribe<Event>(*proxy);
221-
event_proxies_.push_back(static_pointer_cast<PythonEventProxy>(proxy));
220+
event_proxies_.push_back(std::static_pointer_cast<PythonEventProxy>(proxy));
222221
}
223222

224223
void receive(const EntityDestroyedEvent &event);
@@ -232,7 +231,6 @@ class PythonSystem : public entityx::System<PythonSystem>, public entityx::Recei
232231
LoggerFunction stdout_, stderr_;
233232
static bool initialized_;
234233
std::vector<std::shared_ptr<PythonEventProxy>> event_proxies_;
235-
int frame_ = 0;
236234
};
237235
} // namespace python
238236
} // namespace entityx

0 commit comments

Comments
 (0)