Skip to content

Commit bbecf01

Browse files
committed
Fix linux travis builds
Clean up gitmodule scrub Limit travis builds to only Pull-Requests and Master branch Fix travis pop/pushing. Add lib stdc packages. Fix travis clang and g++ builds? Fix cmake error. Fix error where PythonComponent was still refrenced Fix issue with static_pointer_cast being used without refrence to std:: Fix g++ specific errors with PythonSystem_test.cc Fix clang builds.
1 parent 2141679 commit bbecf01

4 files changed

Lines changed: 49 additions & 35 deletions

File tree

.travis.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
branches:
2+
only:
3+
- master
4+
15
sudo: false
26
language: cpp
37
compiler:
@@ -10,6 +14,7 @@ addons:
1014
- llvm-toolchain-precise
1115
- llvm-toolchain-precise-3.7
1216
packages:
17+
- libstdc++-5-dev
1318
- g++-5
1419
- clang-3.8
1520

@@ -18,17 +23,10 @@ cache:
1823
directories:
1924
- $HOME/.ccache
2025
- "deps/boost-install"
26+
- "deps/entityx-install"
2127
- "deps/cmake"
2228

23-
language: cpp
24-
compiler:
25-
- clang
26-
- gcc
27-
2829
before_install:
29-
# use sed to replace the SSH URL with the public URL, then init and update submodules
30-
- sed -i 's/[email protected]:/git:\/\/github.com\//' .gitmodules
31-
- git submodule update --init --recursive
3230
- if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; g++ --version; fi
3331
- if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8" CC="clang-3.8"; clang --version; fi
3432
- echo $CC
@@ -53,8 +51,9 @@ install:
5351
fi
5452
- which cmake
5553
- cmake --version
56-
- popd && pushd .
54+
- popd
5755
# Build Boost
56+
- pushd .
5857
- cd ${DEPS_DIR}
5958
- if [ ! -d "${DEPS_DIR}/boost-install/lib" ]; then export REBUILD_BOOST="yes"; else export REBUILD_BOOST="no"; fi
6059
- |
@@ -73,19 +72,20 @@ install:
7372
- popd
7473

7574
# Build Entityx
75+
- pushd .
7676
- cd ${DEPS_DIR}
77-
- if [ ! -d "${DEPS_DIR}/entityx/lib" ]; then export REBUILD_ENTITYX="yes"; else export REBUILD_ENTITYX="no"; fi
77+
- if [ ! -d "${DEPS_DIR}/entityx-install/lib" ]; then export REBUILD_ENTITYX="yes"; else export REBUILD_ENTITYX="no"; fi
7878
- |
7979
if [ "$REBUILD_ENTITYX" == "yes" ]; then
8080
rm -rf entityx
81-
git clone -b 1.1.2 --quiet --recursive https://github.com/alecthomas/entityx.git
81+
git clone -b 1.2.0 --quiet --recursive https://github.com/alecthomas/entityx.git
8282
cd entityx
83-
cmake -DCMAKE_BUILD_TYPE=Debug -DENTITYX_BUILD_TESTING=1
84-
make VERBOSE=1
83+
cmake -DCMAKE_INSTALL_PREFIX:PATH=${DEPS_DIR}/entityx-install/ -DCMAKE_BUILD_TYPE=Debug -DENTITYX_BUILD_TESTING=1
84+
make VERBOSE=1 all install
8585
make test || cat Testing/Temporary/LastTest.log
8686
fi
8787
- if [ "$REBUILD_ENTITYX" == "no" ]; then mkdir entityx && cd entityx; fi
88-
- cd ../entityx && export ENTITYX_ROOT="$(pwd)"
88+
- cd ../entityx-install/ && export ENTITYX_ROOT="$(pwd)"
8989
- popd
9090

9191
# End script

CMakeLists.txt

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
2828

