Improve build-package script to create portable and unix-like packages

This commit is contained in:
Francesco Abbate 2021-02-24 17:39:12 +01:00
parent 351a772466
commit ff5052be9a
3 changed files with 57 additions and 50 deletions

View File

@ -58,16 +58,17 @@ sudo apt install meson
# or pip3 install --user meson
```
To build Lite XL with Meson use the commands:
To build Lite XL with Meson the commands below can be used:
```sh
meson setup build
meson compile -C build
meson install -C build
```
When performing the "meson setup" command you may enable the "portable" option.
When performing the "meson setup" command you may enable the "portable" option to choose the
kind of install.
If this latter is enabled Lite XL is built to use a "data" and a "user" directory
If the portable option latter is enabled Lite XL is built to use a "data" and a "user" directory
from the same directory of the executable.
If "portable" is not enabled (this is the default) Lite XL will use unix-like
directory locations.
@ -78,19 +79,23 @@ the location of the executable.
The `$HOME` is determined from the corresponding environment variable.
As a special case on Windows the variable `$USERPROFILE` will be used instead.
If you want to install Lite XL on Windows or Mac OS X we suggest to use the script `build-packages.sh`:
If you compile lite-xl yourself it is recommended to use the script `build-packages.sh`:
```sh
bash build-packages.sh <version> <arch>
# In alternative the -portable option can be used like below:
# bash build-packages.sh -portable <version> <arch>
bash build-packages.sh <arch>
```
It will run meson and create a Zip file that can be easily installed or uninstalled.
It will run meson and create two zip files, one for the portable version and
one for the unix-like version. Lite XL can be easily installed by unpacking one
of the zip archive in a directory of your choice.
Please note the, while compiling Lite XL on Mac OS X should work Mac OS X
is not currently supported.
Please note that no directory is not hard-coded in the exectuable so that the
package can be extracted and used in any directory.
Note also that the unix-like package can work on windows as well.
Please note that while compiling Lite XL on Mac OS X should work Mac OS X is not
officially supported.
## Contributing
Any additional functionality that can be added through a plugin should be done

View File

@ -29,21 +29,19 @@ build_dir_is_usable () {
# Ordinary release build
lite_build () {
local meson_options=("-Dportable=$1")
local build="$2"
local build="$1"
build_dir_is_usable "$build" || exit 1
rm -fr "$build"
meson setup --buildtype=release "${meson_options[@]}" "$build" || exit 1
meson setup --buildtype=release "$build" || exit 1
ninja -C "$build" || exit 1
}
# Build using Profile Guided Optimizations (PGO)
lite_build_pgo () {
local meson_options=("-Dportable=$1")
local build="$2"
local build="$1"
build_dir_is_usable "$build" || exit 1
rm -fr "$build"
meson setup --buildtype=release "${meson_options[@]}" -Db_pgo=generate "$build" || exit 1
meson setup --buildtype=release -Db_pgo=generate "$build" || exit 1
ninja -C "$build" || exit 1
copy_directory_from_repo data "$build/src"
"$build/src/lite"
@ -52,17 +50,19 @@ lite_build_pgo () {
}
lite_build_package_windows () {
local portable="$1"
local build="$2"
local version="$3"
local arch="$4"
local portable=""
if [ "$1" == "-portable" ]; then
portable="-portable"
shift
fi
local build="$1"
local arch="$2"
local os="win"
local pdir=".package-build/lite-xl"
if [ $portable == "true" ]; then
if [ "$portable" == "-portable" ]; then
local bindir="$pdir"
local datadir="$pdir/data"
else
echo "WARNING: using non portable option on unix-like system"
local bindir="$pdir/bin"
local datadir="$pdir/share/lite-xl"
fi
@ -77,7 +77,7 @@ lite_build_package_windows () {
cp "$build/src/lite.exe" "$bindir"
strip --strip-all "$bindir/lite.exe"
pushd ".package-build"
local package_name="lite-xl-$os-$arch.zip"
local package_name="lite-xl-$os-$arch$portable.zip"
zip "$package_name" -r "lite-xl"
mv "$package_name" ..
popd
@ -86,10 +86,13 @@ lite_build_package_windows () {
}
lite_build_package_macosx () {
local portable="$1"
local build="$2"
local version="$3"
local arch="$4"
local portable=""
if [ "$1" == "-portable" ]; then
portable="-portable"
shift
fi
local build="$1"
local arch="$2"
local os="macosx"
local pdir=".package-build/lite-xl.app/Contents/MacOS"
if [ $portable == "true" ]; then
@ -110,7 +113,7 @@ lite_build_package_macosx () {
cp "$build/src/lite" "$bindir"
strip "$bindir/lite"
pushd ".package-build"
local package_name="lite-xl-$os-$arch.zip"
local package_name="lite-xl-$os-$arch$portable.zip"
zip "$package_name" -r "lite-xl.app"
mv "$package_name" ..
popd
@ -119,10 +122,13 @@ lite_build_package_macosx () {
}
lite_build_package_linux () {
local portable="$1"
local build="$2"
local version="$3"
local arch="$4"
local portable=""
if [ "$1" == "-portable" ]; then
portable="-portable"
shift
fi
local build="$1"
local arch="$2"
local os="linux"
local pdir=".package-build/lite-xl"
if [ $portable == "true" ]; then
@ -144,7 +150,7 @@ lite_build_package_linux () {
cp "$build/src/lite" "$bindir"
strip "$bindir/lite"
pushd ".package-build"
local package_name="lite-xl-$os-$arch.tar.gz"
local package_name="lite-xl-$os-$arch$portable.tar.gz"
tar czf "$package_name" "lite-xl"
mv "$package_name" ..
popd
@ -174,33 +180,28 @@ lite_copy_third_party_modules () {
rm -fr "$build/lite-colors-master"
}
if [[ -z "$1" || -z "$2" ]]; then
echo "usage: $0 [options] <version> <arch>"
exit 1
fi
portable=false
unset arch
while [ ! -z {$1+x} ]; do
case $1 in
-pgo)
pgo=true
shift
;;
-portable)
portable=true
shift
;;
-branch=*)
use_branch="${1#-branch=}"
shift
;;
*)
version="$1"
arch="$2"
arch="$1"
break
esac
done
if [ -z ${arch+set} ]; then
echo "usage: $0 [options] <arch>"
exit 1
fi
if [ -z ${use_branch+set} ]; then
use_branch="$(git rev-parse --abbrev-ref HEAD)"
fi
@ -208,10 +209,11 @@ fi
build_dir=".build-$arch"
if [ -z ${pgo+set} ]; then
lite_build "$portable" "$build_dir"
lite_build "$build_dir"
else
lite_build_pgo "$portable" "$build_dir"
lite_build_pgo "$build_dir"
fi
lite_copy_third_party_modules "$build_dir"
lite_build_package "$portable" "$build_dir" "$version" "$arch"
lite_build_package "$build_dir" "$arch"
lite_build_package -portable "$build_dir" "$arch"

View File

@ -1,2 +1,2 @@
option('portable', type : 'boolean', value : false, description: 'Create a portable build')
option('portable', type : 'boolean', value : false, description: 'Portable install')