This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bf00ee
commit bcc55c3
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters