mirror of
https://github.com/glest/glest-source.git
synced 2025-08-10 02:16:31 +02:00
Lots of changes to make glest binary more portable on linux.
This commit is contained in:
@@ -194,19 +194,27 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
|||||||
ADD_DEFINITIONS("-DSNAPCRAFT")
|
ADD_DEFINITIONS("-DSNAPCRAFT")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT INSTALL_DIR_BIN)
|
IF(NOT CMAKE_INSTALL_PREFIX)
|
||||||
SET(INSTALL_DIR_BIN "${CMAKE_INSTALL_PREFIX}/games/" CACHE PATH "The installation path for binaries")
|
SET(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT BINDIR)
|
||||||
|
SET(BINDIR "/bin/")
|
||||||
|
add_definitions("-DBINDIR=${BINDIR}")
|
||||||
|
SET(INSTALL_DIR_BIN "${CMAKE_INSTALL_PREFIX}/${BINDIR}" CACHE PATH "The installation path for binaries")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
# The data dir will get defined as a macro at compile-time
|
# The data dir will get defined as a macro at compile-time
|
||||||
IF(NOT INSTALL_DIR_DATA)
|
IF(NOT DATADIR)
|
||||||
SET(INSTALL_DIR_DATA "${CMAKE_INSTALL_PREFIX}/share/glest/" CACHE PATH "The installation path for data files")
|
SET(DATADIR "/share/glest/" CACHE PATH "The path for the executable to find data files")
|
||||||
|
add_definitions("-DDATADIR=${DATADIR}")
|
||||||
|
SET(INSTALL_DIR_DATA "${CMAKE_INSTALL_PREFIX}/${DATADIR}" CACHE PATH "The installation path for data files")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(INSTALL_DIR_INI "${INSTALL_DIR_DATA}")
|
SET(INSTALL_DIR_INI "${INSTALL_DIR_DATA}")
|
||||||
IF(NOT INSTALL_DIR_DESKTOP)
|
IF(NOT INSTALL_DIR_DESKTOP)
|
||||||
SET(INSTALL_DIR_DESKTOP "${CMAKE_INSTALL_PREFIX}/applications/" CACHE PATH "The installation path for desktop files")
|
SET(INSTALL_DIR_DESKTOP "${CMAKE_INSTALL_PREFIX}/share/applications/" CACHE PATH "The installation path for desktop files")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(NOT INSTALL_DIR_ICON)
|
IF(NOT INSTALL_DIR_ICON)
|
||||||
SET(INSTALL_DIR_ICON "${CMAKE_INSTALL_PREFIX}/share/pixmaps/" CACHE PATH "The installation path for icon files")
|
SET(INSTALL_DIR_ICON "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps" CACHE PATH "The installation path for icon files")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(NOT INSTALL_DIR_MAN)
|
IF(NOT INSTALL_DIR_MAN)
|
||||||
SET(INSTALL_DIR_MAN "${CMAKE_INSTALL_PREFIX}/share/man/man6/" CACHE PATH "The installation path for manpage files")
|
SET(INSTALL_DIR_MAN "${CMAKE_INSTALL_PREFIX}/share/man/man6/" CACHE PATH "The installation path for manpage files")
|
||||||
|
@@ -6,38 +6,43 @@ then
|
|||||||
echo "Ubuntu 18.04 is required! System found: $ID $VERSION_ID"
|
echo "Ubuntu 18.04 is required! System found: $ID $VERSION_ID"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
rm -rf Glest
|
||||||
mkdir Glest
|
mkdir Glest
|
||||||
mkdir deps
|
|
||||||
|
|
||||||
echo "\nGetting build deps..."
|
echo
|
||||||
|
echo "Getting build deps..."
|
||||||
sudo ../linux/build-deps.sh
|
sudo ../linux/build-deps.sh
|
||||||
|
|
||||||
echo "\nGetting and installing required libs..."
|
echo
|
||||||
sudo apt clean
|
echo "Building and installing Glest..."
|
||||||
sudo apt --download-only --reinstall install famfamfam-flag-png p7zip-full libcurl4 libfontconfig1 libfribidi0 libftgl2 libgcc1 libgl1-mesa-glx libgl1 libglew2.0 libglu1-mesa libircclient1 libjpeg8 liblua5.3-0 libminiupnpc10 libopenal1 libpng16-16 libsdl2-2.0-0 libstdc++6 libvorbisfile3 libwxbase3.0-0v5 libwxgtk3.0-0v5 libx11-6 libpulse0
|
|
||||||
cp /var/cache/apt/archives/*.deb deps
|
|
||||||
|
|
||||||
mkdir curdep
|
|
||||||
cd curdep
|
|
||||||
for f in ../deps/*.deb;
|
|
||||||
do
|
|
||||||
ar x $f
|
|
||||||
tar -xf data.tar.* -C ../Glest
|
|
||||||
rm *
|
|
||||||
done;
|
|
||||||
cd ..
|
|
||||||
rm -rf curdep deps
|
|
||||||
|
|
||||||
echo "\nBuilding and installing Glest..."
|
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_MAP_EDITOR=OFF -DBUILD_MODEL_VIEWER=OFF -DINSTALL_DIR_BIN=/usr/bin/ -DINSTALL_DIR_DATA=/usr/share/glest/ ../../..
|
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_MAP_EDITOR=OFF -DBUILD_MODEL_VIEWER=OFF ../../..
|
||||||
make -j$(nproc) DESTDIR=../Glest
|
make -j$(nproc) && make install DESTDIR=../Glest
|
||||||
rm -r *
|
rm -r *
|
||||||
|
|
||||||
echo "\n Getting and installing data..."
|
echo
|
||||||
git clone https://github.com/glest/glest-data.git
|
echo "Getting and installing data..."
|
||||||
mkdir build && cd build
|
../../linux/clone-data.sh
|
||||||
cmake -DINSTALL_DIR_BIN=/usr/bin/ -DINSTALL_DIR_DATA=/usr/share/glest/ -DINSTALL_DIR_DESKTOP=/usr/share/applications/ -DINSTALL_DIR_ICON=/usr/share/icons/hicolor/256x256/ glest-data
|
|
||||||
make -j$(nproc) DESTDIR=../Glest
|
cmake -DCMAKE_INSTALL_PREFIX=/usr ../../linux/../data
|
||||||
|
make && make install DESTDIR=../Glest
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
# Remove useless metainfo.
|
||||||
|
rm Glest/usr/share/metainfo/io.glest.Editor.appdata.xml
|
||||||
|
|
||||||
|
wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Creating the AppImage..."
|
||||||
|
|
||||||
|
# Path to pulseaudio libs.
|
||||||
|
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/pulseaudio/
|
||||||
|
:/usr/lib/i386-linux-gnu/pulseaudio/:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
chmod +x linuxdeploy-x86_64.AppImage
|
||||||
|
./linuxdeploy-x86_64.AppImage --appdir=Glest --output appimage
|
||||||
|
chmod +x Glest*.AppImage
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "done!"
|
||||||
|
@@ -19,10 +19,9 @@ parts:
|
|||||||
glest:
|
glest:
|
||||||
plugin: cmake
|
plugin: cmake
|
||||||
configflags:
|
configflags:
|
||||||
|
- "-DCMAKE_INSTALL_PREFIX=/usr"
|
||||||
- "-DBUILD_MAP_EDITOR=OFF"
|
- "-DBUILD_MAP_EDITOR=OFF"
|
||||||
- "-DBUILD_MODEL_VIEWER=OFF"
|
- "-DBUILD_MODEL_VIEWER=OFF"
|
||||||
- "-DINSTALL_DIR_BIN=/usr/bin/"
|
|
||||||
- "-DINSTALL_DIR_DATA=/share/glest/"
|
|
||||||
source-type: git
|
source-type: git
|
||||||
source: https://github.com/glest/glest-source.git
|
source: https://github.com/glest/glest-source.git
|
||||||
#source-type: local
|
#source-type: local
|
||||||
@@ -95,10 +94,9 @@ parts:
|
|||||||
glest-data:
|
glest-data:
|
||||||
plugin: cmake
|
plugin: cmake
|
||||||
configflags:
|
configflags:
|
||||||
- "-DINSTALL_DIR_BIN=/usr/bin/"
|
- "-DCMAKE_INSTALL_PREFIX=/usr"
|
||||||
- "-DINSTALL_DIR_DATA=/share/glest/"
|
- "-DBUILD_MAP_EDITOR=OFF"
|
||||||
- "-DINSTALL_DIR_DESKTOP=/share/applications/"
|
- "-DBUILD_MODEL_VIEWER=OFF"
|
||||||
- "-DINSTALL_DIR_ICON=/share/glest/"
|
|
||||||
#source-type: local
|
#source-type: local
|
||||||
#source: glest-data
|
#source: glest-data
|
||||||
source-type: git
|
source-type: git
|
||||||
|
@@ -9,7 +9,6 @@ IF(BUILD_GLEST)
|
|||||||
MESSAGE(STATUS "Build ${TARGET_NAME} = YES")
|
MESSAGE(STATUS "Build ${TARGET_NAME} = YES")
|
||||||
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11")
|
||||||
add_definitions("-DDATADIR=${INSTALL_DIR_DATA}")
|
|
||||||
|
|
||||||
# This is an environment var that pops up when building with snapcraft.
|
# This is an environment var that pops up when building with snapcraft.
|
||||||
# Use this to activate snapcraft path...
|
# Use this to activate snapcraft path...
|
||||||
|
@@ -233,12 +233,10 @@ namespace Game {
|
|||||||
foundPath = tryCustomPath(cfgType, fileName, custom_path);
|
foundPath = tryCustomPath(cfgType, fileName, custom_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SNAPCRAFT
|
|
||||||
if (foundPath == false) {
|
if (foundPath == false) {
|
||||||
currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
|
currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
|
||||||
foundPath = tryCustomPath(cfgType, fileName, currentpath);
|
foundPath = tryCustomPath(cfgType, fileName, currentpath);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (foundPath == false) {
|
if (foundPath == false) {
|
||||||
@@ -265,16 +263,11 @@ namespace Game {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SNAPCRAFT
|
|
||||||
if (foundPath == false) {
|
|
||||||
foundPath = tryCustomPath(cfgType, fileName, std::getenv("SNAP") +
|
|
||||||
endPathWithSlash(formatPath(TOSTRING(DATADIR))));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DATADIR
|
#if defined(DATADIR) && defined(BINDIR)
|
||||||
if (foundPath == false) {
|
if ((foundPath == false)) {
|
||||||
foundPath = tryCustomPath(cfgType, fileName, endPathWithSlash(formatPath(TOSTRING(DATADIR))));
|
currentpath = getDatPath();
|
||||||
|
foundPath = tryCustomPath(cfgType, fileName, currentpath);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
OPTION(FORCE_EMBEDDED_LIBS "Force use of embedded libraries' code." OFF)
|
OPTION(FORCE_EMBEDDED_LIBS "Force use of embedded libraries' code." OFF)
|
||||||
|
|
||||||
add_definitions("-DDATADIR=${INSTALL_DIR_DATA}")
|
|
||||||
|
|
||||||
# On Travis, the build fails on osx and Ubuntu trusty using
|
# On Travis, the build fails on osx and Ubuntu trusty using
|
||||||
# clang 5.0 unless the -std=c++11 if used
|
# clang 5.0 unless the -std=c++11 if used
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
||||||
|
@@ -300,6 +300,13 @@ namespace Shared {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
std::string getExecPath();
|
||||||
|
#endif // __linux
|
||||||
|
void eraseSubStr(std::string & mainStr, const std::string & toErase);
|
||||||
|
#if defined(DATADIR) && defined(BINDIR)
|
||||||
|
string getDatPath();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} //end namespace
|
} //end namespace
|
||||||
|
|
||||||
|
@@ -53,10 +53,8 @@ namespace Shared {
|
|||||||
namespace Util {
|
namespace Util {
|
||||||
|
|
||||||
string Properties::applicationPath = "";
|
string Properties::applicationPath = "";
|
||||||
#ifdef SNAPCRAFT
|
#if defined(DATADIR) && defined(BINDIR)
|
||||||
string Properties::applicationDataPath = std::getenv("SNAP") + formatPath(TOSTRING(DATADIR));
|
string Properties::applicationDataPath = getDatPath();
|
||||||
#elif FLATPAK
|
|
||||||
string Properties::applicationDataPath = formatPath(TOSTRING(DATADIR));
|
|
||||||
#else
|
#else
|
||||||
string Properties::applicationDataPath = "";
|
string Properties::applicationDataPath = "";
|
||||||
#endif
|
#endif
|
||||||
@@ -266,8 +264,7 @@ namespace Shared {
|
|||||||
mapTagReplacementValues["$APPLICATIONPATH"] = Properties::applicationPath;
|
mapTagReplacementValues["$APPLICATIONPATH"] = Properties::applicationPath;
|
||||||
mapTagReplacementValues["%%APPLICATIONPATH%%"] = Properties::applicationPath;
|
mapTagReplacementValues["%%APPLICATIONPATH%%"] = Properties::applicationPath;
|
||||||
mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath;
|
mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath;
|
||||||
|
mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath;
|
||||||
mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationDataPath;
|
|
||||||
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationDataPath;
|
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationDataPath;
|
||||||
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = Properties::applicationDataPath;
|
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = Properties::applicationDataPath;
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include <io.h> // for open()
|
#include <io.h> // for open()
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h> // for open()
|
#include <sys/stat.h> // for open()
|
||||||
@@ -874,5 +875,45 @@ namespace Shared {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
std::string getExecPath() {
|
||||||
|
char buff[PATH_MAX];
|
||||||
|
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
|
||||||
|
if (len != -1) {
|
||||||
|
buff[len] = '\0';
|
||||||
|
return std::string(buff);
|
||||||
|
}
|
||||||
|
/* handle error condition */
|
||||||
|
return std::string("");
|
||||||
|
}
|
||||||
|
#endif // __linux__
|
||||||
|
void eraseSubStr(std::string & mainStr, const std::string & toErase)
|
||||||
|
{
|
||||||
|
// Search for the substring in string
|
||||||
|
size_t pos = mainStr.find(toErase);
|
||||||
|
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
// If found then erase it from string
|
||||||
|
mainStr.erase(pos, toErase.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(DATADIR) && defined(BINDIR)
|
||||||
|
string getDatPath() {
|
||||||
|
string curPath = getExecPath();
|
||||||
|
printf("\n binary Path: %s", curPath.c_str());
|
||||||
|
const string subBinPath = endPathWithSlash(formatPath(TOSTRING(BINDIR))) + "glest";
|
||||||
|
printf("\n binary Path: %s", subBinPath.c_str());
|
||||||
|
eraseSubStr(curPath, subBinPath);
|
||||||
|
printf("\n path now: %s", curPath.c_str());
|
||||||
|
string datPath = curPath + endPathWithSlash(TOSTRING(DATADIR));
|
||||||
|
printf("\n what is this???: %s", TOSTRING(DATADIR));
|
||||||
|
printf("\n data path: %s", datPath.c_str());
|
||||||
|
return datPath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} //end namespace
|
} //end namespace
|
||||||
|
Reference in New Issue
Block a user