- added cppunit into build system and started writing some unit tests (requires new dependency cppunit)
This commit is contained in:
parent
db921c3fb7
commit
65266ca41e
|
@ -44,6 +44,7 @@ OPTION(BUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS "Build model import/export tool
|
||||||
OPTION(BUILD_MEGAGLEST_MODEL_VIEWER "Build model viewer" ON)
|
OPTION(BUILD_MEGAGLEST_MODEL_VIEWER "Build model viewer" ON)
|
||||||
OPTION(BUILD_MEGAGLEST_MAP_EDITOR "Build map editor" ON)
|
OPTION(BUILD_MEGAGLEST_MAP_EDITOR "Build map editor" ON)
|
||||||
OPTION(BUILD_MEGAGLEST "Build MegaGlest" ON)
|
OPTION(BUILD_MEGAGLEST "Build MegaGlest" ON)
|
||||||
|
OPTION(BUILD_MEGAGLEST_TESTS "Build MegaGlest Unit Tests" OFF)
|
||||||
OPTION(WITH_VLC "Use libVLC to play videos" ON)
|
OPTION(WITH_VLC "Use libVLC to play videos" ON)
|
||||||
|
|
||||||
FIND_PROGRAM(HELP2MAN "help2man")
|
FIND_PROGRAM(HELP2MAN "help2man")
|
||||||
|
@ -329,6 +330,8 @@ IF(EXISTS "${PROJECT_SOURCE_DIR}/source/")
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
include(${PROJECT_SOURCE_DIR}/mk/macosx/CMakeLists.txt)
|
include(${PROJECT_SOURCE_DIR}/mk/macosx/CMakeLists.txt)
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/source/tests )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Check if data exist
|
# Check if data exist
|
||||||
|
|
|
@ -109,7 +109,7 @@ esac
|
||||||
#exit 1;
|
#exit 1;
|
||||||
|
|
||||||
CURRENTDIR="$(dirname $(readlink -f $0))"
|
CURRENTDIR="$(dirname $(readlink -f $0))"
|
||||||
cmake -DCMAKE_INSTALL_PREFIX='' -DWANT_DEV_OUTPATH=ON -DWANT_STATIC_LIBS=ON -DBREAKPAD_ROOT=${CURRENTDIR}/../google-breakpad/ ${EXTRA_CMAKE_OPTIONS} ..
|
cmake -DCMAKE_INSTALL_PREFIX='' -DWANT_DEV_OUTPATH=ON -DWANT_STATIC_LIBS=ON -DBUILD_MEGAGLEST_TESTS=ON -DBREAKPAD_ROOT=${CURRENTDIR}/../google-breakpad/ ${EXTRA_CMAKE_OPTIONS} ..
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo 'ERROR: CMAKE failed.' >&2; exit 1
|
echo 'ERROR: CMAKE failed.' >&2; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
#
|
||||||
|
# http://root.cern.ch/viewvc/trunk/cint/reflex/cmake/modules/FindCppUnit.cmake
|
||||||
|
#
|
||||||
|
# - Find CppUnit
|
||||||
|
#
|
||||||
|
# This module finds the CppUnit include directory and library
|
||||||
|
#
|
||||||
|
# It sets the following variables:
|
||||||
|
# CPPUNIT_FOUND - Set to false, or undefined, if CppUnit isn't found.
|
||||||
|
# CPPUNIT_INCLUDE_DIR - The CppUnit include directory.
|
||||||
|
# CPPUNIT_LIBRARY - The CppUnit library to link against.
|
||||||
|
|
||||||
|
set (_cppunit_DEBUG false)
|
||||||
|
|
||||||
|
# If CPPUNIT_ROOT was defined in the environment, use it.
|
||||||
|
|
||||||
|
if (NOT CPPUNIT_ROOT AND NOT $ENV{CPPUNIT_ROOT} STREQUAL "")
|
||||||
|
set(CPPUNIT_ROOT $ENV{CPPUNIT_ROOT})
|
||||||
|
endif(NOT CPPUNIT_ROOT AND NOT $ENV{CPPUNIT_ROOT} STREQUAL "")
|
||||||
|
|
||||||
|
# If CPPUNIT_INCLUDEDIR was defined in the environment, use it.
|
||||||
|
if( NOT $ENV{CPPUNIT_INCLUDEDIR} STREQUAL "" )
|
||||||
|
set(CPPUNIT_INCLUDEDIR $ENV{CPPUNIT_INCLUDEDIR})
|
||||||
|
endif( NOT $ENV{CPPUNIT_INCLUDEDIR} STREQUAL "" )
|
||||||
|
|
||||||
|
# If CPPUNIT_LIBRARYDIR was defined in the environment, use it.
|
||||||
|
if( NOT $ENV{CPPUNIT_LIBRARYDIR} STREQUAL "" )
|
||||||
|
set(CPPUNIT_LIBRARYDIR $ENV{CPPUNIT_LIBRARYDIR})
|
||||||
|
endif( NOT $ENV{CPPUNIT_LIBRARYDIR} STREQUAL "" )
|
||||||
|
|
||||||
|
if( CPPUNIT_ROOT )
|
||||||
|
set(_cppunit_INCLUDE_SEARCH_DIRS
|
||||||
|
${CPPUNIT_ROOT}/include )
|
||||||
|
set(_cppunit_LIBRARY_SEARCH_DIRS
|
||||||
|
${CPPUNIT_ROOT}/lib )
|
||||||
|
endif( CPPUNIT_ROOT )
|
||||||
|
|
||||||
|
if( CPPUNIT_INCLUDEDIR )
|
||||||
|
file(TO_CMAKE_PATH ${CPPUNIT_INCLUDEDIR} CPPUNIT_INCLUDEDIR)
|
||||||
|
SET(_cppunit_INCLUDE_SEARCH_DIRS
|
||||||
|
${CPPUNIT_INCLUDEDIR} )
|
||||||
|
endif( CPPUNIT_INCLUDEDIR )
|
||||||
|
|
||||||
|
if( CPPUNIT_LIBRARYDIR )
|
||||||
|
file(TO_CMAKE_PATH ${CPPUNIT_LIBRARYDIR} CPPUNIT_LIBRARYDIR)
|
||||||
|
SET(_cppunit_LIBRARY_SEARCH_DIRS
|
||||||
|
${CPPUNIT_LIBRARYDIR} )
|
||||||
|
endif( CPPUNIT_LIBRARYDIR )
|
||||||
|
|
||||||
|
# now find CPPUNIT_INCLUDE_DIR
|
||||||
|
|
||||||
|
if ( _cppunit_DEBUG)
|
||||||
|
message(STATUS "search include dirs for cppunit = ${_cppunit_INCLUDE_SEARCH_DIRS}")
|
||||||
|
endif ( _cppunit_DEBUG)
|
||||||
|
|
||||||
|
find_path(CPPUNIT_INCLUDE_DIR
|
||||||
|
NAMES cppunit/Test.h
|
||||||
|
HINTS ${_cppunit_INCLUDE_SEARCH_DIRS})
|
||||||
|
|
||||||
|
if ( _cppunit_DEBUG)
|
||||||
|
message(STATUS "include dir for cppunit = ${CPPUNIT_INCLUDE_DIR}")
|
||||||
|
endif ( _cppunit_DEBUG)
|
||||||
|
|
||||||
|
# now find CPPUNIT_LIBRARY
|
||||||
|
|
||||||
|
if ( _cppunit_DEBUG)
|
||||||
|
message(STATUS "search library dirs for cppunit = ${_cppunit_LIBRARY_SEARCH_DIRS}")
|
||||||
|
endif ( _cppunit_DEBUG)
|
||||||
|
|
||||||
|
find_library(CPPUNIT_LIBRARY
|
||||||
|
NAMES cppunit
|
||||||
|
HINTS ${_cppunit_LIBRARY_SEARCH_DIRS})
|
||||||
|
|
||||||
|
if ( _cppunit_DEBUG)
|
||||||
|
message(STATUS "library dir for cppunit = ${CPPUNIT_LIBRARY}")
|
||||||
|
endif ( _cppunit_DEBUG)
|
||||||
|
|
||||||
|
if (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
|
||||||
|
SET(CPPUNIT_FOUND TRUE)
|
||||||
|
endif (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
|
||||||
|
|
||||||
|
if (CPPUNIT_FOUND)
|
||||||
|
# show which CppUnit was found only if not quiet
|
||||||
|
if (NOT CppUnit_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found CppUnit: ${CPPUNIT_LIBRARY}")
|
||||||
|
endif (NOT CppUnit_FIND_QUIETLY)
|
||||||
|
else (CPPUNIT_FOUND)
|
||||||
|
# fatal error if CppUnit is required but not found
|
||||||
|
if (CppUnit_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find CppUnit")
|
||||||
|
endif (CppUnit_FIND_REQUIRED)
|
||||||
|
endif (CPPUNIT_FOUND)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARY CPPUNIT_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(CPPUNIT_INCLUDE_DIR CPPUNIT_LIBRARY )
|
|
@ -155,7 +155,7 @@ case $distribution in
|
||||||
case $release in
|
case $release in
|
||||||
6.0*)
|
6.0*)
|
||||||
# No libvlc-dev since version (1.1.3) in Debian 6.0/Squeeze is incompatible, no libluajit-5.1-dev because it is not available on Debian 6.0/Squeeze, cf. http://glest.org/glest_board/?topic=8460
|
# No libvlc-dev since version (1.1.3) in Debian 6.0/Squeeze is incompatible, no libluajit-5.1-dev because it is not available on Debian 6.0/Squeeze, cf. http://glest.org/glest_board/?topic=8460
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libminiupnpc-dev librtmp-dev libgtk2.0-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libminiupnpc-dev librtmp-dev libgtk2.0-dev libcppunit-dev'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
error_during_installation;
|
error_during_installation;
|
||||||
|
@ -165,7 +165,7 @@ case $distribution in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev ilibfribidi-dev libvlc-dev libminiupnpc-dev librtmp-dev libgtk2.0-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev ilibfribidi-dev libvlc-dev libminiupnpc-dev librtmp-dev libgtk2.0-dev libcppunit-dev'
|
||||||
unsupported_release
|
unsupported_release
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -175,22 +175,22 @@ case $distribution in
|
||||||
Ubuntu)
|
Ubuntu)
|
||||||
case $release in
|
case $release in
|
||||||
8.04)
|
8.04)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libcppunit-dev'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
10.04)
|
10.04)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew1.5-dev libftgl-dev libfribidi-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew1.5-dev libftgl-dev libfribidi-dev libcppunit-dev'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
11.10|12.04|12.10)
|
11.10|12.04|12.10)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev libcppunit-dev'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev libcppunit-dev'
|
||||||
unsupported_release
|
unsupported_release
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -201,12 +201,12 @@ case $distribution in
|
||||||
case $release in
|
case $release in
|
||||||
|
|
||||||
13|14)
|
13|14)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev libcppunit-dev'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev'
|
installcommand='apt-get install build-essential subversion automake autoconf autogen cmake libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libftgl-dev libfribidi-dev libvlc-dev libcppunit-dev'
|
||||||
unsupported_release
|
unsupported_release
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -216,17 +216,17 @@ case $distribution in
|
||||||
SuSE|SUSE?LINUX|Opensuse)
|
SuSE|SUSE?LINUX|Opensuse)
|
||||||
case $release in
|
case $release in
|
||||||
11.2|11.3|11.4|12.1)
|
11.2|11.3|11.4|12.1)
|
||||||
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel MesaGLw-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel'
|
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel MesaGLw-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel cppunit-devel'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
12.2)
|
12.2)
|
||||||
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel Mesa-libGL-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel'
|
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel Mesa-libGL-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel cppunit-devel'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel Mesa-libGL-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel'
|
installcommand='zypper install subversion gcc gcc-c++ automake cmake libSDL-devel libxerces-c-devel Mesa-libGL-devel freeglut-devel libvorbis-devel wxGTK-devel lua-devel libjpeg-devel libpng14-devel libcurl-devel openal-soft-devel xorg-x11-libX11-devel libxml2-devel libircclient-devel glew-devel ftgl-devel fribidi-devel cppunit-devel'
|
||||||
unsupported_release
|
unsupported_release
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -236,12 +236,12 @@ case $distribution in
|
||||||
Fedora)
|
Fedora)
|
||||||
case $release in
|
case $release in
|
||||||
13|14)
|
13|14)
|
||||||
installcommand='yum groupinstall "Development Tools"; yum install subversion automake autoconf autogen cmake SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel libxml2-dev libircclient-dev glew-devel ftgl-devel fribidi-devel'
|
installcommand='yum groupinstall "Development Tools"; yum install subversion automake autoconf autogen cmake SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel libxml2-dev libircclient-dev glew-devel ftgl-devel fribidi-devel cppunit-devel'
|
||||||
$installcommand
|
$installcommand
|
||||||
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
if [ $? != 0 ]; then error_during_installation; exit 1; fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
installcommand='yum groupinstall "Development Tools"; yum install subversion automake autoconf autogen cmake SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel libxml2-dev libircclient-dev glew-devel ftgl-devel fribidi-devel'
|
installcommand='yum groupinstall "Development Tools"; yum install subversion automake autoconf autogen cmake SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel libxml2-dev libircclient-dev glew-devel ftgl-devel fribidi-devel cppunit-devel'
|
||||||
unsupported_release
|
unsupported_release
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -28,8 +28,16 @@ namespace XERCES_CPP_NAMESPACE{
|
||||||
class DOMDocument;
|
class DOMDocument;
|
||||||
class DOMNode;
|
class DOMNode;
|
||||||
class DOMElement;
|
class DOMElement;
|
||||||
|
|
||||||
|
#if XERCES_VERSION_MAJOR < 3
|
||||||
|
class DOMBuilder;
|
||||||
|
#else
|
||||||
|
class DOMLSParser;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XERCES_CPP_NAMESPACE_USE
|
||||||
|
|
||||||
namespace Shared { namespace Xml {
|
namespace Shared { namespace Xml {
|
||||||
|
|
||||||
enum xml_engine_parser_type {
|
enum xml_engine_parser_type {
|
||||||
|
@ -58,12 +66,23 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XmlIo();
|
XmlIo();
|
||||||
|
void init();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
#if XERCES_VERSION_MAJOR < 3
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getRootDOMDocument(const string &path, DOMBuilder *parser, bool noValidation);
|
||||||
|
#else
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getRootDOMDocument(const string &path, DOMLSParser *parser, bool noValidation);
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static XmlIo &getInstance();
|
static XmlIo &getInstance();
|
||||||
~XmlIo();
|
~XmlIo();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
static bool isInitialized();
|
||||||
|
|
||||||
XmlNode *load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation=false, bool skipStackCheck=false);
|
XmlNode *load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation=false, bool skipStackCheck=false);
|
||||||
void save(const string &path, const XmlNode *node);
|
void save(const string &path, const XmlNode *node);
|
||||||
};
|
};
|
||||||
|
@ -75,12 +94,15 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XmlIoRapid();
|
XmlIoRapid();
|
||||||
|
void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static XmlIoRapid &getInstance();
|
static XmlIoRapid &getInstance();
|
||||||
~XmlIoRapid();
|
~XmlIoRapid();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
static bool isInitialized();
|
||||||
|
|
||||||
XmlNode *load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation=false,bool skipStackCheck=false);
|
XmlNode *load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation=false,bool skipStackCheck=false);
|
||||||
void save(const string &path, const XmlNode *node);
|
void save(const string &path, const XmlNode *node);
|
||||||
};
|
};
|
||||||
|
@ -98,6 +120,7 @@ private:
|
||||||
private:
|
private:
|
||||||
XmlTree(XmlTree&);
|
XmlTree(XmlTree&);
|
||||||
void operator =(XmlTree&);
|
void operator =(XmlTree&);
|
||||||
|
void clearRootNode();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XmlTree(xml_engine_parser_type engine_type = DEFAULT_XML_ENGINE);
|
XmlTree(xml_engine_parser_type engine_type = DEFAULT_XML_ENGINE);
|
||||||
|
|
|
@ -61,10 +61,18 @@ public:
|
||||||
// class XmlIo
|
// class XmlIo
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
bool XmlIo::initialized= false;
|
bool XmlIo::initialized = false;
|
||||||
bool XmlIoRapid::initialized= false;
|
bool XmlIoRapid::initialized= false;
|
||||||
|
|
||||||
XmlIo::XmlIo() {
|
XmlIo::XmlIo() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XmlIo::isInitialized() {
|
||||||
|
return XmlIo::initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XmlIo::init() {
|
||||||
try{
|
try{
|
||||||
//printf("XmlIo init\n");
|
//printf("XmlIo init\n");
|
||||||
XMLPlatformUtils::Initialize();
|
XMLPlatformUtils::Initialize();
|
||||||
|
@ -90,6 +98,9 @@ XmlIo::XmlIo() {
|
||||||
|
|
||||||
XmlIo &XmlIo::getInstance() {
|
XmlIo &XmlIo::getInstance() {
|
||||||
static XmlIo XmlIo;
|
static XmlIo XmlIo;
|
||||||
|
if(XmlIo::initialized == false) {
|
||||||
|
XmlIo.init();
|
||||||
|
}
|
||||||
return XmlIo;
|
return XmlIo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +116,18 @@ XmlIo::~XmlIo() {
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XERCES_VERSION_MAJOR < 3
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * XmlIo::getRootDOMDocument(const string &path, DOMBuilder *parser, bool noValidation) {
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document= parser->parseURI(path.c_str());
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * XmlIo::getRootDOMDocument(const string &path, DOMLSParser *parser, bool noValidation) {
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document= parser->parseURI(path.c_str());
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
XmlNode *XmlIo::load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation,bool skipStackCheck) {
|
XmlNode *XmlIo::load(const string &path, const std::map<string,string> &mapTagReplacementValues,bool noValidation,bool skipStackCheck) {
|
||||||
//printf("Load file using Xerces engine [%s]\n",path.c_str());
|
//printf("Load file using Xerces engine [%s]\n",path.c_str());
|
||||||
|
|
||||||
|
@ -152,7 +175,9 @@ XmlNode *XmlIo::load(const string &path, const std::map<string,string> &mapTagRe
|
||||||
config->setParameter(XMLUni::fgXercesUseCachedGrammarInParse, true);
|
config->setParameter(XMLUni::fgXercesUseCachedGrammarInParse, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document= parser->parseURI(path.c_str());
|
//XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document= parser->parseURI(path.c_str());
|
||||||
|
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *document = getRootDOMDocument(path, parser, noValidation);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(document == NULL) {
|
if(document == NULL) {
|
||||||
document= parser->parseURI(utf8_decode(path).c_str());
|
document= parser->parseURI(utf8_decode(path).c_str());
|
||||||
|
@ -180,6 +205,9 @@ void XmlIo::save(const string &path, const XmlNode *node){
|
||||||
//printf("Saving file using Xerces engine [%s]\n",path.c_str());
|
//printf("Saving file using Xerces engine [%s]\n",path.c_str());
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
if(node == NULL) {
|
||||||
|
throw megaglest_runtime_error("node == NULL during save!");
|
||||||
|
}
|
||||||
XMLCh str[strSize];
|
XMLCh str[strSize];
|
||||||
XMLString::transcode(node->getName().c_str(), str, strSize-1);
|
XMLString::transcode(node->getName().c_str(), str, strSize-1);
|
||||||
|
|
||||||
|
@ -227,6 +255,10 @@ void XmlIo::save(const string &path, const XmlNode *node){
|
||||||
// class XmlIoRapid
|
// class XmlIoRapid
|
||||||
// =====================================================
|
// =====================================================
|
||||||
XmlIoRapid::XmlIoRapid() {
|
XmlIoRapid::XmlIoRapid() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void XmlIoRapid::init() {
|
||||||
try{
|
try{
|
||||||
//printf("XmlIo init\n");
|
//printf("XmlIo init\n");
|
||||||
|
|
||||||
|
@ -246,8 +278,16 @@ XmlIoRapid::XmlIoRapid() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XmlIoRapid::isInitialized() {
|
||||||
|
return XmlIoRapid::initialized;
|
||||||
|
}
|
||||||
|
|
||||||
XmlIoRapid &XmlIoRapid::getInstance() {
|
XmlIoRapid &XmlIoRapid::getInstance() {
|
||||||
static XmlIoRapid io;
|
static XmlIoRapid io;
|
||||||
|
if(XmlIoRapid::initialized == false) {
|
||||||
|
io.init();
|
||||||
|
}
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,6 +395,10 @@ XmlNode *XmlIoRapid::load(const string &path, const std::map<string,string> &map
|
||||||
|
|
||||||
void XmlIoRapid::save(const string &path, const XmlNode *node){
|
void XmlIoRapid::save(const string &path, const XmlNode *node){
|
||||||
try {
|
try {
|
||||||
|
if(node == NULL) {
|
||||||
|
throw megaglest_runtime_error("node == NULL during save!");
|
||||||
|
}
|
||||||
|
|
||||||
xml_document<> doc;
|
xml_document<> doc;
|
||||||
|
|
||||||
// xml declaration
|
// xml declaration
|
||||||
|
@ -423,9 +467,20 @@ XmlTree::XmlTree(xml_engine_parser_type engine_type) {
|
||||||
rootNode= NULL;
|
rootNode= NULL;
|
||||||
this->engine_type = engine_type;
|
this->engine_type = engine_type;
|
||||||
this->skipStackCheck = false;
|
this->skipStackCheck = false;
|
||||||
|
|
||||||
|
switch(this->engine_type) {
|
||||||
|
case XML_XERCES_ENGINE:
|
||||||
|
break;
|
||||||
|
case XML_RAPIDXML_ENGINE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw megaglest_runtime_error("Invalid XML parser engine: " + intToStr(this->engine_type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlTree::init(const string &name){
|
void XmlTree::init(const string &name){
|
||||||
|
clearRootNode();
|
||||||
this->rootNode= new XmlNode(name);
|
this->rootNode= new XmlNode(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,9 +529,7 @@ void XmlTree::save(const string &path){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlTree::~XmlTree() {
|
void XmlTree::clearRootNode() {
|
||||||
//printf("XmlTree::~XmlTree p [%p]\n",this);
|
|
||||||
|
|
||||||
if(this->skipStackCheck == false) {
|
if(this->skipStackCheck == false) {
|
||||||
LoadStack &loadStack = CacheManager::getCachedItem<LoadStack>(loadStackCacheName);
|
LoadStack &loadStack = CacheManager::getCachedItem<LoadStack>(loadStackCacheName);
|
||||||
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
|
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
|
||||||
|
@ -493,6 +546,11 @@ XmlTree::~XmlTree() {
|
||||||
rootNode=NULL;
|
rootNode=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XmlTree::~XmlTree() {
|
||||||
|
//printf("XmlTree::~XmlTree p [%p]\n",this);
|
||||||
|
clearRootNode();
|
||||||
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class XmlNode
|
// class XmlNode
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
#########################################################################################
|
||||||
|
# megaglest_tests
|
||||||
|
|
||||||
|
SET(EXTERNAL_LIBS "")
|
||||||
|
SET(TARGET_NAME "megaglest_tests")
|
||||||
|
|
||||||
|
IF(BUILD_MEGAGLEST_TESTS)
|
||||||
|
MESSAGE(STATUS "Will try to build MegaGlest unit tests")
|
||||||
|
|
||||||
|
INCLUDE (CheckIncludeFiles)
|
||||||
|
|
||||||
|
FIND_PACKAGE(CppUnit REQUIRED)
|
||||||
|
INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
|
||||||
|
IF(UNIX)
|
||||||
|
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${CPPUNIT_LIBRARY})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
FIND_PACKAGE(SDL REQUIRED)
|
||||||
|
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
|
||||||
|
IF(UNIX)
|
||||||
|
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${SDL_LIBRARY})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
# megaglest test code
|
||||||
|
|
||||||
|
SET(DIRS_WITH_SRC
|
||||||
|
./
|
||||||
|
shared_lib/xml)
|
||||||
|
|
||||||
|
SET(MG_INCLUDES_ROOT "./")
|
||||||
|
SET(MG_SOURCES_ROOT "./")
|
||||||
|
SET(MG_INCLUDE_FILES "")
|
||||||
|
SET(MG_SOURCE_FILES "")
|
||||||
|
|
||||||
|
SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
|
||||||
|
SET(GLEST_LIB_INCLUDE_DIRS
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}platform/common
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}platform/posix
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}util
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}graphics
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}graphics/gl
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}graphics/iqm
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}sound
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}sound/openal
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}xml
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}xml/rapidxml
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}glew
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}lua
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}map)
|
||||||
|
|
||||||
|
IF(WANT_STREFLOP)
|
||||||
|
SET(GLEST_LIB_INCLUDE_DIRS
|
||||||
|
${GLEST_LIB_INCLUDE_DIRS}
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}streflop
|
||||||
|
${GLEST_LIB_INCLUDE_ROOT}streflop/libm_flt32_source)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/win32_deps/include)
|
||||||
|
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/posix)
|
||||||
|
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
|
||||||
|
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/sound/ds8)
|
||||||
|
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||||
|
ELSE()
|
||||||
|
INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/sdl )
|
||||||
|
SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/sdl)
|
||||||
|
SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/unix)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
FOREACH(DIR IN LISTS DIRS_WITH_SRC)
|
||||||
|
set(INCLUDE_DIR_TO_GLOB ${MG_INCLUDES_ROOT}${DIR})
|
||||||
|
INCLUDE_DIRECTORIES( ${INCLUDE_DIR_TO_GLOB} )
|
||||||
|
IF(APPLE)
|
||||||
|
#MESSAGE(STATUS "INCLUDE_DIR_TO_GLOB: ${INCLUDE_DIR_TO_GLOB}")
|
||||||
|
FILE(GLOB INC_FILES_FROM_THIS_DIR ${INCLUDE_DIR_TO_GLOB}/*.h)
|
||||||
|
#MESSAGE(STATUS "INCLUDE FILES GLOBBED: ${INC_FILES_FROM_THIS_DIR}")
|
||||||
|
SET(MG_INCLUDE_FILES ${MG_INCLUDE_FILES} ${INC_FILES_FROM_THIS_DIR})
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
set(SRC_DIR_TO_GLOB ${MG_SOURCES_ROOT}${DIR})
|
||||||
|
#MESSAGE(STATUS "SRC_DIR_TO_GLOB: ${SRC_DIR_TO_GLOB}")
|
||||||
|
FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.cpp)
|
||||||
|
#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
|
||||||
|
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
|
||||||
|
|
||||||
|
set(SRC_DIR_TO_GLOB ${MG_SOURCES_ROOT}${DIR})
|
||||||
|
#MESSAGE(STATUS "SRC_DIR_TO_GLOB: ${SRC_DIR_TO_GLOB}")
|
||||||
|
FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.c)
|
||||||
|
#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
|
||||||
|
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
|
||||||
|
|
||||||
|
IF(APPLE)
|
||||||
|
FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.mm)
|
||||||
|
#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
|
||||||
|
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
|
||||||
|
FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.m)
|
||||||
|
#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
|
||||||
|
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
|
||||||
|
ENDIF(APPLE)
|
||||||
|
ENDFOREACH(DIR)
|
||||||
|
|
||||||
|
#MESSAGE(STATUS "Source files: ${MG_INCLUDE_FILES}")
|
||||||
|
#MESSAGE(STATUS "Source files: ${MG_SOURCE_FILES}")
|
||||||
|
#MESSAGE(STATUS "Include dirs: ${INCLUDE_DIRECTORIES}")
|
||||||
|
|
||||||
|
IF(APPLE)
|
||||||
|
SET(PLATFORM_SPECIFIC_DEFINES "-DHAVE_SYS_IOCTL_H")
|
||||||
|
ELSEIF(WIN32)
|
||||||
|
SET(PLATFORM_SPECIFIC_DEFINES "-DX11_AVAILABLE")
|
||||||
|
ELSE()
|
||||||
|
SET(PLATFORM_SPECIFIC_DEFINES "-DX11_AVAILABLE -DHAVE_SYS_IOCTL_H")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS
|
||||||
|
"${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}")
|
||||||
|
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1)
|
||||||
|
|
||||||
|
OPTION(WANT_DEV_OUTPATH "use developer friendly output paths" OFF)
|
||||||
|
IF(WANT_DEV_OUTPATH)
|
||||||
|
IF(UNIX AND NOT APPLE)
|
||||||
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/mk/linux)
|
||||||
|
ELSE()
|
||||||
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/data/glest_game)
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
MESSAGE(STATUS "EXTERNAL_LIBS = [${EXTERNAL_LIBS}]")
|
||||||
|
|
||||||
|
MESSAGE(STATUS "***Note: The final output path for Megaglest Game will be [${EXECUTABLE_OUTPUT_PATH}]")
|
||||||
|
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(${TARGET_NAME} ${MG_SOURCE_FILES} ${MG_INCLUDE_FILES})
|
||||||
|
|
||||||
|
IF(NOT WIN32)
|
||||||
|
IF(WANT_STREFLOP)
|
||||||
|
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${MG_STREFLOP})
|
||||||
|
ENDIF()
|
||||||
|
TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS})
|
||||||
|
|
||||||
|
# Run the unit tests after build
|
||||||
|
IF(EXISTS ${XVFB_EXEC})
|
||||||
|
MESSAGE("***-- Found xvfb-run: ${XVFB_EXEC} will run tests with it.")
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND ${XVFB_EXEC} --auto-servernum --server-num=770 ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}
|
||||||
|
COMMENT "***-- Found megaglest test runner: ${TARGET_NAME} about to run unit tests via xvfb...")
|
||||||
|
|
||||||
|
ELSE()
|
||||||
|
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}
|
||||||
|
COMMENT "***-- Found megaglest test runner: ${TARGET_NAME} about to run unit tests...")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
ENDIF()
|
|
@ -0,0 +1,264 @@
|
||||||
|
// ==============================================================
|
||||||
|
// This file is part of MegaGlest Unit Tests (www.megaglest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2013 Mark Vejvoda
|
||||||
|
//
|
||||||
|
// You can redistribute this code and/or modify it under
|
||||||
|
// the terms of the GNU General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <fstream>
|
||||||
|
#include "xml_parser.h"
|
||||||
|
#include "platform_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace Shared::Xml;
|
||||||
|
using namespace Shared::Platform;
|
||||||
|
|
||||||
|
bool removeTestFile(string file) {
|
||||||
|
#ifdef WIN32
|
||||||
|
int result = _unlink(file.c_str());
|
||||||
|
#else
|
||||||
|
int result = unlink(file.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (result == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createValidXMLTestFile(const string& test_filename) {
|
||||||
|
std::ofstream xmlFile(test_filename.c_str());
|
||||||
|
xmlFile << "<?xml version=\"1.0\"?>" << std::endl
|
||||||
|
<< "<menu>" << std::endl
|
||||||
|
<< "<menu-background-model value=\"data/core/menu/main_model/menu_main1.g3d\"/>" << std::endl
|
||||||
|
<< "</menu>" << std::endl;
|
||||||
|
xmlFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void createMalformedXMLTestFile(const string& test_filename) {
|
||||||
|
std::ofstream xmlFile(test_filename.c_str());
|
||||||
|
xmlFile << "<?xml version=\"1.0\"?> #@$ !#@$@#$" << std::endl
|
||||||
|
<< "<menu>" << std::endl
|
||||||
|
<< "<menu-background-model value=\"data/core/menu/main_model/menu_main1.g3d\"/>"
|
||||||
|
<< std::endl;
|
||||||
|
xmlFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SafeRemoveTestFile {
|
||||||
|
private:
|
||||||
|
string filename;
|
||||||
|
public:
|
||||||
|
SafeRemoveTestFile(const string &filename) {
|
||||||
|
this->filename = filename;
|
||||||
|
}
|
||||||
|
~SafeRemoveTestFile() {
|
||||||
|
removeTestFile(this->filename);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class XmlIoTest : public CppUnit::TestFixture {
|
||||||
|
// Register the suite of tests for this fixture
|
||||||
|
CPPUNIT_TEST_SUITE( XmlIoTest );
|
||||||
|
|
||||||
|
CPPUNIT_TEST( test_getInstance );
|
||||||
|
CPPUNIT_TEST( test_cleanup );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_load_file_missing, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST( test_load_file_valid );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_load_file_malformed_content, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_save_file_null_node, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST(test_save_file_valid_node );
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
// End of Fixture registration
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void test_getInstance() {
|
||||||
|
XmlIo &newInstance = XmlIo::getInstance();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == true );
|
||||||
|
}
|
||||||
|
void test_cleanup() {
|
||||||
|
XmlIo &newInstance = XmlIo::getInstance();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == true );
|
||||||
|
|
||||||
|
newInstance.cleanup();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == false );
|
||||||
|
}
|
||||||
|
void test_load_file_missing() {
|
||||||
|
XmlNode *rootNode = XmlIo::getInstance().load("/some/path/that/does/not exist", std::map<string,string>());
|
||||||
|
}
|
||||||
|
void test_load_file_valid() {
|
||||||
|
const string test_filename = "xml_test_valid.xml";
|
||||||
|
createValidXMLTestFile(test_filename);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename);
|
||||||
|
|
||||||
|
XmlNode *rootNode = XmlIo::getInstance().load(test_filename, std::map<string,string>());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT( rootNode != NULL );
|
||||||
|
CPPUNIT_ASSERT( rootNode->getName() == "menu" );
|
||||||
|
}
|
||||||
|
void test_load_file_malformed_content() {
|
||||||
|
const string test_filename = "xml_test_malformed.xml";
|
||||||
|
createMalformedXMLTestFile(test_filename);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename);
|
||||||
|
|
||||||
|
XmlNode *rootNode = XmlIo::getInstance().load(test_filename, std::map<string,string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_save_file_null_node() {
|
||||||
|
XmlNode *rootNode = NULL;
|
||||||
|
XmlIo::getInstance().save("",rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_save_file_valid_node() {
|
||||||
|
const string test_filename_load = "xml_test_save_load_valid.xml";
|
||||||
|
const string test_filename_save = "xml_test_save_valid.xml";
|
||||||
|
createValidXMLTestFile(test_filename_load);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename_load);
|
||||||
|
|
||||||
|
XmlNode *rootNode = XmlIo::getInstance().load(test_filename_load, std::map<string,string>());
|
||||||
|
|
||||||
|
XmlIo::getInstance().save(test_filename_save,rootNode);
|
||||||
|
SafeRemoveTestFile deleteFile2(test_filename_save);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class XmlIoRapidTest : public CppUnit::TestFixture {
|
||||||
|
// Register the suite of tests for this fixture
|
||||||
|
CPPUNIT_TEST_SUITE( XmlIoRapidTest );
|
||||||
|
|
||||||
|
CPPUNIT_TEST( test_getInstance );
|
||||||
|
CPPUNIT_TEST( test_cleanup );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_load_file_missing, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST( test_load_file_valid );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_load_file_malformed_content, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_save_file_null_node, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST(test_save_file_valid_node );
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
// End of Fixture registration
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void test_getInstance() {
|
||||||
|
XmlIoRapid &newInstance = XmlIoRapid::getInstance();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == true );
|
||||||
|
}
|
||||||
|
void test_cleanup() {
|
||||||
|
XmlIoRapid &newInstance = XmlIoRapid::getInstance();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == true );
|
||||||
|
|
||||||
|
newInstance.cleanup();
|
||||||
|
CPPUNIT_ASSERT( newInstance.isInitialized() == false );
|
||||||
|
}
|
||||||
|
void test_load_file_missing() {
|
||||||
|
XmlNode *rootNode = XmlIoRapid::getInstance().load("/some/path/that/does/not exist", std::map<string,string>());
|
||||||
|
}
|
||||||
|
void test_load_file_valid() {
|
||||||
|
const string test_filename = "xml_test_valid.xml";
|
||||||
|
createValidXMLTestFile(test_filename);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename);
|
||||||
|
|
||||||
|
XmlNode *rootNode = XmlIoRapid::getInstance().load(test_filename, std::map<string,string>());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT( rootNode != NULL );
|
||||||
|
CPPUNIT_ASSERT( rootNode->getName() == "menu" );
|
||||||
|
}
|
||||||
|
void test_load_file_malformed_content() {
|
||||||
|
const string test_filename = "xml_test_malformed.xml";
|
||||||
|
createMalformedXMLTestFile(test_filename);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename);
|
||||||
|
XmlNode *rootNode = XmlIoRapid::getInstance().load(test_filename, std::map<string,string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_save_file_null_node() {
|
||||||
|
XmlNode *rootNode = NULL;
|
||||||
|
XmlIoRapid::getInstance().save("",rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_save_file_valid_node() {
|
||||||
|
const string test_filename_load = "xml_test_save_load_valid.xml";
|
||||||
|
const string test_filename_save = "xml_test_save_valid.xml";
|
||||||
|
createValidXMLTestFile(test_filename_load);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename_load);
|
||||||
|
|
||||||
|
XmlNode *rootNode = XmlIoRapid::getInstance().load(test_filename_load, std::map<string,string>());
|
||||||
|
|
||||||
|
XmlIoRapid::getInstance().save(test_filename_save,rootNode);
|
||||||
|
SafeRemoveTestFile deleteFile2(test_filename_save);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class XmlTreeTest : public CppUnit::TestFixture {
|
||||||
|
// Register the suite of tests for this fixture
|
||||||
|
CPPUNIT_TEST_SUITE( XmlTreeTest );
|
||||||
|
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_invalid_xml_engine_lowerbound, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_invalid_xml_engine_upperbound, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST( test_valid_xml_engine );
|
||||||
|
CPPUNIT_TEST( test_init );
|
||||||
|
CPPUNIT_TEST_EXCEPTION( test_load_simultaneously_same_file, megaglest_runtime_error );
|
||||||
|
CPPUNIT_TEST( test_load_simultaneously_different_file );
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
// End of Fixture registration
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void test_invalid_xml_engine_lowerbound() {
|
||||||
|
XmlTree xml(static_cast<xml_engine_parser_type>(-1));
|
||||||
|
}
|
||||||
|
void test_invalid_xml_engine_upperbound() {
|
||||||
|
XmlTree xml(static_cast<xml_engine_parser_type>(2));
|
||||||
|
}
|
||||||
|
void test_valid_xml_engine() {
|
||||||
|
XmlTree xmlInstance;
|
||||||
|
CPPUNIT_ASSERT( xmlInstance.getRootNode() == NULL );
|
||||||
|
}
|
||||||
|
void test_init() {
|
||||||
|
XmlTree xmlInstance;
|
||||||
|
xmlInstance.init("");
|
||||||
|
CPPUNIT_ASSERT( xmlInstance.getRootNode() != NULL );
|
||||||
|
CPPUNIT_ASSERT( xmlInstance.getRootNode()->getName() == "" );
|
||||||
|
|
||||||
|
xmlInstance.init("testRoot");
|
||||||
|
CPPUNIT_ASSERT( xmlInstance.getRootNode() != NULL );
|
||||||
|
CPPUNIT_ASSERT( xmlInstance.getRootNode()->getName() == "testRoot" );
|
||||||
|
}
|
||||||
|
void test_load_simultaneously_same_file() {
|
||||||
|
const string test_filename = "xml_test_valid.xml";
|
||||||
|
createValidXMLTestFile(test_filename);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename);
|
||||||
|
|
||||||
|
XmlTree xmlInstance1;
|
||||||
|
xmlInstance1.load(test_filename, std::map<string,string>());
|
||||||
|
XmlTree xmlInstance2;
|
||||||
|
xmlInstance2.load(test_filename, std::map<string,string>());
|
||||||
|
}
|
||||||
|
void test_load_simultaneously_different_file() {
|
||||||
|
const string test_filename1 = "xml_test_valid1.xml";
|
||||||
|
createValidXMLTestFile(test_filename1);
|
||||||
|
SafeRemoveTestFile deleteFile(test_filename1);
|
||||||
|
const string test_filename2 = "xml_test_valid2.xml";
|
||||||
|
createValidXMLTestFile(test_filename2);
|
||||||
|
SafeRemoveTestFile deleteFile2(test_filename2);
|
||||||
|
|
||||||
|
XmlTree xmlInstance1;
|
||||||
|
xmlInstance1.load(test_filename1, std::map<string,string>());
|
||||||
|
XmlTree xmlInstance2;
|
||||||
|
xmlInstance2.load(test_filename2, std::map<string,string>());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Suite Registrations
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoTest );
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlIoRapidTest );
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( XmlTreeTest );
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <cppunit/CompilerOutputter.h>
|
||||||
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
// Get the top level suite from the registry
|
||||||
|
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
||||||
|
|
||||||
|
// Adds the test to the list of test to run
|
||||||
|
CppUnit::TextUi::TestRunner runner;
|
||||||
|
runner.addTest( suite );
|
||||||
|
|
||||||
|
// Change the default outputter to a compiler error format outputter
|
||||||
|
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||||
|
std::cerr ) );
|
||||||
|
// Run the tests.
|
||||||
|
bool wasSucessful = runner.run();
|
||||||
|
|
||||||
|
// Return error code 1 if the one of test failed.
|
||||||
|
return wasSucessful ? 0 : 1;
|
||||||
|
}
|
Loading…
Reference in New Issue