2020-06-30 16:16:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-12-04 14:20:11 +01:00
|
|
|
# strip-components is normally set to 1 to strip the initial "data" from the
|
|
|
|
# directory path.
|
2020-07-05 12:36:46 +02:00
|
|
|
copy_directory_from_repo () {
|
2020-12-04 14:20:11 +01:00
|
|
|
local tar_options=()
|
|
|
|
if [[ $1 == --strip-components=* ]]; then
|
|
|
|
tar_options+=($1)
|
|
|
|
shift
|
|
|
|
fi
|
2020-07-05 12:36:46 +02:00
|
|
|
local dirname="$1"
|
|
|
|
local destdir="$2"
|
2021-08-29 07:37:02 +02:00
|
|
|
_archive "$use_branch" "$dirname" "$destdir" "${tar_options[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_archive () {
|
2021-08-30 01:16:14 +02:00
|
|
|
if [[ $git_available -eq 1 ]]; then
|
2021-08-29 07:37:02 +02:00
|
|
|
git archive "$1" "$2" --format=tar | tar xf - -C "$3" "$4"
|
|
|
|
else
|
|
|
|
cp -r "$2" "$3"
|
|
|
|
fi
|
2020-07-05 12:36:46 +02:00
|
|
|
}
|
|
|
|
|
2020-06-30 16:16:28 +02:00
|
|
|
# Check if build directory is ok to be used to build.
|
|
|
|
build_dir_is_usable () {
|
|
|
|
local build="$1"
|
|
|
|
if [[ $build == */* || -z "$build" ]]; then
|
|
|
|
echo "invalid build directory, no path allowed: \"$build\""
|
|
|
|
return 1
|
|
|
|
fi
|
2021-08-30 01:16:14 +02:00
|
|
|
if [[ $git_available -eq 1 ]]; then
|
2021-08-29 07:37:02 +02:00
|
|
|
git ls-files --error-unmatch "$build" &> /dev/null
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
echo "invalid path, \"$build\" is under revision control"
|
|
|
|
return 1
|
|
|
|
fi
|
2020-06-30 16:16:28 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ordinary release build
|
|
|
|
lite_build () {
|
2021-02-24 17:39:12 +01:00
|
|
|
local build="$1"
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir_is_usable "$build" || exit 1
|
|
|
|
rm -fr "$build"
|
2021-08-19 23:30:44 +02:00
|
|
|
setup_options=()
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
setup_options+=(-Dbundle=true)
|
|
|
|
fi
|
|
|
|
meson setup "${setup_options[@]}" "$build" || exit 1
|
2020-06-30 16:16:28 +02:00
|
|
|
ninja -C "$build" || exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build using Profile Guided Optimizations (PGO)
|
|
|
|
lite_build_pgo () {
|
2021-02-24 17:39:12 +01:00
|
|
|
local build="$1"
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir_is_usable "$build" || exit 1
|
|
|
|
rm -fr "$build"
|
2021-02-24 17:39:12 +01:00
|
|
|
meson setup --buildtype=release -Db_pgo=generate "$build" || exit 1
|
2020-06-30 16:16:28 +02:00
|
|
|
ninja -C "$build" || exit 1
|
2020-07-05 12:36:46 +02:00
|
|
|
copy_directory_from_repo data "$build/src"
|
2021-06-24 14:49:18 +02:00
|
|
|
"$build/src/lite-xl"
|
2020-06-30 16:16:28 +02:00
|
|
|
meson configure -Db_pgo=use "$build"
|
|
|
|
ninja -C "$build" || exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
lite_build_package_windows () {
|
2021-05-06 09:36:39 +02:00
|
|
|
local portable="-msys"
|
2021-02-24 17:39:12 +01:00
|
|
|
if [ "$1" == "-portable" ]; then
|
2021-05-06 09:36:39 +02:00
|
|
|
portable=""
|
2021-02-24 17:39:12 +01:00
|
|
|
shift
|
|
|
|
fi
|
|
|
|
local build="$1"
|
|
|
|
local arch="$2"
|
2020-12-03 16:46:18 +01:00
|
|
|
local os="win"
|
2020-07-30 14:25:21 +02:00
|
|
|
local pdir=".package-build/lite-xl"
|
2021-05-06 09:36:39 +02:00
|
|
|
if [ -z "$portable" ]; then
|
2020-12-03 16:46:18 +01:00
|
|
|
local bindir="$pdir"
|
|
|
|
local datadir="$pdir/data"
|
|
|
|
else
|
|
|
|
local bindir="$pdir/bin"
|
|
|
|
local datadir="$pdir/share/lite-xl"
|
|
|
|
fi
|
|
|
|
mkdir -p "$bindir"
|
|
|
|
mkdir -p "$datadir"
|
2020-12-04 12:00:42 +01:00
|
|
|
for module_name in core plugins colors fonts; do
|
2020-12-04 14:20:11 +01:00
|
|
|
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
|
2020-12-03 16:46:18 +01:00
|
|
|
done
|
2021-08-12 09:20:55 +02:00
|
|
|
# copy the meson generated start.lua file
|
|
|
|
cp "$build/start.lua" "$datadir/core"
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2021-06-24 14:49:18 +02:00
|
|
|
cp "$build/src/lite-xl.exe" "$bindir"
|
|
|
|
strip --strip-all "$bindir/lite-xl.exe"
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2021-02-24 17:39:12 +01:00
|
|
|
local package_name="lite-xl-$os-$arch$portable.zip"
|
2020-07-30 14:25:21 +02:00
|
|
|
zip "$package_name" -r "lite-xl"
|
2020-06-30 16:16:28 +02:00
|
|
|
mv "$package_name" ..
|
|
|
|
popd
|
|
|
|
rm -fr ".package-build"
|
|
|
|
echo "created package $package_name"
|
|
|
|
}
|
2021-06-20 17:37:08 +02:00
|
|
|
|
2021-04-23 16:05:57 +02:00
|
|
|
lite_build_package_macos () {
|
2021-02-24 17:39:12 +01:00
|
|
|
local build="$1"
|
|
|
|
local arch="$2"
|
2021-04-23 16:05:57 +02:00
|
|
|
local os="macos"
|
2021-04-16 00:51:10 +02:00
|
|
|
|
|
|
|
local appdir=".package-build/lite-xl.app"
|
2021-04-18 17:51:31 +02:00
|
|
|
local bindir="$appdir/Contents/MacOS"
|
|
|
|
local datadir="$appdir/Contents/Resources"
|
|
|
|
mkdir -p "$bindir" "$datadir"
|
2020-12-04 12:00:42 +01:00
|
|
|
for module_name in core plugins colors fonts; do
|
2020-12-04 14:20:11 +01:00
|
|
|
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
|
2020-12-03 16:46:18 +01:00
|
|
|
done
|
2021-08-12 09:20:55 +02:00
|
|
|
# copy the meson generated start.lua file
|
|
|
|
cp "$build/start.lua" "$datadir/core"
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2021-06-20 17:37:08 +02:00
|
|
|
cp resources/icons/icon.icns "$appdir/Contents/Resources/icon.icns"
|
|
|
|
cp resources/macos/Info.plist "$appdir/Contents/Info.plist"
|
2021-06-24 14:49:18 +02:00
|
|
|
cp "$build/src/lite-xl" "$bindir/lite-xl"
|
2021-04-16 00:51:10 +02:00
|
|
|
strip "$bindir/lite-xl"
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2021-04-16 00:51:10 +02:00
|
|
|
local package_name="lite-xl-$os-$arch.zip"
|
2020-06-30 16:16:28 +02:00
|
|
|
zip "$package_name" -r "lite-xl.app"
|
|
|
|
mv "$package_name" ..
|
|
|
|
popd
|
|
|
|
rm -fr ".package-build"
|
|
|
|
echo "created package $package_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
lite_build_package_linux () {
|
2021-02-24 17:39:12 +01:00
|
|
|
local portable=""
|
|
|
|
if [ "$1" == "-portable" ]; then
|
|
|
|
portable="-portable"
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
local build="$1"
|
|
|
|
local arch="$2"
|
2020-12-03 16:46:18 +01:00
|
|
|
local os="linux"
|
2020-07-30 14:25:21 +02:00
|
|
|
local pdir=".package-build/lite-xl"
|
2021-03-20 16:12:19 +01:00
|
|
|
if [ "$portable" == "-portable" ]; then
|
2020-12-03 16:46:18 +01:00
|
|
|
local bindir="$pdir"
|
|
|
|
local datadir="$pdir/data"
|
2021-08-17 23:58:19 +02:00
|
|
|
local docdir="$pdir/doc"
|
2020-12-03 16:46:18 +01:00
|
|
|
else
|
|
|
|
local bindir="$pdir/bin"
|
|
|
|
local datadir="$pdir/share/lite-xl"
|
2021-08-17 23:58:19 +02:00
|
|
|
local docdir="$pdir/share/doc/lite-xl"
|
2020-12-03 16:46:18 +01:00
|
|
|
fi
|
|
|
|
mkdir -p "$bindir"
|
|
|
|
mkdir -p "$datadir"
|
2021-08-17 23:58:19 +02:00
|
|
|
mkdir -p "$docdir"
|
2020-12-04 12:00:42 +01:00
|
|
|
for module_name in core plugins colors fonts; do
|
2020-12-04 14:20:11 +01:00
|
|
|
copy_directory_from_repo --strip-components=1 "data/$module_name" "$datadir"
|
2020-12-03 16:46:18 +01:00
|
|
|
done
|
2021-08-12 09:20:55 +02:00
|
|
|
# copy the meson generated start.lua file
|
|
|
|
cp "$build/start.lua" "$datadir/core"
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2021-06-24 14:49:18 +02:00
|
|
|
cp "$build/src/lite-xl" "$bindir"
|
2021-08-17 23:58:19 +02:00
|
|
|
cp "licenses/licenses.md" "$docdir"
|
2021-06-24 14:49:18 +02:00
|
|
|
strip "$bindir/lite-xl"
|
2021-03-20 16:12:19 +01:00
|
|
|
if [ -z "$portable" ]; then
|
2021-08-17 23:58:19 +02:00
|
|
|
mkdir -p "$pdir/share/applications" "$pdir/share/icons/hicolor/scalable/apps" "$pdir/share/metainfo"
|
|
|
|
cp "resources/linux/org.lite-xl.lite-xl.desktop" "$pdir/share/applications"
|
|
|
|
cp "resources/linux/org.lite-xl.lite-xl.appdata.xml" "$pdir/share/metainfo"
|
2021-06-24 14:49:18 +02:00
|
|
|
cp "resources/icons/lite-xl.svg" "$pdir/share/icons/hicolor/scalable/apps/lite-xl.svg"
|
2021-03-20 16:12:19 +01:00
|
|
|
fi
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2021-02-24 17:39:12 +01:00
|
|
|
local package_name="lite-xl-$os-$arch$portable.tar.gz"
|
2020-07-30 14:25:21 +02:00
|
|
|
tar czf "$package_name" "lite-xl"
|
2020-06-30 16:16:28 +02:00
|
|
|
mv "$package_name" ..
|
|
|
|
popd
|
|
|
|
rm -fr ".package-build"
|
|
|
|
echo "created package $package_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
lite_build_package () {
|
|
|
|
if [[ "$OSTYPE" == msys || "$OSTYPE" == win32 ]]; then
|
|
|
|
lite_build_package_windows "$@"
|
|
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
2021-04-23 16:05:57 +02:00
|
|
|
lite_build_package_macos "$@"
|
2020-06-30 16:16:28 +02:00
|
|
|
elif [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* ]]; then
|
|
|
|
lite_build_package_linux "$@"
|
|
|
|
else
|
|
|
|
echo "Unknown OS type \"$OSTYPE\""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-11 15:14:57 +01:00
|
|
|
lite_copy_third_party_modules () {
|
|
|
|
local build="$1"
|
|
|
|
curl --insecure -L "https://github.com/rxi/lite-colors/archive/master.zip" -o "$build/rxi-lite-colors.zip"
|
|
|
|
mkdir -p "$build/third/data/colors" "$build/third/data/plugins"
|
|
|
|
unzip "$build/rxi-lite-colors.zip" -d "$build"
|
|
|
|
mv "$build/lite-colors-master/colors" "$build/third/data"
|
|
|
|
rm -fr "$build/lite-colors-master"
|
|
|
|
}
|
2021-02-24 17:39:12 +01:00
|
|
|
unset arch
|
2020-12-04 14:20:11 +01:00
|
|
|
while [ ! -z {$1+x} ]; do
|
|
|
|
case $1 in
|
|
|
|
-pgo)
|
|
|
|
pgo=true
|
|
|
|
shift
|
|
|
|
;;
|
2021-02-16 16:31:46 +01:00
|
|
|
-branch=*)
|
|
|
|
use_branch="${1#-branch=}"
|
|
|
|
shift
|
|
|
|
;;
|
2020-12-04 14:20:11 +01:00
|
|
|
*)
|
2021-02-24 17:39:12 +01:00
|
|
|
arch="$1"
|
2020-12-04 14:20:11 +01:00
|
|
|
break
|
|
|
|
esac
|
|
|
|
done
|
2020-12-03 16:46:18 +01:00
|
|
|
|
2021-02-24 17:39:12 +01:00
|
|
|
if [ -z ${arch+set} ]; then
|
|
|
|
echo "usage: $0 [options] <arch>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-30 01:16:14 +02:00
|
|
|
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -ne 0 ]]; then
|
|
|
|
git_available=1;
|
|
|
|
else
|
|
|
|
echo "Use of git prohibited. Either '.git' wasn't found or BUILD_PROHIBIT_GIT was set."
|
|
|
|
git_available=0;
|
|
|
|
fi
|
|
|
|
|
2021-02-16 16:31:46 +01:00
|
|
|
if [ -z ${use_branch+set} ]; then
|
2021-08-30 01:16:14 +02:00
|
|
|
if [[ $git_available -eq 1 ]]; then
|
2021-08-29 07:37:02 +02:00
|
|
|
use_branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
else
|
|
|
|
# it really doesn't matter if git isn't present
|
|
|
|
use_branch="master"
|
|
|
|
fi
|
2021-02-16 16:31:46 +01:00
|
|
|
fi
|
|
|
|
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir=".build-$arch"
|
|
|
|
|
|
|
|
if [ -z ${pgo+set} ]; then
|
2021-02-24 17:39:12 +01:00
|
|
|
lite_build "$build_dir"
|
2020-06-30 16:16:28 +02:00
|
|
|
else
|
2021-02-24 17:39:12 +01:00
|
|
|
lite_build_pgo "$build_dir"
|
2020-06-30 16:16:28 +02:00
|
|
|
fi
|
2020-12-11 15:14:57 +01:00
|
|
|
lite_copy_third_party_modules "$build_dir"
|
2021-02-24 17:39:12 +01:00
|
|
|
lite_build_package "$build_dir" "$arch"
|
2021-04-16 00:51:10 +02:00
|
|
|
if [[ ! ( "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* || "$OSTYPE" == "darwin"* ) ]]; then
|
2021-03-23 08:50:25 +01:00
|
|
|
lite_build_package -portable "$build_dir" "$arch"
|
|
|
|
fi
|