rt-thread-official/components/external/lua
xiongyihui3@gmail.com 74bf69110e add support of arm standard c library, support using armcc to compile lua
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2429 bbd45198-f89e-11dd-88c7-29a3b14d5316
2012-11-22 03:39:22 +00:00
..
applications add lua support for rt-thead 2012-11-10 07:32:39 +00:00
exlibs move larduinolib.c into ART's repo, add lua external library example 2012-11-13 07:43:55 +00:00
lua add support of arm standard c library, support using armcc to compile lua 2012-11-22 03:39:22 +00:00
test add lua support for rt-thead 2012-11-10 07:32:39 +00:00
ChangeLog add lua support for rt-thead 2012-11-10 07:32:39 +00:00
README.TXT add support of arm standard c library, support using armcc to compile lua 2012-11-22 03:39:22 +00:00
SConscript add lua support for rt-thead 2012-11-10 07:32:39 +00:00

README.TXT

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Lua on RT-Thread

## 简介
RT-Thread中的Lua修改自[eLua](http://www.eluaproject.net/)的Lua-5.1.4版本。
采用gcc工具链时Lua依赖于newlib库采用keil时Lua依赖于arm的标准c库。
启动lua的RAM占用情况
    - 标准的lua        17.1904296875 KB
    - 优化的lua        5.01953125 KB
    注数据来自print(collectgarbage('count'))的输出
优化是指采用一个lua patch --- [Lua Tiny RAM](http://www.eluaproject.net/doc/v0.8/en_arch_ltr.html)

## 使用
在RT-Thread的finsh中调用lua()获得一个lua解释器。
在lua解释器中
    - 可以调用lua标准库中的函数print('hello, lua on rt-thread')
    - 可以执行脚本文件dofile('/hello.lua')
    - 可以定义新的函数function sinc(x) return math.sin(x)/x end
    - etc.

## 配置
    1.通过在rtconfig.h中定义RT_USING_LUA加入lua组件
    2.可以定义RT_LUA_OPTRAM减少RAM占用
    3.可以定义RT_LUS_USE_EXLIBS而添加外部库如arduino的常用函数封装为一个arduino库
    3.更多的配置项可以在luaconf.h中找到

## 开发相关
    - 采用gcc工具链时依赖于newlib需在rtconfig.h中定义RT_USING_NEWLIB  
      采用keil工具链时依赖于arm的标准c库需在rtconfig.h中定义RT_USING_ARM_LIBC
    - 开启编译器对C99的支持如MDK中在C/C++选项的Misc Controls输入框中添加--c99
    - 使用gcc时需要在链接脚本中定义_stext和_etext.ordata*放在两者之间。用于判断数据是read-only和writable  
      使用keil时需要在分散加载文件中把rodata放在ER_IROM1区
    - 添加新的模块参见exlibs/lexamplelib.c
    
## 目录说明
    - lua从eLua获得Lua-5.1.4版本代码
    - exlibsexternal libraries外部库代码如example库
    - applicationsLua应用代码如finsh中lua()
    - test测试代码