2929
# Default compiler args
3030
if (CMAKE_CXX_COMPILER_ID MATCHES "(GNU|.*Clang)")
31-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic
32-
-Werror -Wall -Wextra -Wno-unused-parameter
33-
-Wno-error=unused-variable -Wno-error=sign-compare -std=c++11")
31+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=sign-compare -std=c++11 -Wno-error=deprecated-declarations -Wno-unused-local-typedefs")
32+
if (CMAKE_CXX_COMPILER_ID MATCHES "(.*Clang)")
33+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers -Qunused-arguments")
34+
endif()
35+
if (CMAKE_CXX_COMPILER_ID MATCHES "(GNU)")
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
37+
endif()
3438
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
3539
set(CMAKE_CXX_FLAGS_MINSIZEREL "-g -Os -DNDEBUG")
3640
set(CMAKE_CXX_FLAGS_RELEASE "-g -O2 -DNDEBUG")
3741
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
42+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
3843
elseif(CMAKE_CXX_COMPILER_ID STREQUAL 'MSVC')
3944
# /Zi - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger.
4045
# /FS - Allows multiple cl.exe processes to write to the same .pdb file
@@ -47,8 +52,15 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL 'MSVC')
4752
endif()
4853

4954
include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
55+
# C++11 feature checks
5056
include(CheckCXXSourceCompiles)
5157

