From 199bb0bdd394b3c608ffab951166186396923b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davorin=20U=C4=8Dakar?= Date: Thu, 1 Jun 2017 20:48:16 +0200 Subject: [PATCH] Fixed PCH, separate build config dirs - cmake * separate directories for build configuration (Debug, Release) * fixed PCH macro to work with make again --- build.sh | 14 +++++++------- cmake/PCH.cmake | 3 ++- etc/PKGBUILD | 5 ++--- etc/openzone.spec | 4 +--- src/ozCore/List.hh | 18 +++++++++--------- src/ozCore/String.cc | 2 +- src/ozCore/String.hh | 4 ++-- src/ozEngine/Application.cc | 6 ------ 8 files changed, 24 insertions(+), 32 deletions(-) diff --git a/build.sh b/build.sh index c6eacde7..97d9e221 100755 --- a/build.sh +++ b/build.sh @@ -45,25 +45,25 @@ function build() continue fi - header_msg $platform + header_msg $platform-$buildType - (( $1 )) && rm -rf build/$platform - if [[ ! -d build/$platform ]]; then - mkdir -p build/$platform + (( $1 )) && rm -rf build/$platform-$buildType + if [[ ! -d build/$platform-$buildType ]]; then + mkdir -p build/$platform-$buildType if [[ $platform == Emscripten ]]; then - ( cd build/$platform && emcmake cmake -Wdev --warn-uninitialized \ + ( cd build/$platform-$buildType && emcmake cmake -Wdev --warn-uninitialized \ -G Ninja \ -D CMAKE_BUILD_TYPE=$buildType \ ../.. ) else - ( cd build/$platform && cmake -Wdev --warn-uninitialized \ + ( cd build/$platform-$buildType && cmake -Wdev --warn-uninitialized \ -G Ninja \ -D CMAKE_TOOLCHAIN_FILE=../../cmake/$platform.Toolchain.cmake \ -D CMAKE_BUILD_TYPE=$buildType \ ../.. ) fi fi - (( $1 )) || ( cd build/$platform && time ninja ) + (( $1 )) || ( cd build/$platform-$buildType && time ninja ) done } diff --git a/cmake/PCH.cmake b/cmake/PCH.cmake index 1e0bdc22..8fd7bfe5 100644 --- a/cmake/PCH.cmake +++ b/cmake/PCH.cmake @@ -64,8 +64,9 @@ macro(use_pch target pchTarget) get_target_property(pchHeader ${pchTarget} OUTPUT_NAME) set_target_properties(${target} PROPERTIES COMPILE_FLAGS "-include ${pchHeader}") + add_dependencies(${target} ${pchTarget}) # Add explicit file dependencies so that changing the main PCH triggers rebuild. Just adding - # pchTarget as a dependency for the current target is not enought when using Ninja build system. + # pchTarget as a dependency for the current target is not enough when using Ninja build system. get_target_property(sources ${target} SOURCES) set_source_files_properties(${sources} PROPERTIES OBJECT_DEPENDS "${pchHeader}.gch") endmacro(use_pch) diff --git a/etc/PKGBUILD b/etc/PKGBUILD index f7122a12..1dc759b0 100644 --- a/etc/PKGBUILD +++ b/etc/PKGBUILD @@ -7,7 +7,7 @@ pkgrel=1 url="http://ducakar.github.com/openzone/" license=('GPL3') arch=('i686' 'x86_64') -makedepends=('cmake' 'ninja' 'gcc-libs' 'physfs' 'lua' 'mesa' 'sdl2_ttf' 'libvorbis' 'openal') +makedepends=('cmake' 'gcc-libs' 'physfs' 'lua' 'mesa' 'sdl2_ttf' 'libvorbis' 'openal') source=("https://github.com/downloads/ducakar/openzone/${pkgbase}-src-${pkgver}.tar.xz" "https://github.com/downloads/ducakar/openzone/${pkgbase}-data-${pkgver}.tar.xz") md5sums=('SKIP' @@ -35,11 +35,10 @@ function build() ./src/tools/openzone -p .. -i 99_test -t 30 cmake \ - -G Ninja \ -D CMAKE_CXX_FLAGS_RELEASE="-Ofast -flto -fprofile-use" \ .. - ninja + make } function package_liboz() diff --git a/etc/openzone.spec b/etc/openzone.spec index 382def95..f050fb59 100644 --- a/etc/openzone.spec +++ b/etc/openzone.spec @@ -12,7 +12,6 @@ Source0: https://github.com/downloads/ducakar/openzone/%{name}-src-%{vers Source1: https://github.com/downloads/ducakar/openzone/%{name}-data-%{version}.tar.xz BuildRequires: cmake -BuildRequires: ninja BuildRequires: alsa-lib-devel BuildRequires: zlib-devel BuildRequires: physfs-devel @@ -74,7 +73,6 @@ Game data for OpenZone. Includes tutorial, test world and Cviček mission. mkdir -p build && cd build cmake \ - -G Ninja \ -D CMAKE_INSTALL_PREFIX=/usr \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_CXX_FLAGS="-msse3 -mfpmath=sse" \ @@ -85,7 +83,7 @@ cmake \ -D OZ_TOOLS=1 \ .. -ninja +make %{?_smp_mflags} %install rm -rf "$RPM_BUILD_ROOT" diff --git a/src/ozCore/List.hh b/src/ozCore/List.hh index 6bdb7ec9..8678c46e 100644 --- a/src/ozCore/List.hh +++ b/src/ozCore/List.hh @@ -136,9 +136,9 @@ public: List(List&& other) : data_(other.data_), size_(other.size_), capacity_(other.capacity_) { - other.data_ = nullptr; - other.size_ = 0; - other.capacity_ = 0; + other.data_ = nullptr; + other.size_ = 0; + other.capacity_ = 0; } /** @@ -163,13 +163,13 @@ public: if (&other != this) { delete[] data_; - data_ = other.data_; - size_ = other.size_; - capacity_ = other.capacity_; + data_ = other.data_; + size_ = other.size_; + capacity_ = other.capacity_; - other.data_ = nullptr; - other.size_ = 0; - other.capacity_ = 0; + other.data_ = nullptr; + other.size_ = 0; + other.capacity_ = 0; } return *this; } diff --git a/src/ozCore/String.cc b/src/ozCore/String.cc index fb9dfd66..eb2f0851 100644 --- a/src/ozCore/String.cc +++ b/src/ozCore/String.cc @@ -59,7 +59,7 @@ char* String::resize(int newSize, bool keepContents) } data_ = newBuffer; - size_ = newSize; + size_ = newSize; } return data_; diff --git a/src/ozCore/String.hh b/src/ozCore/String.hh index 34a38a08..45b3a7a0 100644 --- a/src/ozCore/String.hh +++ b/src/ozCore/String.hh @@ -36,7 +36,7 @@ namespace oz /** * String. * - * Class has static storage of `BUFFER_SIZE` bytes, if string is larger it is stored in a + * Class has static storage of `BUFFER_SIZE` bytes, if the string is larger it is stored in a * dynamically allocated storage. To deallocate storage just assign an empty string. */ class String @@ -68,7 +68,7 @@ private: int size_ = 0; ///< Length in bytes (without the final null char). union { - char* data_ = nullptr; ///< Pointer to the current buffer. + char* data_ = nullptr; ///< Pointer to the current buffer (iff not static). char baseData_[BUFFER_SIZE]; ///< Static buffer. }; diff --git a/src/ozEngine/Application.cc b/src/ozEngine/Application.cc index 4dda0a95..be569b16 100644 --- a/src/ozEngine/Application.cc +++ b/src/ozEngine/Application.cc @@ -87,7 +87,6 @@ void Application::run(Stage* initialStage) nextStage = initialStage; #ifdef __native_client__ - Pepper::init(); const PPB_View* view = PSInterfaceView(); @@ -102,7 +101,6 @@ void Application::run(Stage* initialStage) NACL_SetScreenResolution(rect.size.width, rect.size.height, 0); SDL_SetMainReady(); - #endif File::init(); @@ -147,7 +145,6 @@ void Application::run(Stage* initialStage) // input.prepare(); #ifdef __native_client__ - PSEventSetFilter(PSE_INSTANCE_HANDLEINPUT | PSE_INSTANCE_DIDCHANGEVIEW | PSE_MOUSELOCK_MOUSELOCKLOST); @@ -194,7 +191,6 @@ void Application::run(Stage* initialStage) } PSEventSetFilter(PSE_ALL); - #endif SDL_Event event; @@ -240,10 +236,8 @@ void Application::run(Stage* initialStage) } #ifdef __native_client__ - // input.keys[SDLK_ESCAPE] = false; // input.oldKeys[SDLK_ESCAPE] = false; - #endif // Waste time when iconified.