1 Star 2 Fork 4

logbug/lua2c

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clua 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/sh
#
# Shell script wrapper to convert Lua to C and optionally
# compile and run it.
#
# option -c causes compilation only (no run)
# option -C causes C source generation only (no compile or run)
pushd "`dirname \"$0\"`" > /dev/null
export CWD="$PWD"
popd > /dev/null
# You may need to change these variables:
LUA=lua
CC=gcc
CFLAGS="-O3 -fomit-frame-pointer -DNDEBUG -Wall -Ilua/src"
#CFLAGS="-O2 -DNDEBUG -Wall -Ilua/src"
#CFLAGS=-g
LFLAGS="-Llua/src -llua"
LUA2C="${LUA} $CWD/lua2c.lua"
#LUA2C="./lua2c"
COMPILEONLY=
if [ "$1" = "-c" ]
then
COMPILEONLY=1
shift
elif [ "$1" = "-C" ]
then
COMPILEONLY=2
shift
fi
if [ "$1" = "" ]
then
echo "usage: clua [options] [filename.lua] ..."
echo " options:"
echo " -c compile only (no run)"
echo " -C generate C source only (no compile or run)"
exit 1
fi
LUAFILE=$1
FILENAME=${LUAFILE%.*}
CFILE=${FILENAME}.c
LUA_PATH=$CWD/lib/?.lua ${LUA2C} ${LUAFILE} > ${CFILE} || exit 1
if [ "$COMPILEONLY" = "2" ]
then
exit 0
fi
${CC} ${CFLAGS} ${CFILE} -o ${FILENAME} ${LFLAGS} || exit 1
if [ "$COMPILEONLY" = "1" ]
then
exit 0
fi
shift
./${FILENAME} $@
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/logbug/lua2c.git
git@gitee.com:logbug/lua2c.git
logbug
lua2c
lua2c
master

搜索帮助