Created
January 15, 2016 01:07
-
-
Save RyanSquared/db5fee015b7a74bf05d2 to your computer and use it in GitHub Desktop.
Compiles MoonScript files using a C preprocessor and optionally outputs in Lua binary.
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
if which mcpp >&-; then | |
CPP="mcpp -P" | |
else | |
CPP="cpp -P" | |
fi | |
has_compiled=false | |
is_binary=false | |
is_forcing=false | |
for arg in $*; do | |
case $arg in | |
-binary) | |
is_binary=true | |
;; | |
-force-compile) | |
is_forcing=true | |
;; | |
esac | |
done | |
for file in $(find . -type f -name "*.moon"); do | |
luafile="${file%.*}.lua" | |
if [ ! -f "$luafile" ] || [ $(stat -c "%Y" "${file}" ) -gt $(stat -c "%Y" "$luafile") ] || $is_forcing; then | |
if ! $has_compiled; then | |
printf "\n" | |
fi | |
if $is_binary; then | |
$CPP $file | moonc -- | luac -o $luafile - | |
echo "Built $file" | |
else | |
$CPP $file | moonc -- > $luafile | |
fi | |
has_compiled=true | |
fi | |
done | |
if $has_compiled; then | |
printf "\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment