2021-04-08 15:40:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
option_copy=on
|
|
|
|
pargs=()
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
-keep)
|
|
|
|
option_copy=off
|
|
|
|
;;
|
|
|
|
-global)
|
|
|
|
option_global=on
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
echo "error: unknown option \"$1\""
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
pargs+=("$1")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2021-04-12 11:08:47 +02:00
|
|
|
if [ "${#pargs[@]}" -lt 3 ]; then
|
|
|
|
echo "usage: $0 [options] <plugin-dir> <plugin-name> <build-dir>"
|
2021-04-08 15:40:44 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-12 11:08:47 +02:00
|
|
|
plugin_dir="${pargs[0]}"
|
|
|
|
plugin="${pargs[1]}"
|
|
|
|
|
2021-04-08 15:40:44 +02:00
|
|
|
if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "mingw"* ]]; then
|
|
|
|
run_windows=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
rundir=".run"
|
|
|
|
bindir="$rundir/bin"
|
|
|
|
datadir="$rundir/share/lite-xl"
|
|
|
|
|
|
|
|
userdir="$(realpath "$rundir")"
|
2021-04-12 11:08:47 +02:00
|
|
|
builddir="${pargs[2]}"
|
2021-04-08 15:40:44 +02:00
|
|
|
|
|
|
|
build_lite () {
|
|
|
|
echo "running ninja"
|
|
|
|
ninja -C "$builddir"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_lite_build () {
|
|
|
|
echo "copying lite executable and data"
|
|
|
|
rm -fr "$rundir"
|
|
|
|
mkdir -p "$bindir" "$datadir"
|
|
|
|
if [ ! -z ${run_windows+x} ]; then
|
|
|
|
cp "$builddir/src/lite.exe" "$bindir"
|
|
|
|
else
|
|
|
|
cp "$builddir/src/lite" "$bindir"
|
|
|
|
fi
|
|
|
|
for module_name in core plugins colors fonts; do
|
|
|
|
cp -r "data/$module_name" "$datadir"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
run_lite () {
|
|
|
|
if [ ! -z ${option_global+x} ]; then
|
2021-04-12 11:08:47 +02:00
|
|
|
echo "running \"lite ${pargs[@]:3}\""
|
|
|
|
exec "$bindir/lite" "${pargs[@]:3}"
|
2021-04-08 15:40:44 +02:00
|
|
|
else
|
2021-04-12 11:08:47 +02:00
|
|
|
echo "running \"lite ${pargs[@]:3}\" with local HOME"
|
2021-04-08 15:40:44 +02:00
|
|
|
if [ ! -z ${run_windows+x} ]; then
|
2021-04-12 11:08:47 +02:00
|
|
|
USERPROFILE="$userdir" exec "$bindir/lite" "${pargs[@]:3}"
|
2021-04-08 15:40:44 +02:00
|
|
|
else
|
2021-04-12 11:08:47 +02:00
|
|
|
HOME="$userdir" exec "$bindir/lite" "${pargs[@]:3}"
|
2021-04-08 15:40:44 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_plugin () {
|
|
|
|
echo "-- lite-xl 1.16" | cat - "$plugin_dir/$plugin.lua" > "$datadir/plugins/$plugin.lua"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $option_copy == on ]; then
|
|
|
|
build_lite
|
|
|
|
copy_lite_build
|
|
|
|
fi
|
|
|
|
copy_plugin
|
|
|
|
run_lite
|