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"
|
2020-12-04 14:20:11 +01:00
|
|
|
git archive master "$dirname" --format=tar | tar xf - -C "$destdir" "${tar_options[@]}"
|
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
|
|
|
|
git ls-files --error-unmatch "$build" &> /dev/null
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
echo "invalid path, \"$build\" is under revision control"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ordinary release build
|
|
|
|
lite_build () {
|
2020-12-03 16:46:18 +01:00
|
|
|
local meson_options=("-Dportable=$1")
|
|
|
|
local build="$2"
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir_is_usable "$build" || exit 1
|
|
|
|
rm -fr "$build"
|
2020-12-03 16:46:18 +01:00
|
|
|
meson setup --buildtype=release "${meson_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 () {
|
2020-12-03 16:46:18 +01:00
|
|
|
local meson_options=("-Dportable=$1")
|
|
|
|
local build="$2"
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir_is_usable "$build" || exit 1
|
|
|
|
rm -fr "$build"
|
2020-12-03 16:46:18 +01:00
|
|
|
meson setup --buildtype=release "${meson_options[@]}" -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"
|
2020-06-30 16:16:28 +02:00
|
|
|
"$build/src/lite"
|
|
|
|
meson configure -Db_pgo=use "$build"
|
|
|
|
ninja -C "$build" || exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
lite_build_package_windows () {
|
2020-12-03 16:46:18 +01:00
|
|
|
local portable="$1"
|
|
|
|
local build="$2"
|
|
|
|
local version="$3"
|
|
|
|
local arch="$4"
|
|
|
|
local os="win"
|
2020-07-30 14:25:21 +02:00
|
|
|
local pdir=".package-build/lite-xl"
|
2020-12-03 16:46:18 +01:00
|
|
|
if [ $portable == "true" ]; then
|
|
|
|
local bindir="$pdir"
|
|
|
|
local datadir="$pdir/data"
|
|
|
|
else
|
2020-12-11 15:14:13 +01:00
|
|
|
echo "WARNING: using non portable option on unix-like system"
|
2020-12-03 16:46:18 +01:00
|
|
|
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
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2020-12-03 16:46:18 +01:00
|
|
|
cp "$build/src/lite.exe" "$bindir"
|
|
|
|
strip --strip-all "$bindir/lite.exe"
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2020-11-23 15:33:34 +01:00
|
|
|
local package_name="lite-xl-$os-$arch.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"
|
|
|
|
}
|
|
|
|
|
|
|
|
lite_build_package_macosx () {
|
2020-12-03 16:46:18 +01:00
|
|
|
local portable="$1"
|
|
|
|
local build="$2"
|
|
|
|
local version="$3"
|
|
|
|
local arch="$4"
|
|
|
|
local os="macosx"
|
2020-06-30 16:16:28 +02:00
|
|
|
local pdir=".package-build/lite-xl.app/Contents/MacOS"
|
2020-12-03 16:46:18 +01:00
|
|
|
if [ $portable == "true" ]; then
|
|
|
|
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
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2020-12-03 16:46:18 +01:00
|
|
|
cp "$build/src/lite" "$bindir"
|
|
|
|
strip "$bindir/lite"
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2020-11-23 15:33:34 +01: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 () {
|
2020-12-03 16:46:18 +01:00
|
|
|
local portable="$1"
|
|
|
|
local build="$2"
|
|
|
|
local version="$3"
|
|
|
|
local arch="$4"
|
|
|
|
local os="linux"
|
2020-07-30 14:25:21 +02:00
|
|
|
local pdir=".package-build/lite-xl"
|
2020-12-03 16:46:18 +01:00
|
|
|
if [ $portable == "true" ]; then
|
2020-12-11 15:14:13 +01:00
|
|
|
echo "WARNING: using portable option on unix-like system"
|
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
|
2020-12-11 15:14:57 +01:00
|
|
|
for module_name in plugins colors; do
|
|
|
|
cp -r "$build/third/data/$module_name" "$datadir"
|
|
|
|
done
|
2020-12-03 16:46:18 +01:00
|
|
|
cp "$build/src/lite" "$bindir"
|
|
|
|
strip "$bindir/lite"
|
2020-06-30 16:16:28 +02:00
|
|
|
pushd ".package-build"
|
2020-11-23 15:33:34 +01:00
|
|
|
local package_name="lite-xl-$os-$arch.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
|
|
|
|
lite_build_package_macosx "$@"
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2020-06-30 16:16:28 +02:00
|
|
|
if [[ -z "$1" || -z "$2" ]]; then
|
2020-12-03 16:46:18 +01:00
|
|
|
echo "usage: $0 [options] <version> <arch>"
|
2020-06-30 16:16:28 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-04 14:20:11 +01:00
|
|
|
portable=false
|
|
|
|
while [ ! -z {$1+x} ]; do
|
|
|
|
case $1 in
|
|
|
|
-pgo)
|
|
|
|
pgo=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-portable)
|
|
|
|
portable=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
version="$1"
|
|
|
|
arch="$2"
|
|
|
|
break
|
|
|
|
esac
|
|
|
|
done
|
2020-12-03 16:46:18 +01:00
|
|
|
|
2020-06-30 16:16:28 +02:00
|
|
|
build_dir=".build-$arch"
|
|
|
|
|
|
|
|
if [ -z ${pgo+set} ]; then
|
2020-12-03 16:46:18 +01:00
|
|
|
lite_build "$portable" "$build_dir"
|
2020-06-30 16:16:28 +02:00
|
|
|
else
|
2020-12-03 16:46:18 +01:00
|
|
|
lite_build_pgo "$portable" "$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"
|
2020-12-03 16:46:18 +01:00
|
|
|
lite_build_package "$portable" "$build_dir" "$version" "$arch"
|
2020-06-30 16:16:28 +02:00
|
|
|
|