7 如需新增或更新, 把.lua文件放入corelib目录, 在当前目录下执行:
8 luatos_32bit.exe update_inline_libs.lua
10 相关exe文件可以在 https://gitee.com/openLuat/LuatOS/attach_files 下载
13 -- 主要配置项, lua分需要区分两种编译环境:
14 -- lua_Integer的大小, 受 LUA_32BITS控制, 默认是启用
15 -- size_t 大小, 与平台相关, MCU上通常为32bit
16 -- 虽然可以两两组成, 但实际情况只有2种,当前:
18 -- local bittype = "64bit_size32"
19 local bittype
= "32bit"
20 -- local bittype = "source"
23 local typename
= bittype
24 if bittype
== "32bit" then
27 typename
= "_" .. bittype
30 local function lsdir(path
, files
, shortname
)
31 local cmd
= "dir /b " .. (shortname
and " " or " /s ") .. path
33 local exe
= io
.popen(cmd
)
35 for line
in exe
:lines() do
36 if string.endsWith(line
, ".lua") then
37 log.info("found", line
)
38 table.insert(files
, line
)
46 local function oscall(cmd
, quite
, cwd
)
47 if cwd
and Base_CWD
then
53 local exe
= io
.popen(cmd
)
55 for line
in exe
:lines() do
62 if cwd
and Base_CWD
then
67 function TLD(buff
, T
, D
)
68 buff
:pack("bb", T
, D
:len())
73 lsdir("corelib", files
, true)
76 local path
= "..\\luat\\vfs\\luat_inline_libs".. typename
.. ".c"
77 local f
= io
.open(path
, "wb")
80 log.info("can't write", path
)
84 f
:write([[#include "luat_base.h"]])
86 f
:write([[#include "luat_fs.h"]])
88 f
:write([[#include "luat_luadb.h"]])
93 for _
, value
in ipairs(files
) do
95 if bittype
== "source" then
96 data
= io
.readFile("corelib\\" .. value
)
98 local lf
= loadfile("corelib\\" .. value
)
99 data
= string.dump(lf
, true)
102 -- io.popen("luac_" .. bittype .. ".exe -s -o tmp.luac " .. "core\\" .. value):read("*a")
103 -- local data = io.readFile("tmp.luac")
104 local buff
= zbuff
.create(256*1024)
105 -- local data = io.readFile("tmp\\" .. value .. "c")
107 f
:write("//------- " .. value
.. "\r\n")
109 local k
= "luat_inline2_" .. value
:sub(1, value
:len() - 4) .. typename
110 print(value
, #data
, k
)
111 table.insert(kvs
, {size
=#data
,ptr
=k
, name
=value
})
113 f
:write("const char ".. k
.."[] = {\r\n")
117 if index
% 8 == 0 then
120 f
:write(string.format("0x%02X, ", buff
[index
]))
123 f
:write("};\r\n\r\n")
126 f
:write("const luadb_file_t luat_inline2_libs".. typename
.. "[] = {\r\n")
127 for _
, value
in ipairs(kvs
) do
128 f
:write(" {.name=\"" .. value
.name
.. "\",.size=" .. tostring(value
.size
) .. ", .ptr=" .. value
.ptr
.. "},\r\n")
130 f
:write(" {.name=\"\",.size=0,.ptr=NULL}\r\n")
131 f
:write("};\r\n\r\n")