Dogfood released; an alternative for creating 'self running' Lua programs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Dogfood released; an alternative for creating 'self running' Lua programs

Jasper Klein
Hello,

I would like to announce that I've released v1.0.1 of my project 'dogfood' [1].
Dogfood is a srlua alternative for creating self running Lua programs.

The main points where dogfood differs from srlua are;
- One self containing executable.
- Can embed multiple (non-binary) Lua modules in one executable.
- No support for Lua 5.1 and older.

The dogfood executable has two parts; the 'dog' part containing the interpreter and the 'food' part which is a Lua script that is executed by the 'dog' part.
When creating a self running Lua program, the food part extracts the interpreter (the dog part) from itself and then glues your Lua modules against it.
This tool owes its name because of the reuse of its interpreter for the resulting program.

Building dogfood should be straightforward but requires boostrapping to join the dog and food parts. The provided makefile will do the bootstrap for you.
However in case you have your own build environment, there are bootstrap shell scripts for Windows and Unix like systems as well.

-- Jasper Klein

[1] https://github.com/PG1003/dogfood

Reply | Threaded
Open this post in threaded view
|

Re: Dogfood released; an alternative for creating 'self running' Lua programs

Marc Balmer
Attached is my approach (in Lua land, everyone creates his own batteries...)

Requires a C compiler.  Tested on macOS only....




Oh yes, and it can eat its own dogfood, too:

$ lua luacc.lua -o luacc luacc.lua

- mb

> Am 21.07.2020 um 22:29 schrieb Jasper Klein <[hidden email]>:
>
> Hello,
>
> I would like to announce that I've released v1.0.1 of my project 'dogfood' [1].
> Dogfood is a srlua alternative for creating self running Lua programs.
>
> The main points where dogfood differs from srlua are;
> - One self containing executable.
> - Can embed multiple (non-binary) Lua modules in one executable.
> - No support for Lua 5.1 and older.
>
> The dogfood executable has two parts; the 'dog' part containing the interpreter and the 'food' part which is a Lua script that is executed by the 'dog' part.
> When creating a self running Lua program, the food part extracts the interpreter (the dog part) from itself and then glues your Lua modules against it.
> This tool owes its name because of the reuse of its interpreter for the resulting program.
>
> Building dogfood should be straightforward but requires boostrapping to join the dog and food parts. The provided makefile will do the bootstrap for you.
> However in case you have your own build environment, there are bootstrap shell scripts for Windows and Unix like systems as well.
>
> -- Jasper Klein
>
> [1] https://github.com/PG1003/dogfood
>


luacc.lua (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dogfood released; an alternative for creating 'self running' Lua programs

Mike Schmitz-2
On Fri, Aug 07, 2020 at 02:11:02PM +0200, Marc Balmer wrote:
> Attached is my approach (in Lua land, everyone creates his own batteries...)
>
> Requires a C compiler.  Tested on macOS only....
>


>
>
> Oh yes, and it can eat its own dogfood, too:
>
> $ lua luacc.lua -o luacc luacc.lua
>
> - mb

Verified on Devuan Beowulf with this patch:
 
--- luacc.lua   2020-08-07 08:44:00.299980320 -0700
+++ luacc.linux.lua     2020-08-07 08:39:10.975984249 -0700
@@ -21,8 +21,8 @@
 end
 
 -- Start the compiler that expects C code on standard input
-local c = io.popen('cc -x c -o ' .. outfile .. ' -O3 -I/usr/local/include '
-    .. '-L/usr/local/lib -llua -', 'w')
+local c = io.popen('cc -x c -o ' .. outfile .. ' -O3 -I/usr/include/lua5.3 '
+    .. '-L/usr/lib/x86_64-linux-gnu -llua5.3 -', 'w')
 
 -- Dump the bytecode to a const char array
 c:write('static const char bytecode[] = {')


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dogfood released; an alternative for creating 'self running' Lua programs

Luiz Henrique de Figueiredo
In reply to this post by Marc Balmer
luacc.lua accepts several scripts to run but does not work because
this line in luacc.lua does not work as intended:
   bytecode = table.concat(bytecode)

Simply concatenating bytecode for two scritps does not produce
bytecode that runs both scripts. luac.c does some magic to make this
happen. I wrote luac.lua [1] that does that but it's neither pretty
nor portable.

[1] http://lua-users.org/lists/lua-l/2008-08/msg00092.html
Reply | Threaded
Open this post in threaded view
|

Re: Dogfood released; an alternative for creating 'self running' Lua programs

Jasper Klein
In reply to this post by Marc Balmer
Op vrijdag 7 augustus 2020 14:11:02 CEST schreef Marc Balmer:
> Attached is my approach (in Lua land, everyone creates his own batteries...)

Your solution is much simpler than I've made with dogfood but luacc has less features . ;-)

Yes, there are many others.
I like the srlua concept and after studying it, I got the idea for dogfood and decided to make it.

> Requires a C compiler.  Tested on macOS only....

Once dogfood is build, it doesn't require a compiler to build self contained Lua executables which is an advantage on platforms such as Windows.

On Github I found multiple projects, like luastatic, that build Lua executables in more or less the same way als luacc, by outputting C code that has to be compiled to have a self contained Lua executable.
The resulting executable will launch faster by avoiding opening itself as a file and reading/seeking for the Lua parts as dogfood and srlua do.
But on the other hand, when speed is really needed, Lua wouldn't probably be the right choice.

Dogfood was tested on Windows and Linux (Manjaro), but not on macOS. :-)

-- Jasper


Reply | Threaded
Open this post in threaded view
|

Re: Dogfood released; an alternative for creating 'self running' Lua programs

lyiriyah
Sounds really cool man, and I rate Manjaro!

Oscar

7 Aug 2020 18:46:28 Jasper Klein <[hidden email]>:

> Op vrijdag 7 augustus 2020 14:11:02 CEST schreef Marc Balmer:
>> Attached is my approach (in Lua land, everyone creates his own batteries...)
>
> Your solution is much simpler than I've made with dogfood but luacc has less features . ;-)
>
> Yes, there are many others.
> I like the srlua concept and after studying it, I got the idea for dogfood and decided to make it.
>
>> Requires a C compiler.  Tested on macOS only....
>
> Once dogfood is build, it doesn't require a compiler to build self contained Lua executables which is an advantage on platforms such as Windows.
>
> On Github I found multiple projects, like luastatic, that build Lua executables in more or less the same way als luacc, by outputting C code that has to be compiled to have a self contained Lua executable.
> The resulting executable will launch faster by avoiding opening itself as a file and reading/seeking for the Lua parts as dogfood and srlua do.
> But on the other hand, when speed is really needed, Lua wouldn't probably be the right choice.
>
> Dogfood was tested on Windows and Linux (Manjaro), but not on macOS. :-)
>
> -- Jasper
>