2021-08-09 12:19:27 +02:00
|
|
|
#!/bin/env bash
|
2022-09-25 22:59:01 +02:00
|
|
|
set -e
|
2021-08-09 12:19:27 +02:00
|
|
|
|
|
|
|
if [ ! -e "src/api/api.h" ]; then
|
|
|
|
echo "Please run this script from the root directory of Lite XL."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
source scripts/common.sh
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
ARCH="$(uname -m)"
|
|
|
|
BUILD_DIR="$(get_default_build_dir)"
|
|
|
|
RUN_BUILD=true
|
|
|
|
STATIC_BUILD=false
|
|
|
|
ADDONS=false
|
|
|
|
BUILD_TYPE="debug"
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
show_help(){
|
|
|
|
echo
|
2021-08-29 10:15:55 +02:00
|
|
|
echo "Usage: $0 <OPTIONS>"
|
2021-08-09 12:19:27 +02:00
|
|
|
echo
|
|
|
|
echo "Available options:"
|
|
|
|
echo
|
|
|
|
echo "-h --help Show this help and exits."
|
|
|
|
echo "-b --builddir DIRNAME Sets the name of the build dir (no path)."
|
2022-09-25 22:59:01 +02:00
|
|
|
echo " Default: '${BUILD_DIR}'."
|
|
|
|
echo " --debug Debug this script."
|
2021-08-09 12:19:27 +02:00
|
|
|
echo "-n --nobuild Skips the build step, use existing files."
|
2022-09-25 22:59:01 +02:00
|
|
|
echo "-s --static Specify if building using static libraries."
|
2021-08-09 12:19:27 +02:00
|
|
|
echo "-v --version VERSION Specify a version, non whitespace separated string."
|
2022-09-25 22:59:01 +02:00
|
|
|
echo "-a --addons Install 3rd party addons."
|
|
|
|
echo "-r --release Compile in release mode."
|
2021-08-09 12:19:27 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
initial_arg_count=$#
|
2021-08-09 12:19:27 +02:00
|
|
|
|
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
2022-09-25 22:59:01 +02:00
|
|
|
-h|--help)
|
2021-08-09 12:19:27 +02:00
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-b|--builddir)
|
|
|
|
BUILD_DIR="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
-a|--addons)
|
|
|
|
ADDONS=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--debug)
|
|
|
|
set -x
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-09 12:19:27 +02:00
|
|
|
-n|--nobuild)
|
|
|
|
RUN_BUILD=false
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
-r|--release)
|
|
|
|
BUILD_TYPE="release"
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-09 12:19:27 +02:00
|
|
|
-s|--static)
|
|
|
|
STATIC_BUILD=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-v|--version)
|
|
|
|
VERSION="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
# show help if no valid argument was found
|
|
|
|
if [ $initial_arg_count -eq $# ]; then
|
2021-08-09 12:19:27 +02:00
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
setup_appimagetool() {
|
2022-09-25 22:59:01 +02:00
|
|
|
if [ ! -e appimagetool ]; then
|
|
|
|
if ! wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then
|
|
|
|
echo "Could not download the appimagetool for the arch '${ARCH}'."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
chmod 0755 appimagetool
|
2021-08-09 12:19:27 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
download_appimage_apprun() {
|
2021-08-09 12:19:27 +02:00
|
|
|
if [ ! -e AppRun ]; then
|
|
|
|
if ! wget -O AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH}" ; then
|
|
|
|
echo "Could not download AppRun for the arch '${ARCH}'."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
chmod 0755 AppRun
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
build_litexl() {
|
2021-08-09 12:19:27 +02:00
|
|
|
if [ -e build ]; then
|
|
|
|
rm -rf build
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e ${BUILD_DIR} ]; then
|
|
|
|
rm -rf ${BUILD_DIR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Build lite-xl..."
|
|
|
|
sleep 1
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $STATIC_BUILD == false ]]; then
|
|
|
|
meson setup --buildtype=$BUILD_TYPE --prefix=/usr ${BUILD_DIR}
|
|
|
|
else
|
|
|
|
meson setup --wrap-mode=forcefallback \
|
|
|
|
--buildtype=$BUILD_TYPE \
|
|
|
|
--prefix=/usr \
|
|
|
|
${BUILD_DIR}
|
|
|
|
fi
|
2021-08-09 12:19:27 +02:00
|
|
|
meson compile -C ${BUILD_DIR}
|
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
generate_appimage() {
|
2021-08-09 12:19:27 +02:00
|
|
|
if [ -e LiteXL.AppDir ]; then
|
|
|
|
rm -rf LiteXL.AppDir
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating LiteXL.AppDir..."
|
|
|
|
|
|
|
|
DESTDIR="$(realpath LiteXL.AppDir)" meson install --skip-subprojects -C ${BUILD_DIR}
|
|
|
|
mv AppRun LiteXL.AppDir/
|
|
|
|
# These could be symlinks but it seems they doesn't work with AppimageLauncher
|
|
|
|
cp resources/icons/lite-xl.svg LiteXL.AppDir/
|
2021-08-31 14:45:00 +02:00
|
|
|
cp resources/linux/org.lite_xl.lite_xl.desktop LiteXL.AppDir/
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $ADDONS == true ]]; then
|
|
|
|
addons_download "${BUILD_DIR}"
|
|
|
|
addons_install "${BUILD_DIR}" "LiteXL.AppDir/usr/share/lite-xl"
|
|
|
|
fi
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
if [[ $STATIC_BUILD == false ]]; then
|
|
|
|
echo "Copying libraries..."
|
|
|
|
|
|
|
|
mkdir -p LiteXL.AppDir/usr/lib/
|
|
|
|
|
|
|
|
local allowed_libs=(
|
|
|
|
libfreetype
|
|
|
|
libpcre2
|
|
|
|
libSDL2
|
|
|
|
libsndio
|
|
|
|
liblua
|
|
|
|
)
|
|
|
|
|
|
|
|
while read line; do
|
|
|
|
local libname="$(echo $line | cut -d' ' -f1)"
|
|
|
|
local libpath="$(echo $line | cut -d' ' -f2)"
|
|
|
|
for lib in "${allowed_libs[@]}" ; do
|
|
|
|
if echo "$libname" | grep "$lib" > /dev/null ; then
|
|
|
|
cp "$libpath" LiteXL.AppDir/usr/lib/
|
|
|
|
continue 2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo " Ignoring: $libname"
|
|
|
|
done < <(ldd build/src/lite-xl | awk '{print $1 " " $3}')
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Generating AppImage..."
|
|
|
|
local version=""
|
|
|
|
if [ -n "$VERSION" ]; then
|
|
|
|
version="-$VERSION"
|
|
|
|
fi
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
if [[ $ADDONS == true ]]; then
|
|
|
|
version="${version}-addons"
|
|
|
|
fi
|
|
|
|
|
2023-04-16 15:18:40 +02:00
|
|
|
./appimagetool --appimage-extract-and-run LiteXL.AppDir LiteXL${version}-${ARCH}.AppImage
|
2021-08-09 12:19:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_appimagetool
|
|
|
|
download_appimage_apprun
|
|
|
|
if [[ $RUN_BUILD == true ]]; then build_litexl; fi
|
|
|
|
generate_appimage $1
|