用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. 用VBS判断操作系统是32位(x86)还是64位(x64)
  2. 用VBS修改Windows用户密码
  3. 为OpenWrt编译Shadowsocks-libev
  4. VBS修改文件和文件夹的NTFS 权限
  5. VBS正则表达式对象的MultiLine属性

一条评论 发表在“用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 =================================

留下回复