用Tiny C Compiler编译Lua

标签: , , , ,

很久以前写过一篇《Windows下用TCC编译Lua源码》,现在Lua已经更新到Lua 5.3.2了,想编译一个玩玩,但是发现之前的脚本是把源文件hard code进去的,对于最新版的没法用,于是改进了一下脚本。

@echo off
setlocal enabledelayedexpansion
:: By Demon
:: https://demon.tw
set tcc=C:\tcc\tcc.exe
2>nul del *.exe *.a
if exist src\luac rmdir /s /q src\luac
for /f "delims=" %%i in (
    'dir /s /b src\*.c'
) do (
    if not "%%~nxi" == "lua.c" (
        if not "%%~nxi" == "luac.c" set src=!src! "%%i"
    )
)
set tcc=%tcc% -Iinclude -Isrc -w
if exist src\lua set lua=lua\
%tcc% -o lua.exe %src% src\%lua%lua.c
lua.exe

为了兼容性没有编译luac.exe,兼容Lua 4.0以上版本源码的编译。

赞赏

微信赞赏支付宝赞赏

随机文章:

  1. Windows 10无法WOL网络唤醒的解决方法
  2. VBS打开选择文件对话框(Windows 7)
  3. 远程桌面连接用户名密码错误的解决方法
  4. 48行计算24点C语言代码
  5. ActivePython PyPM error: (OperationalError) unable to open database file None None

一条评论 发表在“用Tiny C Compiler编译Lua”上

  1. Mike说道:

    借用博主的代码,改用pcc编译器编译成功了,在此贴一下:

    @rem =================================
    @echo off
    setlocal enabledelayedexpansion
    :: By Demon
    :: http://demon.tw
    set pcc=”C:\Program Files (x86)\pcc\bin\pcc.exe”
    cls
    2>nul del *.exe *.a *.o
    if exist src\luac rmdir /s /q src\luac
    for /f “delims=” %%i in (
    ‘dir /s /b src\*.c’
    ) do (
    if not “%%~nxi” == “lua.c” (
    if not “%%~nxi” == “luac.c” set src=!src! “%%i”
    )
    )
    set pcc=%pcc% -Iinclude -Isrc -Wall -Wextra ^
    -DLUA_COMPAT_5_3 -DLUA_USE_C89
    if exist src\lua set lua=lua\
    %pcc% -o lua.exe %src% src\%lua%lua.c
    .\lua.exe -v
    @rem =================================

Mike 留下回复