aboutsummaryrefslogtreecommitdiff
path: root/compile_lib.sh
blob: 6e4e78a1e94e30bd14469d430a6d1fc1ea5ab862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
# This file is a script that converts the .nom files in lib/ into slightly more optimized
# precompiled versions that are only lua> ".." and =lua ".." bits which are faster to load.
FLUSH=false
while getopts ":f" opt; do
  case $opt in
    f)
      FLUSH=true
      echo "flushing..."
      ;;
  esac
done
if [ "$FLUSH" = true ] ; then
    for file in $(find lib/ -name "*.lua") ; do
        rm $file
    done
fi

for file in $(cat lib/core.nom | lua -e "for filename in io.read('*a'):gmatch('require \"([^\"]*)\"') do print(filename) end") ; do
    compilefile="${file/\.nom/.lua}"
    if [ ! -e "$compilefile" ] || [ "$file" -nt "$compilefile" ] ; then
        echo "Compiling $file into $compilefile"
        ./nomsu.moon -c $file
    fi
done