[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Distributing self contained lua app
- From: Sean Conner <sean@...>
- Date: Thu, 22 Jul 2021 19:24:44 -0400
It was thus said that the Great Peter Hickman once stated:
> I'm wanting to make a small lua application completely self contained, no
> installation dependencies. So my plan is to use physfs so that all the lua
> scripts would be in one file. Then I will use a little C script like this:
[ snip ]
> I'm pretty sure that it will work just fine. But there is a question,
> physfs is a nice and small library and I only need three methods so it's
> not a big deal. But if I was to use SDL2? Exposing the whole of SDL2 (sdl2,
> sdl2_gfx, sdl2_image, sdl2_mixer, sdl2_ttf) as C functions is going to be a
> nightmare. Along with the issue of getting SDL2 to use physfs when it loads
> images, fonts and sound files
>
> Is there a better way of doing this?
>
> Or is it "welcome to the club" :(
Welcome to the club.
Okay, I do this for a few applications at work, only I embed the entire
code (C and Lua) into an executable. I have an overview of how it works:
http://boston.conman.org/2013/03/22.1
http://boston.conman.org/2013/03/23.1
only these days, I load the C modules into package.preload and I run the Lua
based modules through zlib to save space.
I also did another approach to distributing a "Lua application" as a
single file, based off the method Java uses with it's .jar files. An
overview of this method:
https://github.com/spc476/LEM
There were, however, some issues---while I could load modules written in
Lua directly from the ZIP file, I could not load modules written in C
directly from the ZIP file (I would have to first extract the module onto an
actual file system and then I could load them). Also, how to deal with
applications that want to write data. I was able to get LuaRocks to run
exclusively from a ZIP file (but that work isn't publically avilable as it
was more of a "proof-of-concept" for myself than anything else), and
ultimately, I just lost interest in it.
But on that note, the ZIP file format is unique in that its header starts
at the *end* of the file, so it's relatively easy to append a ZIP file to
the end of an exectuable (that's how self-extracting ZIP archives work).
Maybe a self-extracting/self-installing program?
I don't think there are any easy answers for what you are trying to
accomplish here.
-spc