Skip to content

Commit

Permalink
Improving AppImage generation trials.
Browse files Browse the repository at this point in the history
Tried to include dependencies from the system.

It appears GLEW and FreeGLUT depend on drivers from the OS, since I'm running on NVIDIA it ties itself with it. Meaning that I need to build for NVIDIA/MESA/... etc.
  • Loading branch information
RicardoEPRodrigues committed Jul 4, 2018
1 parent a88ae7c commit 2bf4050
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 26 deletions.
6 changes: 3 additions & 3 deletions 3Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ endif ()
add_custom_target(CopyFilesEngine
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E echo Copying Engine files
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_NAME}/config ${EXECUTABLE_OUTPUT_PATH}/config/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_NAME}/shaders ${EXECUTABLE_OUTPUT_PATH}/shaders/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_NAME}/assets ${EXECUTABLE_OUTPUT_PATH}/assets/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/config ${EXECUTABLE_OUTPUT_PATH}/config/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${EXECUTABLE_OUTPUT_PATH}/shaders/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets ${EXECUTABLE_OUTPUT_PATH}/assets/
)

add_dependencies(${PROJECT_NAME} CopyFilesEngine)
2 changes: 1 addition & 1 deletion 3EngineExecutable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ if (UNIX AND NOT APPLE)
add_custom_target(AppImage
DEPENDS LightScene
COMMAND ${CMAKE_COMMAND} -E echo Making AppImage from path ${EXECUTABLE_OUTPUT_PATH}
COMMAND /bin/sh "${CMAKE_CURRENT_SOURCE_DIR}/../BuildTools/AppImage/build.sh" "${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/../BuildTools/AppImage/3Engine.AppDir" "${RUNTIME_OUTPUT_DIRECTORY}/AppImage"
COMMAND /bin/bash "${CMAKE_CURRENT_SOURCE_DIR}/../BuildTools/AppImage/build.sh" "${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/../BuildTools/AppImage/3Engine.AppDir" "${RUNTIME_OUTPUT_DIRECTORY}/AppImage"
)
endif ()
57 changes: 35 additions & 22 deletions BuildTools/AppImage/build.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
#!/bin/sh
#!/bin/bash

if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
echo "Missing Arguments. Usage: ./build.sh <Binaries Path> <AppDir Files Path> <Destination Path>"
exit 1
fi

binariesPath=$(readlink -f $1)
appDirPath=$(readlink -f $2)
destPath=$(readlink -f $3)
appDirName=${appDirPath##*/}
destAppDirPath=${destPath}/${appDirName}
SCRIPT_PATH=$(dirname "$0")

if [ ! -d ${binariesPath} ]; then
echo "Binaries folder doesn't exist. ${binariesPath} . Exiting..."
BINARIES_PATH=$(readlink -f $1)
APPDIR_PATH=$(readlink -f $2)
DEST_PATH=$(readlink -f $3)
APPDIR_NAME=${APPDIR_PATH##*/}
APPDIR_DEST_PATH=${DEST_PATH}/${APPDIR_NAME}

if [ ! -d ${BINARIES_PATH} ]; then
echo "Binaries folder doesn't exist. ${BINARIES_PATH} . Exiting..."
exit 1
fi

if [ ! -d ${appDirPath} ]; then
echo "AppDir folder doesn't exist. ${appDirPath} . Exiting..."
if [ ! -d ${APPDIR_PATH} ]; then
echo "AppDir folder doesn't exist. ${APPDIR_PATH} . Exiting..."
exit 1
fi


mkdir -p ${destPath}
cd ${destPath}
mkdir -p ${DEST_PATH}
cd ${DEST_PATH}

echo "Copying AppDir Folder"
cp -R ${appDirPath} ${destPath}
cp -R ${APPDIR_PATH} ${DEST_PATH}
if [ $? -ne 0 ]; then
echo "Failed Copying AppDir Folder. Exiting..."
exit 1
fi

echo "Copying Binaries Files into AppDir"
cp -R ${binariesPath}/. ${destAppDirPath}
cp -R ${BINARIES_PATH}/. ${APPDIR_DEST_PATH}
if [ $? -ne 0 ]; then
echo "Failed Copying Binaries Files. Exiting..."
exit 1
fi

echo "Moving Executables to AppDir/bin"
mkdir -p ${destAppDirPath}/bin
#CPLP=${SCRIPT_PATH}/cpld.sh

#echo "Copy 3Engine library dependencies"
#mkdir -p ${APPDIR_DEST_PATH}/lib
#for i in `find ${APPDIR_DEST_PATH}/lib -maxdepth 1 -executable -type f`; do
# if [[ ${i} = *".so" ]]; then
# ${CPLP} ${i} ${APPDIR_DEST_PATH}/lib #> /dev/null
# fi
#done

echo "Moving Executables to AppDir/bin" # and copy library dependencies
mkdir -p ${APPDIR_DEST_PATH}/bin
# Gets all executables and places them on bin folder
for i in `find ${destAppDirPath} -maxdepth 1 -executable -type f`; do
if [ ${i##*/} != "AppRun" ]; then
mv ${i} ${destAppDirPath}/bin
for i in `find ${APPDIR_DEST_PATH} -maxdepth 1 -executable -type f`; do
if [ ${i##*/} != "AppRun" ] && [[ ${i} != *".desktop" ]] && [[ ${i} != *".png" ]]; then
# ${CPLP} ${i} ${APPDIR_DEST_PATH}/lib #> /dev/null
mv ${i} ${APPDIR_DEST_PATH}/bin
fi
done

Expand All @@ -65,10 +78,10 @@ fi
export ARCH=x86_64

# Create AppImage with the name of the AppDir Folder
./appimagetool.AppImage ${appDirName} ${appDirName%.AppDir}.AppImage
./appimagetool.AppImage ${APPDIR_NAME} ${APPDIR_NAME%.AppDir}.AppImage
if [ $? -ne 0 ]; then
echo "Unable to create ${appDirName%.AppDir}.AppImage. Exiting..."
echo "Unable to create ${APPDIR_NAME%.AppDir}.AppImage. Exiting..."
exit 1
fi

echo "Successfully created ${appDirName%.AppDir}.AppImage"
echo "Successfully created ${APPDIR_NAME%.AppDir}.AppImage"
41 changes: 41 additions & 0 deletions BuildTools/AppImage/cpld.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# Author : Hemanth.HM
# Email : hemanth[dot]hm[at]gmail[dot]com
# License : GNU GPLv3
#

function usage()
{
cat << EOU
Usage: bash $0 <path to the binary> <path to copy the dependencies>
EOU
exit 1
}

#Validate the inputs
[[ $# < 2 ]] && usage

#Check if the paths are vaild
[[ ! -e $1 ]] && echo "Not a vaild input $1" && exit 1
[[ -d $2 ]] || echo "No such directory $2 creating..."&& mkdir -p "$2"

#Get the library dependencies
echo "Collecting the shared library dependencies for $1..."
deps=$(ldd $1 | awk 'BEGIN{ORS=" "}$1\
~/^\//{print $1}$3~/^\//{print $3}'\
| sed 's/,$/\n/')
echo "Copying the dependencies to $2"

#Copy the deps
userLibs="/usr/lib/"*
for dep in ${deps}
do
if [[ ${dep} = ${userLibs} ]]; then
echo "Copying ${dep} to $2"
cp "${dep}" "$2"
else
echo "Ignoring system dependency ${dep}"
fi
done

echo "Done!"

0 comments on commit 2bf4050

Please sign in to comment.