diff --git a/.gitignore b/.gitignore index 048ce4e4343..38eeab44b65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,15 @@ # Asset directory assets/* -# We want certain xmls though -!assets/definitions/ -!assets/definitions/*.xml + +# asset symlinks +/cegui_examples +/definitions +/fonts +/gui +/materials +/models +/sounds +/videos # Website directory diff --git a/CMakeLists.txt b/CMakeLists.txt index 07807a45a4c..a209413d86b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,11 @@ include(utils) # Search path for dynamic libraries at runtime. Only relevant for Linux. set(CMAKE_INSTALL_RPATH ".") +# Makes sure that the RPATH is always the install path. Required for linux +# redistributable +SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + # Assure a proper build type if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE @@ -82,8 +87,8 @@ set(OGRE_PLUGINS # Plugin_BSPSceneManager # Plugin_OctreeSceneManager # Plugin_OctreeZone - Plugin_ParticleFX - Plugin_CgProgramManager + #Plugin_ParticleFX + #Plugin_CgProgramManager # Plugin_PCZSceneManager RenderSystem_GL ) @@ -268,7 +273,8 @@ if(WIN32) ) else() target_link_libraries(ThriveLib - ${AVRESAMPLE_LIBRARIES} + ${AVRESAMPLE_LIBRARIES} + ${SWRESAMPLE_LIBRARIES} ) endif() @@ -666,3 +672,25 @@ add_custom_target(zip DEPENDS Thrive ) +############################################################################### +# Linux package +############################################################################### + +if(UNIX) + + file(READ "thriveversion.ver" THRIVE_VERSION) + set(LINUX_LIBRARIES "${cAudio_LIBRARIES}" "${BULLET_LIBRARIES}" "${AVRESAMPLE_LIBRARIES}" + "${SWRESAMPLE_LIBRARIES}" "${OgreFFMPEG_LIBRARIES}" "${FFMPEG_LIBRARIES}" "${Boost_LIBRARIES}" + "${OGRE_LIBRARIES}" "${OIS_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}" "${BULLET_LIBRARIES}" + "${CEGUI_LIBRARY}" "${TINYXML_LIBRARIES}" "${OpenAL_LIBRARIES}") + + configure_file("${CMAKE_SOURCE_DIR}/cpack/CreatePackage.sh.in" + "${CMAKE_CURRENT_BINARY_DIR}/CreatePackage.sh" @ONLY + ) + + add_custom_target(linuxrelease + COMMAND "./CreatePackage.sh" + DEPENDS Thrive doc + ) + +endif() diff --git a/SetupThrive.sh b/SetupThrive.sh index 323222ad58b..95bccecb408 100755 --- a/SetupThrive.sh +++ b/SetupThrive.sh @@ -7,11 +7,12 @@ OriginalFolder=$(pwd) if [ -f ./thriveversion.ver -o "$InsideFolder" = "thrive" ]; then # Running from thrive folder - StartingDirectory=$(dirname "$(pwd)") + cd .. + StartingDirectory=$(pwd) else - StartingDirectory=$(pwd) + StartingDirectory=$(pwd) fi @@ -81,20 +82,24 @@ fi PackageManager="dnf install -y " PackagesToInstall="bullet-devel boost gcc-c++ libXaw-devel freetype-devel freeimage-devel \ - zziplib-devel boost-devel ois-devel tinyxml-devel glm-devel ffmpeg-devel ffmpeg-libs openal-soft-devel" + zziplib-devel boost-devel ois-devel tinyxml-devel glm-devel ffmpeg-devel ffmpeg-libs \ + openal-soft-devel libatomic" CommonPackages="cmake make git mercurial svn" if [ "$OS" = "Fedora" ]; then - echo "Creating CEGUI project folder for $OS" + echo "Creating Thrive project folder for $OS" elif [ "$OS" = "Ubuntu" ]; then + echo "Creating Thrive project folder for $OS" + PackageManager="apt-get install -y " PackagesToInstall="bullet-dev boost-dev build-essential automake libtool libfreetype6-dev \ - libfreeimage-dev libzzip-dev libxrandr-dev libxaw7-dev freeglut3-dev libgl1-mesa-dev \ - libglu1-mesa-dev libois-dev libboost-thread-dev tinyxml-dev glm-dev ffmpeg-dev libavutil-dev libopenal-dev" + libfreeimage-dev libzzip-dev libxrandr-dev libxaw7-dev freeglut3-dev libgl1-mesa-dev \ + libglu1-mesa-dev libois-dev libboost-thread-dev tinyxml-dev glm-dev ffmpeg-dev libavutil-dev libopenal-dev \ + libatomic1" else echo "Unkown linux OS \"$OS\"" @@ -175,10 +180,12 @@ else fi hg update default +# Working commit +hg checkout a2e49193409c -mkdir build +mkdir -p build cd build -cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCEGUI_BUILD_APPLICATION_TEMPLATES=OFF -DCEGUI_BUILD_PYTHON_MODULES=OFF -DCEGUI_SAMPLES_ENABLED=OFF +cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCEGUI_BUILD_APPLICATION_TEMPLATES=OFF -DCEGUI_BUILD_PYTHON_MODULES=OFF -DCEGUI_SAMPLES_ENABLED=OFF -DCEGUI_STRING_CLASS=1 cd "$StartingDirectory" @@ -196,8 +203,8 @@ else #Official repo #git clone https://github.com/scrawl/ogre-ffmpeg-videoplayer.git ogre-ffmpeg-videoplayer - # Currently working hhyyrylainen's fork - git clone https://github.com/hhyyrylainen/ogre-ffmpeg-videoplayer.git ogre-ffmpeg-videoplayer + # Currently working Revolutionary games fork + git clone https://github.com/Revolutionary-Games/ogre-ffmpeg-videoplayer.git ogre-ffmpeg-videoplayer cd ogre-ffmpeg-videoplayer fi @@ -215,9 +222,8 @@ echo "cAudio" if [ -d cAudio ]; then cd cAudio - #Workaround for broken latest version - #git checkout master - #git pull origin master + git checkout master + git pull origin master else @@ -227,7 +233,7 @@ else fi #Workaround for broken build with latest version -git checkout 22ff1a97a9a820c72726463708590adfae77008c +#git checkout 22ff1a97a9a820c72726463708590adfae77008c mkdir -p build cd build @@ -324,28 +330,37 @@ fi echo "Making all the links" ln -sf assets/cegui_examples cegui_examples -ln -sf assets/definitions definitions +#ln -sf assets/definitions definitions ln -sf assets/fonts fonts ln -sf assets/gui gui ln -sf assets/materials materials ln -sf assets/models models ln -sf assets/sounds sounds +ln -sf assets/videos videos + +mkdir -p build echo "Copying Ogre resources file" cp ogre_cfg/resources.cfg build/resources.cfg echo "Copying complelety pointless Ogre files" -cp /usr/local/share/OGRE/plugins.cfg build/plugins.cfg - +cp ogre_cfg/plugins.cfg build/plugins.cfg +echo "Copying Ogre libs to bin" +cp $StartingDirectory/ogreBuild/build/ogre/lib/RenderSystem_GL.* build/ +cp $StartingDirectory/ogreBuild/build/ogre/lib/Plugin_ParticleFX.* build/ +#cp $StartingDirectory/ogreBuild/build/ogre/lib/Plugin_CgProgramManager.* build/ +#cp $StartingDirectory/ogreBuild/build/ogre/lib/libOgreMain.* build/ echo "Compiling Thrive" -mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON eval "make $MakeArgs" +echo "Making symlinks to libraries in bin/contrib" +ln -s contrib/lua/liblua.so liblua.so + echo "." echo "." echo "." diff --git a/contrib/luabind b/contrib/luabind index 55b1bd92172..a0edf58e14c 160000 --- a/contrib/luabind +++ b/contrib/luabind @@ -1 +1 @@ -Subproject commit 55b1bd9217205253b41ab7d4746637ee5b0d276f +Subproject commit a0edf58e14cfb8cd4f13779707921b5e9caf686c diff --git a/cpack/CreatePackage.sh.in b/cpack/CreatePackage.sh.in new file mode 100755 index 00000000000..afd20a99205 --- /dev/null +++ b/cpack/CreatePackage.sh.in @@ -0,0 +1,130 @@ +#!/bin/sh +# Creates a zipped redistributable Thrive package for linux +version=@THRIVE_VERSION@ +versionedname=Thrive-$version +stripfiles=1 + +target=$versionedname + +librariestoinstall="@LINUX_LIBRARIES@" + +mkdir -p $target +mkdir -p $target/bin + + +# Copy all required files +cp Thrive $target/bin +cp contrib/lua/liblua.so $target/bin + + +if [ $stripfiles = 1 ] ; then + strip $target/bin/Thrive + strip $target/bin/liblua.so +fi + +# Copies a single library + +CopyDependency () { + + echo "Copying dependency $1" + + cp "$1" $target/bin + + linkto=$(readlink "$1") + + if [ ! -z "$linkto" ]; then + + echo "Following symlink $1 => $linkto" + linkdir=$(dirname "$1") + + CopyDependency "$linkdir/$linkto" + + fi + + # Strip the copied file + if [ $stripfiles = 1 ] ; then + + filename=$(basename "$1") + echo "Stripping dependency $filename" + strip "$target/bin/$filename" + fi +} + +# Loop through all required libraries +echo "$librariestoinstall" | awk 'BEGIN { RS=";" } { print $0 }' | while read -r line ; do + + filename=$(basename "$line") + extension="${filename##*.}" + + if [ -f "$line" ] && [ "$extension" != "a" ]; then + + CopyDependency "$line" + echo "" + fi +done + +# Ogre plugins +cp ./RenderSystem_GL.* $target/bin +cp ./Plugin_ParticleFX.* $target/bin +#cp ./Plugin_CgProgramManager.* $target/bin + +if [ $stripfiles = 1 ] ; then + strip $target/bin/RenderSystem_GL.* + strip $target/bin/Plugin_ParticleFX.* + #strip $target/bin/Plugin_CgProgramManager.* +fi + +# Assets +# TODO: see if these could be symlinks +cp -r ../assets/fonts $target/ +#cp -r ../assets/definitions $target/ +cp -r ../assets/gui $target/ +cp -r ../assets/materials $target/ +cp -r ../assets/models $target/ +cp -r ../assets/sounds $target/ +cp -r ../assets/videos $target/ +cp -r ../scripts $target/ + +echo "Copying and creating rest of the resources" + +# Ogre files that are required until Thrive gets its own config files +cp resources.cfg $target/bin +cp plugins.cfg $target/bin + +# Launch links +echo "#!/bin/sh +cd bin +./Thrive" > $target/launch.sh +chmod +x $target/launch.sh + +# Info files +cp ../LICENSE.txt $target/ +cp ../README.md $target/ +cp ../gpl.txt $target/ + +# documentation +cp -r doc $target/ + +# Version file +cp ../thriveversion.ver $target/ +touch "$target/package.version.$versionedname" + +# Source code setup script +mkdir -p $target/source_build +cp ../SetupThrive.sh $target/source_build +echo "To get a copy of the source code and automatically build it run ./SetupThrive.sh. +Note: the script requires root, so you should read through it before running it" > $target/source_build/README.MD + +# Delete log files, if ran from the staging folder before +echo "Deleting log and settings files if they exist" +rm $target/bin/cAudioEngineLog.html +rm $target/bin/CEGUI.log +rm $target/bin/default +rm $target/bin/ogre.cfg + +echo "Zipping it up" + +# Zip it up +7za a "Thrive.$version.7z" $versionedname + +echo "Package Thrive.$version.7z done" diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 1a56fb191ce..5c4182c4923 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -209,6 +209,7 @@ struct Engine::Implementation : public Ogre::WindowEventListener { namespace fs = boost::filesystem; fs::path manifestPath = directory / "manifest.txt"; if (not fs::exists(manifestPath)) { + throw std::runtime_error("Missing manifest file: " + manifestPath.string()); return; } std::ifstream manifest(manifestPath.string()); @@ -348,8 +349,7 @@ struct Engine::Implementation : public Ogre::WindowEventListener { // Using the handling on keydown mode to detect when inputs are consumed m_aggregator->initialise(false); - CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType( - reinterpret_cast("Thrive/Tooltip") ); + CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("Thrive/Tooltip"); // For demos // This file is renamed in newer CEGUI versions @@ -361,7 +361,7 @@ struct Engine::Implementation : public Ogre::WindowEventListener { // CEGUI::ImageManager::getSingleton().loadImageset("GameMenu.imageset"); // CEGUI::ImageManager::getSingleton().loadImageset("HUDDemo.imageset"); - CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType( reinterpret_cast("Thrive/Tooltip") ); + CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("Thrive/Tooltip"); CEGUI::AnimationManager::getSingleton().loadAnimationsFromXML("thrive.anims"); //For demos: diff --git a/src/gui/CEGUIWindow.cpp b/src/gui/CEGUIWindow.cpp index 263e4775133..1c4f9fc917e 100644 --- a/src/gui/CEGUIWindow.cpp +++ b/src/gui/CEGUIWindow.cpp @@ -261,7 +261,7 @@ CEGUIWindow::destroy() const { std::string CEGUIWindow::getText() const { - return std::string(m_window->getText().c_str()); + return m_window->getText().c_str(); } @@ -381,7 +381,7 @@ CEGUIWindow::listWidgetGetFirstSelectedItemText(){ if(!selected) return ""; - return std::string(selected->getText().c_str()); + return selected->getText().c_str(); } int @@ -580,7 +580,7 @@ CEGUIWindow::setSizeRel( std::string CEGUIWindow::getName() { - return std::string(m_window->getName().c_str()); + return m_window->getName().c_str(); } void diff --git a/src/sound/caudio_include.h b/src/sound/caudio_include.h index de3b8c6ca22..9038fb4b091 100644 --- a/src/sound/caudio_include.h +++ b/src/sound/caudio_include.h @@ -20,11 +20,6 @@ #include -__attribute__((unused)) static void toWINSTRNotUnused(){ -#ifndef _WIN32 - cAudio::toWINSTR(static_cast(nullptr)); -#endif -} __attribute__((unused)) static void toUTF8NotUnused(){