58+
# Set -stdlib=lib++ for the next test. MacOS has libc++ installed, but Linux
59+
# don't necessarily have that.
60+
set(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
61+
if (CMAKE_CXX_COMPILER_ID MATCHES "(GNU|.*Clang)")
62+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
63+
endif()
5264
check_cxx_source_compiles(
5365
"
5466
#include <memory>
@@ -60,13 +72,12 @@ int main() {
6072
ENTITYX_HAVE_CXX11_STDLIB
6173
)
6274

75+
# Revert addition of -stdlib=libc++ if we couldn't build main with memory.
6376
if (NOT ENTITYX_HAVE_CXX11_STDLIB)
6477
message("-- Not using -stdlib=libc++ (test failed to build)")
78+
set(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")
6579
else ()
6680
message("-- Using -stdlib=libc++")
67-
if (CMAKE_CXX_COMPILER_ID MATCHES "(GNU|.*Clang)")
68-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
69-
endif()
7081
endif ()
7182

7283
# Misc features
@@ -112,8 +123,8 @@ endif()
112123

113124
# Add entityx
114125
# TODO(SMA) : Update FindEntityX.cmake to find the version tag, we've tested this
115-
# with version 1.1.2
116-
# find_package(entityx 1.1.2 REQUIRED)
126+
# with version 1.2.0
127+
# find_package(entityx 1.2.0 REQUIRED)
117128
find_package(EntityX REQUIRED)
118129
message(status "** EntityX Include: ${ENTITYX_INCLUDE_DIRS}")
119130
message(status "** EntityX Libraries: ${ENTITYX_LIBRARIES}")
@@ -127,14 +138,20 @@ set(ENTITYX_INSTALLED_PYTHON_PACKAGE_DIR ${PYTHON_ROOT}/Lib CACHE STRING "Python
127138
# Define HAVE_ROUND for pymath.h
128139
add_definitions(/DHAVE_ROUND)
129140
# HACK(SMA): Always statically link boost & python
130-
add_definitions(-DBOOST_STATIC -DBOOST_PYTHON_STATIC_LIB )
141+
add_definitions(-DBOOST_NO_AUTO_PTR -DBOOST_STATIC -DBOOST_PYTHON_STATIC_LIB )
131142

132143
include_directories(${CMAKE_CURRENT_LIST_DIR})
133144
include_directories(${PYTHON_INCLUDE_DIRS})
134145
include_directories(${Boost_INCLUDE_DIRS})
135146
include_directories(${ENTITYX_INCLUDE_DIRS})
136147
link_directories(${Boost_LIBRARY_DIR})
137148

149+
# Generate python configs
150+
configure_file(
151+
${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/config.h.in
152+
${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/config.h
153+
)
154+
138155
# Things to install
139156
set(install_libs entityx_python)
140157
# Inclue headers here so they appear in visual studio.
@@ -165,12 +182,6 @@ if (ENTITYX_PYTHON_BUILD_TESTING)
165182
create_test(PythonSystem_test entityx/python/PythonSystem_test.cc)
166183
endif (ENTITYX_PYTHON_BUILD_TESTING)
167184

168-
169-
configure_file(
170-
${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/config.h.in
171-
${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/config.h
172-
)
173-
174185
install(
175186
DIRECTORY "entityx/python/"
176187
DESTINATION "include"

entityx/python/PythonSystem.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace python {
2828
class PythonScript {
2929
public:
3030
/**
31-
* Create a new PythonComponent from a Python Entity class.
31+
* Create a new PythonScript from a Python Entity class.
3232
*
3333
* @param module The Python module where the Entity subclass resides.
3434
* @param cls The Class within the module. Must inherit from entityx.Entity.
@@ -40,7 +40,7 @@ class PythonScript {
4040
}
4141

4242
/**
43-
* Create a new PythonComponent from an existing Python instance.
43+
* Create a new PythonScript from an existing Python instance.
4444
*/
4545
explicit PythonScript(boost::python::object object) : object(object) {}
4646

@@ -146,7 +146,7 @@ class BroadcastPythonEventProxy : public PythonEventProxy, public Receiver<Broad
146146

147147
void receive(const Event &event) {
148148
for ( auto entity : entities ) {
149-
auto py_entity = entity.template component<PythonComponent>();
149+
auto py_entity = entity.template component<PythonScript>();
150150
py_entity->object.attr(handler_name.c_str())(event);
151151
}
152152
}
@@ -208,7 +208,7 @@ class PythonSystem : public entityx::System<PythonSystem>, public entityx::Recei
208208
void add_event_proxy(EventManager& event_manager, const std::string &handler_name) {
209209
std::shared_ptr<BroadcastPythonEventProxy<Event>> proxy(new BroadcastPythonEventProxy<Event>(handler_name));
210210
event_manager.subscribe<Event>(*proxy.get());
211-
event_proxies_.push_back(static_pointer_cast<PythonEventProxy>(proxy));
211+
event_proxies_.push_back(std::static_pointer_cast<PythonEventProxy>(proxy));
212212
}
213213

214214
/**

entityx/python/PythonSystem_test.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BOOST_PYTHON_MODULE(entityx_python_test) {
8787

8888
class PythonSystemTest {
8989
protected:
90-
PythonSystemTest() : entity_manager(event_manager), python(entity_manager) {
90+
PythonSystemTest() : python(entity_manager), entity_manager(event_manager) {
9191
assert(PyImport_AppendInittab("entityx_python_test", initentityx_python_test) != -1
9292
&& "Failed to initialize entityx_python_test Python module");
9393
python.add_path(ENTITYX_PYTHON_TEST_DATA);
@@ -166,7 +166,7 @@ TEST_CASE_METHOD(PythonSystemTest, "TestComponentAssignmentCreationInCpp") {
166166
TEST_CASE_METHOD(PythonSystemTest, "TestEntityConstructorArgs") {
167167
try {
168168
Entity e = entity_manager.create();
169-
auto script = e.assign<PythonScript>("entityx.tests.constructor_test", "ConstructorTest", 4.0, 5.0);
169+
e.assign<PythonScript>("entityx.tests.constructor_test", "ConstructorTest", 4.0, 5.0);
170170
auto position = e.component<Position>();
171171
REQUIRE(static_cast<bool>(position));
172172
REQUIRE(position->x == 4.0);
@@ -189,12 +189,15 @@ TEST_CASE_METHOD(PythonSystemTest, "TestEventDelivery") {
189189
auto scriptg = g.assign<PythonScript>("entityx.tests.event_test", "EventTest");
190190
REQUIRE(!scripte->object.attr("collided"));
191191
REQUIRE(!scriptf->object.attr("collided"));
192+
REQUIRE(!scriptg->object.attr("collided"));
192193
event_manager.emit<CollisionEvent>(f, g);
193194
REQUIRE(scriptf->object.attr("collided"));
194195
REQUIRE(!scripte->object.attr("collided"));
196+
REQUIRE(scriptg->object.attr("collided"));
195197
event_manager.emit<CollisionEvent>(e, f);
196198
REQUIRE(scriptf->object.attr("collided"));
197199
REQUIRE(scripte->object.attr("collided"));
200+
REQUIRE(scriptg->object.attr("collided"));
198201
}
199202
catch ( ... ) {
200203
PyErr_Print();

0 commit comments

Comments
 (0)