diff --git a/3Engine/CMakeLists.txt b/3Engine/CMakeLists.txt index cbcfef3..5964820 100644 --- a/3Engine/CMakeLists.txt +++ b/3Engine/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/3EngineExecutable/CMakeLists.txt b/3EngineExecutable/CMakeLists.txt index bc71161..2b86be6 100644 --- a/3EngineExecutable/CMakeLists.txt +++ b/3EngineExecutable/CMakeLists.txt @@ -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 () \ No newline at end of file diff --git a/BuildTools/AppImage/build.sh b/BuildTools/AppImage/build.sh index 9d43b22..4163ede 100755 --- a/BuildTools/AppImage/build.sh +++ b/BuildTools/AppImage/build.sh @@ -1,50 +1,63 @@ -#!/bin/sh +#!/bin/bash if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then echo "Missing Arguments. Usage: ./build.sh " 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 @@ -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" \ No newline at end of file +echo "Successfully created ${APPDIR_NAME%.AppDir}.AppImage" \ No newline at end of file diff --git a/BuildTools/AppImage/cpld.sh b/BuildTools/AppImage/cpld.sh new file mode 100755 index 0000000..94ffb44 --- /dev/null +++ b/BuildTools/AppImage/cpld.sh @@ -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 +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!" \ No newline at end of file