Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Prep for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
robthomson committed Jul 17, 2024
1 parent 7bf00ee commit bcc55c3
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
File renamed without changes.
41 changes: 41 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

#clean old compiled tree
rm -rfv ../scripts/*

if ! [ -d "../scripts" ]; then
mkdir ../scripts
fi

#copy tree to scripts
rsync -rvva ../src/* ../scripts/

#adjust any included lua files
find ../scripts/ -type f -name '*.lua' -exec sed -i 's/.lua/.luac/g' {} \;

#compile the scripts
files=$(find ../scripts/ -type f -name '*.lua')

for x in $files ; do

filename=$(basename $x)
filename_compiled="${filename}c"
x_compiled="${x}c"

echo $filename

if [ -d "luac.out" ] ; then
rm luac.out
fi

echo $x_compiled
luac5.4 $x
if [ $? -ne 0 ]; then
exit 1
fi

# move to correct folder
rm -f $x
mv luac.out $x_compiled

done
89 changes: 89 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/sh

{ # ensure the whole script is loaded

set -eu

print_bold()
{
tput bold; echo "${1}"; tput sgr0
}

download_file()
{
if 'curl' -V >/dev/null 2>&1
then 'curl' -fsSL "${1}"
else 'wget' -qO- "${1}"
fi
}

# install_file baseurl file
install_file()
{
if [ -e "${2}" ]
then
cp "${2}" "${LUAVER_DIR}/${2}"
else
download_file "${1}/${2}" >"${LUAVER_DIR}/${2}"
fi
}

## Option parsing
LUAVER_DIR=~/.luaver
REVISION=v1.1.0
SHELL_TYPE="$(basename /"${SHELL}")"

while getopts hr:s: OPT
do
case "$OPT" in
r ) REVISION="${OPTARG}" ;;
h )
echo "Usage: ${0} [-r REVISION]"
echo " -r luaver reversion [${REVISION}]"
exit 0
;;
esac
done

print_bold "Installing luaver..."

## Download script
URL="https://raw.githubusercontent.com/DhavalKapil/luaver/${REVISION}"

mkdir -p "${LUAVER_DIR}/completions"

install_file "${URL}" "luaver"
chmod a+x "${LUAVER_DIR}/luaver"

install_file "${URL}" "completions/luaver.bash" || rm "${LUAVER_DIR}/completions/luaver.bash"

## Set up profile
APPEND_COMMON="[ -s ~/.luaver/luaver ] && . ~/.luaver/luaver"

APPEND_BASH="${APPEND_COMMON}
[ -s ~/.luaver/completions/luaver.bash ] && . ~/.luaver/completions/luaver.bash"

APPEND_ZSH="${APPEND_COMMON}"

case "${SHELL_TYPE}" in
bash ) APPEND="${APPEND_BASH}" ;;
zsh ) APPEND="${APPEND_ZSH}" ;;
* ) APPEND="${APPEND_COMMON}"
esac

if [ -f ~/."${SHELL_TYPE}"rc ]
then
'grep' -qF "${APPEND}" ~/."${SHELL_TYPE}"rc || printf "\n%s\n\n" "${APPEND}" >>~/."${SHELL_TYPE}"rc

print_bold "Appending the following lines at the end of ~/.${SHELL_TYPE}rc if lines not exists:"
printf "\n%s\n\n" "${APPEND}"
print_bold "To use luaver, you must restart the shell or execute '. ~/.${SHELL_TYPE}rc'"
else
print_bold "Add the following lines at the end of your profile (~/.bashrc, ~/.zshrc, etc):"
printf "\n%s\n\n" "${APPEND}"
print_bold "To use luaver, you must restart the shell or execute the above lines"
fi

print_bold "luaver was successfully installed!"

}
File renamed without changes.
2 changes: 2 additions & 0 deletions scripts/rf2ethos/api_version.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--[[
local msp_API_VERSION = 1
local config.apiVersionReceived = false
local lastRunTS = 0
Expand Down Expand Up @@ -36,3 +37,4 @@ local function getApiVersion()
end
return {f = getApiVersion, t = "Waiting for API version"}
]]--

0 comments on commit bcc55c3

Please sign in to comment.