dotfiles/.bin/luakit-env
2024-12-25 14:31:11 +01:00

90 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# fallback to no config
if [ -z "$HOME/.lenv" ]
then
echo "_env=dev" > $HOME/.lenv
echo "_dir=$HOME/src/luakit-dev" >> $HOME/.lenv
fi
# load config
. $HOME/.lenv
_action="$1"
shift
# validation
if [ -z "$_env" ] || [ -z "$_dir" ]
then
echo "Incomplete environment"
exit 1
fi
if [ -z "$_action" ]
then
echo "No action provided"
exit 1
fi
# now we can start...
echo "luakit-$_env: perform $_action $@ (in $_dir)" | xargs
# change into environment
mkdir -p "$_dir"
cd "$_dir"
# perform actions
if [ "$_action" == "test" ]
then
export G_ENABLE_DIAGNOSTIC=1;
luajit tests/run_test.lua $@;
fi
if [ "$_action" == "make" ]
then
gmake clean
gmake options
gmake -j 8 luakit
fi
if [ "$_action" == "remake" ]
then
gmake -j1 luakit
fi
if [ "$_action" == "debug" ]
then
egdb -ex "break luakit.c:main" -ex "run $@" ./luakit
fi
if [ "$_action" == "reset" ]
then
cd /tmp
rm -rf "$_dir"
mkdir -p "$_dir"
git clone git@github.com:luakit/luakit "$_dir"
cd "$_dir"
fi
if [ "$_action" == "pr" ]
then
if [ -n "$1" ]
then
for pr in $@
do gh pr checkout $pr
done
else
gh pr --repo luakit/luakit list $@ | cat
fi
fi
if [ "$_action" == "update-port" ]
then
cd /usr/ports/mystuff/www/luakit
commit="$(basename $(gh browse --repo luakit/luakit -c -n))"
sed -i "s/^COMMIT =.*/COMMIT = $commit/" Makefile
make clean=all
portbump
make makesum
make reinstall
fi