Skip to content

Commit 67e30cd

Browse files
authored
Merge pull request #182 from evo-lua/document-vfs-searcher
Update the LUAZIP guide to mention VFS searchers
2 parents 86b099a + 9f71470 commit 67e30cd

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

docs/how-to-guides/standalone-executables.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,33 @@ After the process has completed, you will notice the presence of two build artif
3030

3131
The executable is all you need to distribute; it includes the ZIP archive alongside the Evo runtime used to build it (and a signature).
3232

33-
## Extracting Bundled Files
33+
## Loading Bundled Files
3434

35-
You'll need to create a "loader" called `main.lua`, which initializes the rest of your application. Place it in the directory that you package.
35+
You'll need to create a "loader" called `main.lua`, which initializes the rest of your application. Place it in the directory that you package. Evo will extract the entry point, `main.lua`, and run it when it detects a self-contained app. Your entry point can `require` modules from within the virtual file system just like any other file:
3636

37-
Evo will by default only extract the entry point, `main.lua`, and run it when it detects a self-contained app. This means that any extra files you might need (such as DLL/SO files or Lua scripts), you'll have to extract from the ZIP archive. In the future, helpers for this could be added, but it's somewhat difficult to predict what exactly is needed here so for now the runtime only provides the most basic support.
37+
```lua
38+
-- main.lua
39+
local someModule = require("someModule")
40+
dump(someModule)
3841

39-
For the time being, you can distribute other files on disk or extract everything to a temporary directory before loading the app.
42+
local someOtherModule = require("subdirectory.someOtherModule")
43+
dump(someOtherModule)
44+
```
45+
46+
In the above example, Evo will load both files from the VFS, if they exist, or use the default `require` behavior otherwise:
47+
48+
1. Whenever a module exists in the VFS and on disk, the VFS takes priority (for security and performance reasons)
49+
1. All `.` (dots) in the path names are internally replaced by `/` to cleanly map to the VFS paths
50+
51+
This change isn't disruptive; all Evo does is add a custom [searcher](https://www.lua.org/manual/5.2/manual.html#pdf-package.searchers) that looks into the VFS first when it dectects it is running a standalone executable.
52+
53+
There is one limitation that does exist: You can't directly load native libraries from the VFS.
54+
55+
If you want to use `require` (or `ffi.load`) to load a C module, you'll need to provide the DLL/SO files alongside the standalone executable. Alternatively, you can build the DLL/SO files into the app, but then you'll have to extract them from the ZIP archive.
56+
57+
In the future, helpers for this [will likely be added](https://github.com/evo-lua/evo-runtime/issues/488), but it's somewhat difficult to predict what exactly is needed here. For now the runtime only provides the most basic support.
58+
59+
For the time being, you can distribute C modules separetely (on disk) or extract everything to a temporary directory before loading the app.
4060

4161
## Native Look and Feel
4262

0 commit comments

Comments
 (0)