Skip to content

Commit

Permalink
Gettext, PCH++, ozEngine
Browse files Browse the repository at this point in the history
- all oCore/*.cc and ozDynamics/*.cc include ozCore.hh/ozDynamics.hh, which is
  precompiled via ozCore_pch.hh/ozDynamics_pch.hh
- ozCore
  * JSON::read(), write() removed
  * Gettext class: generalisation of Lingua class, handles gettext .mo files
- ozEngine
  * new comonent to contain generic 3D engine building blocks in the future
- cmake
  * PCHs work from other directories
  • Loading branch information
ducakar committed Feb 15, 2013
1 parent 8c7ea5a commit fcc7183
Show file tree
Hide file tree
Showing 60 changed files with 649 additions and 131 deletions.
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

version=0.3.81
components=( ozCore ozDynamics common matrix nirvana modules client builder unittest )
components=( ozCore ozDynamics ozEngine common matrix nirvana modules client builder unittest )

# Generate CMakeLists.txt files.
for component in ${components[@]}; do
Expand Down
10 changes: 5 additions & 5 deletions cmake/PCH.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ else( PCH_DISABLE )
add_library( ${_pchTarget}_trigger STATIC "${_inputModule}" )

# Build PCH and copy original header to the build folder since we include PCH indirectly.
add_custom_command( OUTPUT "${_inputHeader}.gch"
add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}.gch"
DEPENDS ${_pchTarget}_trigger
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${_inputHeader}"
"${_inputHeader}"
COMMAND "${CMAKE_COMMAND}" -E remove -f "${_inputHeader}.gch"
COMMAND "${CMAKE_CXX_COMPILER}" ${_flags} -o "${_inputHeader}.gch"
"${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}"
COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}.gch"
COMMAND "${CMAKE_CXX_COMPILER}" ${_flags} -o "${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}.gch"
"${CMAKE_CURRENT_SOURCE_DIR}/${_inputHeader}" )
add_custom_target( ${_pchTarget} DEPENDS "${_inputHeader}.gch" )
add_custom_target( ${_pchTarget} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}.gch" )

# Cache header location for later `use_pch()` macros.
set( ${_pchTarget}_output "${CMAKE_CURRENT_BINARY_DIR}/${_inputHeader}" )
Expand Down
4 changes: 2 additions & 2 deletions etc/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function build()
cmake \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS="${CXXFLAGS/-O2} -msse3 -mfpmath=sse" \
-D CMAKE_CXX_FLAGS="${CXXFLAGS/-O2} -msse3 -mfpmath=sse -fPIC" \
-D CMAKE_CXX_FLAGS_RELEASE="-Ofast -flto" \
-D BUILD_SHARED_LIBS=1 \
-D OZ_LUAJIT=1 \
Expand All @@ -31,7 +31,7 @@ function build()

function package_liboz()
{
pkgdesc='OpenZone Core and Dynamics Libraries'
pkgdesc='OpenZone Core, Dynamics and Engine Libraries'
license=('ZLIB')
depends=('libpulse' 'physfs')

Expand Down
14 changes: 10 additions & 4 deletions etc/openzone.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and front-end that renders it and enables the player to manipulate with the
simulated world.

%package -n liboz
Summary: OpenZone Core and Dynamics Libraries
Summary: OpenZone Core, Dynamics and Engine Libraries
Group: System Environment/Libraries
License: zlib

Expand All @@ -43,15 +43,18 @@ log writer, JSON file manipulation class, math functions and linear algebra
classes.
OpenZone Dynamics Library is a rigid body physics engine used in OpenZone
engine.
OpenZone Engine Library contains basic engine building blocks for OpenZone
game.

%package -n liboz-devel
Summary: Headers for OpenZone Core and Dynamics Libraries
Summary: Headers for OpenZone Core, Dynamics and Engine Libraries
Group: Development/Libraries
License: zlib
Requires: liboz = %{version}

%description -n liboz-devel
This package contains header files for OpenZone Core and Dynamics Libraries.
This package contains header files for OpenZone Core, Dynamics and Engine
Libraries.

%package data
Summary: OpenZone game data
Expand All @@ -71,7 +74,7 @@ cd build
cmake \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS="-msse3 -mfpmath=sse" \
-D CMAKE_CXX_FLAGS="-msse3 -mfpmath=sse -fPIC" \
-D CMAKE_CXX_FLAGS_RELEASE="-Ofast -flto" \
-D BUILD_SHARED_LIBS=1 \
..
Expand Down Expand Up @@ -102,14 +105,17 @@ install -m644 share/openzone/*.zip "$RPM_BUILD_ROOT"%{_datadir}/openzone
%defattr(-, root, root, -)
%{_libdir}/libozCore.so*
%{_libdir}/libozDynamics.so*
%{_libdir}/libozEngine.so*
%doc src/ozCore/COPYING

%files -n liboz-devel
%defattr(-, root, root, -)
%{_libdir}/pkgconfig/ozCore.pc
%{_libdir}/pkgconfig/ozDynamics.pc
%{_libdir}/pkgconfig/ozEngine.pc
%{_includedir}/ozCore
%{_includedir}/ozDynamics
%{_includedir}/ozEngine
%doc src/ozCore/COPYING

%files data
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} )

add_subdirectory( ozCore )
add_subdirectory( ozDynamics )
add_subdirectory( ozEngine )
add_subdirectory( unittest )

add_pch( pch stable.hh stable.cc )
Expand Down
5 changes: 1 addition & 4 deletions src/ozCore/Alloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* @file ozCore/Alloc.cc
*/

