commit 15b8729
Michael Forney
·
2025-02-12 08:27:14 +0000 UTC
parent 991d56f
lua: Build luaposix into standalone lua interpreter This makes it more useful for general scripting.
3 files changed,
+120,
-2
+1,
-1
1@@ -19,7 +19,7 @@ lib('liblua.a', [[src/(
2 )]])
3 file('lib/liblua.a', '644', '$outdir/liblua.a')
4
5-exe('lua', {'src/lua.c', 'liblua.a'})
6+exe('lua', {'src/lua.c', 'liblua.a', '$builddir/pkg/luaposix/libluaposix.a'})
7 file('bin/lua5.4', '755', '$outdir/lua')
8 sym('bin/lua', 'lua5.4')
9 exe('luac', {'src/luac.c', 'liblua.a'})
1@@ -0,0 +1,118 @@
2+From 53565af85003022be06bc6662e72a9291d338b14 Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Sun, 2 Feb 2025 03:03:11 -0800
5+Subject: [PATCH] Build in luaposix modules
6+
7+---
8+ lua.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+ 1 file changed, 88 insertions(+)
10+
11+diff --git a/src/lua.c b/src/lua.c
12+index 0ff88454..ca160217 100644
13+--- a/src/lua.c
14++++ b/src/lua.c
15+@@ -609,6 +609,35 @@ static void doREPL (lua_State *L) {
16+
17+ /* }================================================================== */
18+
19++int luaopen_posix_ctype(lua_State *L);
20++int luaopen_posix_dirent(lua_State *L);
21++int luaopen_posix_errno(lua_State *L);
22++int luaopen_posix_fcntl(lua_State *L);
23++int luaopen_posix_fnmatch(lua_State *L);
24++int luaopen_posix_glob(lua_State *L);
25++int luaopen_posix_grp(lua_State *L);
26++int luaopen_posix_libgen(lua_State *L);
27++int luaopen_posix_poll(lua_State *L);
28++int luaopen_posix_pwd(lua_State *L);
29++int luaopen_posix_sched(lua_State *L);
30++int luaopen_posix_signal(lua_State *L);
31++int luaopen_posix_stdio(lua_State *L);
32++int luaopen_posix_stdlib(lua_State *L);
33++int luaopen_posix_sys_msg(lua_State *L);
34++int luaopen_posix_sys_resource(lua_State *L);
35++int luaopen_posix_sys_socket(lua_State *L);
36++int luaopen_posix_sys_stat(lua_State *L);
37++int luaopen_posix_sys_statvfs(lua_State *L);
38++int luaopen_posix_sys_time(lua_State *L);
39++int luaopen_posix_sys_times(lua_State *L);
40++int luaopen_posix_sys_utsname(lua_State *L);
41++int luaopen_posix_sys_wait(lua_State *L);
42++int luaopen_posix_syslog(lua_State *L);
43++int luaopen_posix_termio(lua_State *L);
44++int luaopen_posix_time(lua_State *L);
45++int luaopen_posix_unistd(lua_State *L);
46++int luaopen_posix_utime(lua_State *L);
47++
48+
49+ /*
50+ ** Main body of stand-alone interpreter (to be called in protected mode).
51+@@ -632,6 +661,65 @@ static int pmain (lua_State *L) {
52+ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
53+ }
54+ luaL_openlibs(L); /* open standard libraries */
55++ luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
56++ /* luaposix */
57++ lua_pushcfunction(L, luaopen_posix_ctype);
58++ lua_setfield(L, -2, "posix.ctype");
59++ lua_pushcfunction(L, luaopen_posix_dirent);
60++ lua_setfield(L, -2, "posix.dirent");
61++ lua_pushcfunction(L, luaopen_posix_errno);
62++ lua_setfield(L, -2, "posix.errno");
63++ lua_pushcfunction(L, luaopen_posix_fcntl);
64++ lua_setfield(L, -2, "posix.fcntl");
65++ lua_pushcfunction(L, luaopen_posix_fnmatch);
66++ lua_setfield(L, -2, "posix.fnmatch");
67++ lua_pushcfunction(L, luaopen_posix_glob);
68++ lua_setfield(L, -2, "posix.glob");
69++ lua_pushcfunction(L, luaopen_posix_grp);
70++ lua_setfield(L, -2, "posix.grp");
71++ lua_pushcfunction(L, luaopen_posix_libgen);
72++ lua_setfield(L, -2, "posix.libgen");
73++ lua_pushcfunction(L, luaopen_posix_poll);
74++ lua_setfield(L, -2, "posix.poll");
75++ lua_pushcfunction(L, luaopen_posix_pwd);
76++ lua_setfield(L, -2, "posix.pwd");
77++ lua_pushcfunction(L, luaopen_posix_sched);
78++ lua_setfield(L, -2, "posix.sched");
79++ lua_pushcfunction(L, luaopen_posix_signal);
80++ lua_setfield(L, -2, "posix.signal");
81++ lua_pushcfunction(L, luaopen_posix_stdio);
82++ lua_setfield(L, -2, "posix.stdio");
83++ lua_pushcfunction(L, luaopen_posix_stdlib);
84++ lua_setfield(L, -2, "posix.stdlib");
85++ lua_pushcfunction(L, luaopen_posix_sys_msg);
86++ lua_setfield(L, -2, "posix.sys.msg");
87++ lua_pushcfunction(L, luaopen_posix_sys_resource);
88++ lua_setfield(L, -2, "posix.sys.resource");
89++ lua_pushcfunction(L, luaopen_posix_sys_socket);
90++ lua_setfield(L, -2, "posix.sys.socket");
91++ lua_pushcfunction(L, luaopen_posix_sys_stat);
92++ lua_setfield(L, -2, "posix.sys.stat");
93++ lua_pushcfunction(L, luaopen_posix_sys_statvfs);
94++ lua_setfield(L, -2, "posix.sys.statvfs");
95++ lua_pushcfunction(L, luaopen_posix_sys_time);
96++ lua_setfield(L, -2, "posix.sys.time");
97++ lua_pushcfunction(L, luaopen_posix_sys_times);
98++ lua_setfield(L, -2, "posix.sys.times");
99++ lua_pushcfunction(L, luaopen_posix_sys_utsname);
100++ lua_setfield(L, -2, "posix.sys.utsname");
101++ lua_pushcfunction(L, luaopen_posix_sys_wait);
102++ lua_setfield(L, -2, "posix.sys.wait");
103++ lua_pushcfunction(L, luaopen_posix_syslog);
104++ lua_setfield(L, -2, "posix.syslog");
105++ lua_pushcfunction(L, luaopen_posix_termio);
106++ lua_setfield(L, -2, "posix.termio");
107++ lua_pushcfunction(L, luaopen_posix_time);
108++ lua_setfield(L, -2, "posix.time");
109++ lua_pushcfunction(L, luaopen_posix_unistd);
110++ lua_setfield(L, -2, "posix.unistd");
111++ lua_pushcfunction(L, luaopen_posix_utime);
112++ lua_setfield(L, -2, "posix.utime");
113++ lua_pop(L, 1);
114+ createargtable(L, argv, argc, script); /* create table 'arg' */
115+ lua_gc(L, LUA_GCRESTART); /* start GC... */
116+ lua_gc(L, LUA_GCGEN, 0, 0); /* ...in generational mode */
117+--
118+2.44.0
119+
+1,
-1
1@@ -1 +1 @@
2-5.4.7 r1
3+5.4.7 r2