aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntony Woods <acron1@gmail.com>2013-10-16 09:09:22 +0100
committerAntony Woods <acron1@gmail.com>2013-10-16 09:09:22 +0100
commit7a42d331bd9cf0e754105d41b42abfa8a625bf86 (patch)
tree6f402301e9ea530975bcf12b9e2b389ff4051c3e
parent73a0cf44e8d4a852b58b3126ddd3fa3b8a465af5 (diff)
Fixed invalid header in python files. Now using chrono instead of boost timer. Removed unnecessary ptr checks, as now shared ptr is mandatory. Updated Readme to reflect new changes. Updated travis file, just in case.
-rw-r--r--.travis.yml1
-rw-r--r--CMakeLists.txt22
-rw-r--r--CheckCXX11SharedPtr.cmake54
-rw-r--r--CheckNeedGetPointer.cmake18
-rw-r--r--README.md10
-rw-r--r--entityx/config.h.in6
-rw-r--r--entityx/help/Timer.cc4
-rw-r--r--entityx/help/Timer.h5
-rw-r--r--entityx/python/PythonSystem.cc2
-rwxr-xr-xscripts/travis.sh2
10 files changed, 14 insertions, 110 deletions
diff --git a/.travis.yml b/.travis.yml
index 5b5024f..611553a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,6 @@ before_install:
- sudo apt-add-repository -y ppa:jkeiren/ppa
- if test $CC = gcc; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
- sudo apt-get update -qq
- - sudo apt-get install -y boost1.48 python-dev
- if test $CC = gcc; then sudo apt-get install gcc-4.7 g++-4.7; fi
- if test $CC = gcc; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 20; fi
- if test $CC = gcc; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 20; fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6cae773..48db06e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,10 +13,8 @@ set(ENTITYX_RUN_BENCHMARKS false CACHE BOOL "Run benchmarks (in conjunction with
set(ENTITYX_MAX_COMPONENTS 64 CACHE STRING "Set the maximum number of components.")
set(ENTITYX_USE_CPP11_STDLIB false CACHE BOOL "For Clang, specify whether to use libc++ (-stdlib=libc++).")
# Check for which shared_ptr implementation to use.
-set(ENTITYX_USE_STD_SHARED_PTR true CACHE BOOL "Use std::shared_ptr<T> rather than boost::shared_ptr<T>?")
set(ENTITYX_BUILD_SHARED false CACHE BOOL "Build shared libraries?")
set(ENTITYX_BUILD_PYTHON false CACHE BOOL "Build entityx::python?")
-set(ENTITYX_BOOST_SP_DISABLE_THREADS true CACHE BOOL "Disable multi-threading support in boost::shared_ptr")
include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
include(CheckCXXSourceCompiles)
@@ -28,12 +26,6 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
-
-if (ENTITYX_BOOST_SP_DISABLE_THREADS)
- message("-- Disabled multi-threading support in Boost (see http://www.boost.org/doc/libs/1_54_0/libs/smart_ptr/shared_ptr.htm)")
- add_definitions(-DBOOST_SP_DISABLE_THREADS=1)
-endif ()
-
# C++11 feature checks
include(CheckCXX11Features.cmake)
@@ -55,9 +47,6 @@ macro(create_test TARGET_NAME SOURCE)
entityx
gtest
gtest_main
- ${Boost_SYSTEM_LIBRARY}
- ${Boost_TIMER_LIBRARY}
- ${Boost_SIGNALS_LIBRARY}
${ARGN}
)
add_test(${TARGET_NAME} ${TARGET_NAME})
@@ -81,9 +70,6 @@ require(HAS_CXX11_LONG_LONG "C++11 lambdas")
message("-- Checking misc features")
require(HAVE_STDINT_H "stdint.h")
-set(Boost_USE_STATIC_LIBS OFF)
-set(Boost_USE_MULTITHREADED ON)
-set(Boost_USE_STATIC_RUNTIME OFF)
if (ENTITYX_BUILD_PYTHON)
message("-- Building with Python support (-DENTITYX_BUILD_PYTHON=0 to disable)")
find_package(Boost 1.48.0 COMPONENTS python)
@@ -91,7 +77,6 @@ else (ENTITYX_BUILD_PYTHON)
message("-- Python support disabled")
endif (ENTITYX_BUILD_PYTHON)
-include_directories(${Boost_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
@@ -100,8 +85,6 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
# Things to install
set(install_libs entityx)
-include(CheckCXX11SharedPtr.cmake)
-
set(sources entityx/tags/TagsComponent.cc entityx/deps/Dependencies.cc entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc)
add_library(entityx STATIC ${sources})
@@ -110,14 +93,11 @@ if (ENTITYX_BUILD_SHARED)
add_library(entityx_shared SHARED ${sources})
target_link_libraries(
entityx_shared
- ${Boost_SIGNALS_LIBRARY}
)
set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx)
list(APPEND install_libs entityx_shared)
endif (ENTITYX_BUILD_SHARED)
-include_directories(${Boost_INCLUDE_DIR})
-
if (ENTITYX_BUILD_PYTHON AND Boost_PYTHON_LIBRARY)
message("-- Found boost::python, building entityx/python")
find_package(PythonLibs REQUIRED)
@@ -149,7 +129,7 @@ if (ENTITYX_BUILD_PYTHON AND Boost_PYTHON_LIBRARY)
endif (ENTITYX_BUILD_PYTHON AND Boost_PYTHON_LIBRARY)
if (ENTITYX_BUILD_TESTING)
- find_package(Boost 1.48.0 REQUIRED COMPONENTS timer system)
+ #find_package(Boost 1.48.0 REQUIRED COMPONENTS timer system)
add_subdirectory(gtest-1.6.0)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
enable_testing()
diff --git a/CheckCXX11SharedPtr.cmake b/CheckCXX11SharedPtr.cmake
deleted file mode 100644
index 0dc3281..0000000
--- a/CheckCXX11SharedPtr.cmake
+++ /dev/null
@@ -1,54 +0,0 @@
-cmake_minimum_required(VERSION 2.8.3)
-
-if (ENTITYX_USE_CPP11_STDLIB)
- add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
- set(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
- check_cxx_source_compiles(
- "
- #include <memory>
-
- int main() {
- std::shared_ptr<int>();
- }
- "
- ENTITYX_HAVE_CXX11_STDLIB
- )
-
- if (NOT ENTITYX_HAVE_CXX11_STDLIB)
- message("-- Not using -stdlib=libc++ (test failed to build)")
- set(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")
- else ()
- message("-- Using -stdlib=libc++")
- endif ()
-else ()
- message("-- Using default stdlib (try -DENTITYX_USE_CPP11_STDLIB=1 to use -stdlib=libc++)")
-endif ()
-
-check_cxx_source_compiles(
-"
-#include <memory>
-
-int main() { std::shared_ptr<int>(); }
-"
-ENTITYX_HAVE_STD_SHARED_PTR
-)
-
-check_cxx_source_compiles(
-"
-#include <boost/shared_ptr.hpp>
-
-int main() { boost::shared_ptr<int>(); }
-"
-ENTITYX_HAVE_BOOST_SHARED_PTR
-)
-
-if (ENTITYX_HAVE_STD_SHARED_PTR AND ENTITYX_USE_STD_SHARED_PTR)
- message("-- Using std::shared_ptr<T>")
-else()
- if (ENTITYX_USE_STD_SHARED_PTR)
- message("-- Using boost::shared_ptr<T> (std::shared_ptr<T> could not be used)")
- else()
- message("-- Using boost::shared_ptr<T> (try -DENTITYX_USE_STD_SHARED_PTR=1 to use std::shared_ptr<T>)")
- endif()
-endif()
diff --git a/CheckNeedGetPointer.cmake b/CheckNeedGetPointer.cmake
deleted file mode 100644
index 2e53ac3..0000000
--- a/CheckNeedGetPointer.cmake
+++ /dev/null
@@ -1,18 +0,0 @@
-cmake_minimum_required(VERSION 2.8.3)
-
-check_cxx_source_compiles(
-"
-#include <boost/get_pointer.hpp>
-
-namespace boost {
-template <class T> inline T * get_pointer(const std::shared_ptr<T> &p) {
- return p.get();
-}
-}
-
-int main() {
- return 0;
-}
-"
-ENTITYX_NEED_GET_POINTER_SHARED_PTR_SPECIALIZATION
-)
diff --git a/README.md b/README.md
index 1e1f5f1..e41d80b 100644
--- a/README.md
+++ b/README.md
@@ -282,7 +282,6 @@ EntityX has the following build and runtime requirements:
- A C++ compiler that supports a basic set of C++11 features (ie. Clang >= 3.1, GCC >= 4.7, and maybe (untested) VC++ with the [Nov 2012 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=35515)).
- [CMake](http://cmake.org/)
-- [Boost](http://boost.org) `1.48.0` (headers only unless using boost::python).
### C++11 compiler and library support
@@ -299,15 +298,13 @@ I use Homebrew, and the following works for me:
For libstdc++:
```bash
-brew install boost
-cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_STD_SHARED_PTR=1 -DENTITYX_USE_CPP11_STDLIB=0 ..
+cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_CPP11_STDLIB=0 ..
```
For libc++ (with C++11 support):
```bash
-brew install boost --with-c++11
-cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_STD_SHARED_PTR=1 -DENTITYX_USE_CPP11_STDLIB=1 ..
+cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_CPP11_STDLIB=1 ..
```
### Installing on Ubuntu 12.04
@@ -340,13 +337,10 @@ Once these dependencies are installed you should be able to build and install En
- `-DENTITYX_BUILD_TESTING=1` - Build tests (run with `make test`).
- `-DENTITYX_RUN_BENCHMARKS=1` - In conjunction with `-DENTITYX_BUILD_TESTING=1`, also build benchmarks.
- `-DENTITYX_USE_CPP11_STDLIB=1` - For Clang, specify whether to use `-stdlib=libc++`.
-- `-DENTITYX_USE_STD_SHARED_PTR=1` - Use `std::shared_ptr<T>` (and friends) rather than the Boost equivalents. This does not eliminate the need for Boost, but is useful if the rest of your application uses `std::shared_ptr<T>`.
- `-DENTITYX_MAX_COMPONENTS=64` - Override the maximum number of components that can be assigned to each entity.
- `-DENTITYX_BUILD_SHARED=1` - Whether to build shared libraries (defaults to 1).
- `-DENTITYX_BUILD_TESTING=0` - Whether to build tests (defaults to 0). Run with "make && make test".
-For a production build, you'll typically only need the `-DENTITYX_USE_STD_SHARED_PTR=1` flag, if any.
-
Once you have selected your flags, build and install with:
```sh
diff --git a/entityx/config.h.in b/entityx/config.h.in
index de43e83..4f9831c 100644
--- a/entityx/config.h.in
+++ b/entityx/config.h.in
@@ -1,13 +1,13 @@
#pragma once
-#cmakedefine ENTITYX_HAVE_BOOST_SHARED_PTR 1
-#cmakedefine ENTITYX_HAVE_STD_SHARED_PTR 1
-#cmakedefine ENTITYX_USE_STD_SHARED_PTR 1
#cmakedefine ENTITYX_MAX_COMPONENTS @ENTITYX_MAX_COMPONENTS@
#cmakedefine ENTITYX_HAVE_BOOST_PYTHON 1
#cmakedefine ENTITYX_INSTALLED_PYTHON_PACKAGE_DIR "@ENTITYX_INSTALLED_PYTHON_PACKAGE_DIR@"
#cmakedefine ENTITYX_NEED_GET_POINTER_SHARED_PTR_SPECIALIZATION "@ENTITYX_NEED_GET_POINTER_SHARED_PTR_SPECIALIZATION@"
+#define ENTITYX_USE_STD_SHARED_PTR 1
+#define ENTITYX_HAVE_STD_SHARED_PTR 1
+
#include <stdint.h>
#include "entityx/config.h"
diff --git a/entityx/help/Timer.cc b/entityx/help/Timer.cc
index de25df0..2de0ef1 100644
--- a/entityx/help/Timer.cc
+++ b/entityx/help/Timer.cc
@@ -25,12 +25,12 @@ Timer::~Timer()
void Timer::restart()
{
-
+ _start = std::chrono::system_clock::now();
}
double Timer::elapsed()
{
- return 1.0;
+ return std::chrono::duration<double>(std::chrono::system_clock::now() - _start);
}
} // namespace help
diff --git a/entityx/help/Timer.h b/entityx/help/Timer.h
index eaf51ab..87a0626 100644
--- a/entityx/help/Timer.h
+++ b/entityx/help/Timer.h
@@ -7,9 +7,10 @@
*
* Author: Antony Woods <antony@teamwoods.org>
*/
-
#pragma once
+ #include <chrono>
+
namespace entityx {
namespace help {
@@ -21,6 +22,8 @@ public:
void restart();
double elapsed();
+private:
+ std::chrono::time_point<std::chrono::system_clock> _start;
};
} // namespace help
diff --git a/entityx/python/PythonSystem.cc b/entityx/python/PythonSystem.cc
index 032b283..220003b 100644
--- a/entityx/python/PythonSystem.cc
+++ b/entityx/python/PythonSystem.cc
@@ -15,7 +15,7 @@
#include <iostream>
#include <sstream>
#include "entityx/python/PythonSystem.h"
-#include "entityx/help/NonCopyableEvent.h"
+#include "entityx/help/NonCopyable.h"
namespace py = boost::python;
diff --git a/scripts/travis.sh b/scripts/travis.sh
index dadc478..b6b7975 100755
--- a/scripts/travis.sh
+++ b/scripts/travis.sh
@@ -3,7 +3,7 @@
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug -DENTITYX_BUILD_TESTING=1"
if [ "$USE_STD_SHARED_PTR" = "1" ]; then
- CMAKE_ARGS="${CMAKE_ARGS} -DENTITYX_USE_STD_SHARED_PTR=1"
+ CMAKE_ARGS="${CMAKE_ARGS}"
# This fails on OSX
if [ "$CXX" = "clang++" ]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENTITYX_USE_CPP11_STDLIB=1"