#include "Alloc.hh"

#include "System.hh"
#include "Log.hh"
#include "ozCore.hh"

#include <cstdlib>
#include <malloc.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ozCore/Buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @file ozCore/Buffer.cc
*/

#include "Buffer.hh"
#include "ozCore.hh"

namespace oz
{
Expand Down
9 changes: 7 additions & 2 deletions src/ozCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_library( ozCore
DChain.hh
Endian.hh
File.hh
Gettext.hh
HashMap.hh
HashSet.hh
InputStream.hh
Expand Down Expand Up @@ -52,6 +53,7 @@ add_library( ozCore
Buffer.cc
common.cc
File.cc
Gettext.cc
JSON.cc
Log.cc
Mat33.cc
Expand All @@ -71,8 +73,6 @@ add_library( ozCore
#END SOURCES
)

set_target_properties( ozCore PROPERTIES VERSION ${OZ_VERSION} SOVERSION 0 )

if( EMSCRIPTEN )
# target_link_libraries( ozCore )
elseif( ANDROID )
Expand All @@ -88,6 +88,11 @@ else()
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -lpulse-simple -lasound -lrt -lpthread )
endif()

set_target_properties( ozCore PROPERTIES VERSION ${OZ_VERSION} SOVERSION 0 )

add_pch( ozCore_pch ../ozCore_pch.hh ../ozCore_pch.cc )
use_pch( ozCore ozCore_pch )

install( TARGETS ozCore
RUNTIME DESTINATION bin${OZ_BINARY_SUBDIR}
LIBRARY DESTINATION lib${OZ_BINARY_SUBDIR}
Expand Down
18 changes: 9 additions & 9 deletions src/ozCore/File.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @file ozCore/File.cc
*/

#include "File.hh"
#include "ozCore.hh"

#if defined( __native_client__ )
# include <ppapi/c/pp_file_info.h>
Expand Down Expand Up @@ -65,13 +65,6 @@ namespace oz

#ifdef __native_client__

struct Semaphore
{
pthread_mutex_t mutex;
pthread_cond_t cond;
volatile int counter;
};

#define SEMAPHORE_POST() \
pthread_mutex_lock( &_fd->semaphore.mutex ); \
++_fd->semaphore.counter; \
Expand Down Expand Up @@ -106,6 +99,13 @@ struct Semaphore

struct File::Descriptor
{
struct Semaphore
{
pthread_mutex_t mutex;
pthread_cond_t cond;
volatile int counter;
};

// Some Descriptor members are also useful for static functions.
static Descriptor staticDesc;

Expand Down Expand Up @@ -665,7 +665,7 @@ bool File::read( OutputStream* ostream ) const
char* buffer = ostream->forward( fileSize );
bool result = read( buffer, &size );

ostream->seek( buffer + size );
ostream->set( buffer + size );
return result;
}

Expand Down
Loading

0 comments on commit fcc7183

Please sign in to comment.