Skip to content

Commit

Permalink
Fixed PCH, separate build config dirs
Browse files Browse the repository at this point in the history
- cmake
  * separate directories for build configuration (Debug, Release)
  * fixed PCH macro to work with make again
  • Loading branch information
ducakar committed Jun 1, 2017
1 parent e830301 commit 199bb0b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 32 deletions.
14 changes: 7 additions & 7 deletions build.sh
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion cmake/PCH.cmake
Expand Up @@ -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)
5 changes: 2 additions & 3 deletions etc/PKGBUILD
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions etc/openzone.spec
Expand Up @@ -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
Expand Down Expand Up @@ -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" \
Expand All @@ -85,7 +83,7 @@ cmake \
-D OZ_TOOLS=1 \
..

ninja
make %{?_smp_mflags}

%install
rm -rf "$RPM_BUILD_ROOT"
Expand Down
18 changes: 9 additions & 9 deletions src/ozCore/List.hh
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ozCore/String.cc
Expand Up @@ -59,7 +59,7 @@ char* String::resize(int newSize, bool keepContents)
}

data_ = newBuffer;
size_ = newSize;
size_ = newSize;
}

return data_;
Expand Down
4 changes: 2 additions & 2 deletions src/ozCore/String.hh
Expand Up @@ -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
Expand Down Expand Up @@ -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.
};

Expand Down
6 changes: 0 additions & 6 deletions src/ozEngine/Application.cc
Expand Up @@ -87,7 +87,6 @@ void Application::run(Stage* initialStage)
nextStage = initialStage;

#ifdef __native_client__

Pepper::init();

const PPB_View* view = PSInterfaceView();
Expand All @@ -102,7 +101,6 @@ void Application::run(Stage* initialStage)

NACL_SetScreenResolution(rect.size.width, rect.size.height, 0);
SDL_SetMainReady();

#endif

File::init();
Expand Down Expand Up @@ -147,7 +145,6 @@ void Application::run(Stage* initialStage)
// input.prepare();

#ifdef __native_client__

PSEventSetFilter(PSE_INSTANCE_HANDLEINPUT | PSE_INSTANCE_DIDCHANGEVIEW |
PSE_MOUSELOCK_MOUSELOCKLOST);

Expand Down Expand Up @@ -194,7 +191,6 @@ void Application::run(Stage* initialStage)
}

PSEventSetFilter(PSE_ALL);

#endif

SDL_Event event;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 199bb0b

Please sign in to comment.