bat批处理luajit编译lua源代码

来源:互联网 发布:linux图形化界面命令 编辑:程序博客网 时间:2024/05/16 00:48

今天看到bat,手痒,看了几篇教程,想动手写写。

这是一个 luajit 编译某个目录下所有.lua文件(支持嵌套目录)。

读前须知:

1.PC平台;假设你已经安装好了luajit;

2.若你需要一个打包程序,这个bat可能不是你需要的。你应该写个或者搜一搜python版本的(更具跨平台性质)。

3.写他存粹是练手。

4.使用:luajitDir [input dir] [output dir]或 luajitDir,然后拖目录至控制台,并在当前目录下创建[input].jit目录

@echo off
if not "%1"=="" (set input=%1&goto LendInput)
:LgetInput
set /p input=Drag input Dir to compile*
if not exist "%input%" goto LgetInput
:LendInput
if not "%2"=="" (set output=%2) else (set output=%input%.jit)
pushd %cd%
cd /d "%input%">nul 2>nul || (echo %input% Dir is BAD! & goto Lexit)
popd
xcopy "%input%" "%output%" /s /y /i>nul 2>nul || (echo %output% Dir is BAD! & goto Lexit)
<pre name="code" class="plain" style="font-size: 18px;">pushd %cd%
cd /d "%output%">nul 2>nul || (echo %output% Dir is BAD! & goto Lexit)
popd

set /a num=0
for /f "delims=" %%i in ('dir /b /a-d /s "%output%"')^
do (if %%~xi==.lua set /a num += 1 & luajit -b %%~fsi)
echo Compile %num% files
*Lexit
if "%1"=="" pause


0 0
原创粉丝点击