2020-12-03 23:01:01 +01:00
|
|
|
#!/bin/bash
|
2020-12-26 11:37:43 +01:00
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
2021-03-06 15:39:30 +01:00
|
|
|
# accept argument in the form
|
|
|
|
github_raw_content () {
|
|
|
|
echo "https://raw.githubusercontent.com/$1"
|
|
|
|
}
|
|
|
|
|
2020-12-26 11:37:43 +01:00
|
|
|
option_portable=off
|
|
|
|
option_copy=on
|
|
|
|
pargs=()
|
2021-03-06 15:39:30 +01:00
|
|
|
plugins=()
|
2020-12-26 11:37:43 +01:00
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
-portable)
|
|
|
|
option_portable=on
|
|
|
|
;;
|
|
|
|
-keep)
|
|
|
|
option_copy=off
|
|
|
|
;;
|
2021-03-06 15:39:30 +01:00
|
|
|
-plugin=*)
|
|
|
|
# should be like -plugin=franko/lite-plugins/master/plugins/autowrap.lua
|
2021-03-06 23:48:18 +01:00
|
|
|
plugins+=("${1#-plugin=}")
|
2021-03-06 15:39:30 +01:00
|
|
|
;;
|
2020-12-26 11:37:43 +01:00
|
|
|
-global)
|
|
|
|
option_global=on
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
echo "error: unknown option \"$1\""
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
pargs+=("$1")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "${#pargs[@]}" -lt 1 ]; then
|
|
|
|
echo "usage: $0 [options] <build-dir>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "mingw"* ]]; then
|
|
|
|
run_windows=yes
|
|
|
|
fi
|
|
|
|
|
2020-12-03 23:01:01 +01:00
|
|
|
rundir=".run"
|
2021-08-19 23:30:44 +02:00
|
|
|
if [ "$option_portable" == on ]; then
|
2020-12-03 23:01:01 +01:00
|
|
|
bindir="$rundir"
|
|
|
|
datadir="$rundir/data"
|
|
|
|
else
|
|
|
|
bindir="$rundir/bin"
|
|
|
|
datadir="$rundir/share/lite-xl"
|
|
|
|
fi
|
|
|
|
|
2020-12-08 18:49:58 +01:00
|
|
|
userdir="$(realpath "$rundir")"
|
2020-12-26 11:37:43 +01:00
|
|
|
builddir="${pargs[0]}"
|
2020-12-07 17:42:50 +01:00
|
|
|
|
2020-12-26 15:25:09 +01:00
|
|
|
build_lite () {
|
|
|
|
echo "running ninja"
|
|
|
|
ninja -C "$builddir"
|
|
|
|
}
|
|
|
|
|
2020-12-26 11:37:43 +01:00
|
|
|
copy_lite_build () {
|
|
|
|
echo "copying lite executable and data"
|
|
|
|
rm -fr "$rundir"
|
|
|
|
mkdir -p "$bindir" "$datadir"
|
|
|
|
if [ ! -z ${run_windows+x} ]; then
|
2021-07-11 18:36:49 +02:00
|
|
|
cp "$builddir/src/lite-xl.exe" "$bindir"
|
2020-12-26 11:37:43 +01:00
|
|
|
else
|
2021-07-11 18:36:49 +02:00
|
|
|
cp "$builddir/src/lite-xl" "$bindir"
|
2020-12-26 11:37:43 +01:00
|
|
|
fi
|
2021-08-10 11:12:47 +02:00
|
|
|
mkdir -p "$datadir/core"
|
2020-12-26 11:37:43 +01:00
|
|
|
for module_name in core plugins colors fonts; do
|
|
|
|
cp -r "data/$module_name" "$datadir"
|
|
|
|
done
|
2021-08-12 09:03:57 +02:00
|
|
|
# The start.lua file is generated by meson in $builddir but
|
|
|
|
# there is already a start.lua file in data/core so the command below
|
|
|
|
# should be executed after we copy the data/core directory.
|
|
|
|
cp "$builddir/start.lua" "$datadir/core"
|
2020-12-26 11:37:43 +01:00
|
|
|
}
|
2020-12-03 23:01:01 +01:00
|
|
|
|
2020-12-26 11:37:43 +01:00
|
|
|
run_lite () {
|
|
|
|
if [ ! -z ${option_global+x} ]; then
|
2021-07-11 18:36:49 +02:00
|
|
|
echo "running \"lite-xl ${pargs[@]:1}\""
|
|
|
|
exec "$bindir/lite-xl" "${pargs[@]:1}"
|
2020-12-26 11:37:43 +01:00
|
|
|
else
|
2021-07-11 18:36:49 +02:00
|
|
|
echo "running \"lite-xl ${pargs[@]:1}\" with local HOME"
|
2020-12-26 11:37:43 +01:00
|
|
|
if [ ! -z ${run_windows+x} ]; then
|
2021-07-11 18:36:49 +02:00
|
|
|
USERPROFILE="$userdir" exec "$bindir/lite-xl" "${pargs[@]:1}"
|
2020-12-26 11:37:43 +01:00
|
|
|
else
|
2021-07-11 18:36:49 +02:00
|
|
|
HOME="$userdir" exec "$bindir/lite-xl" "${pargs[@]:1}"
|
2020-12-26 11:37:43 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-07 09:49:08 +01:00
|
|
|
github_raw_content () {
|
|
|
|
echo "https://raw.githubusercontent.com/$1"
|
|
|
|
}
|
|
|
|
|
2021-03-06 15:39:30 +01:00
|
|
|
fetch_plugins () {
|
|
|
|
for name in "$@"; do
|
2021-03-06 23:48:18 +01:00
|
|
|
local url="$(github_raw_content "$name")"
|
|
|
|
local modname="${url##*/}"
|
|
|
|
if [ "$modname" == init.lua ]; then
|
|
|
|
local m1="${name#*/}"
|
|
|
|
modname="${m1%%/*}.lua"
|
|
|
|
fi
|
|
|
|
echo "installed $name as $modname from $url"
|
|
|
|
curl --insecure -L "$url" -o "$datadir/plugins/${modname}"
|
2021-03-06 15:39:30 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-12-26 11:37:43 +01:00
|
|
|
if [ $option_copy == on ]; then
|
2020-12-26 15:25:09 +01:00
|
|
|
build_lite
|
2020-12-26 11:37:43 +01:00
|
|
|
copy_lite_build
|
2020-12-03 23:01:01 +01:00
|
|
|
fi
|
2021-03-06 15:39:30 +01:00
|
|
|
fetch_plugins "${plugins[@]}"
|
2020-12-26 11:37:43 +01:00
|
|
|
run_lite
|