On This Page
Many2One is a utility to combine multiple lua source files into 1 file for easy usage and distribution. It consists of a lua file (many2one.lua) and an associated configuration file containing all the run information.
It will scan the given file and find all dependencies recursively using the the package.path and package.cpath settings in the Lua interpreter used to run many2one. So if you can run your program using the same Lua Interpreter on the same system, many2one will find all the dependencies and copy them over to make a self contained package. This saves a lot of time because earlier missing packages were found when the self contained package was executed.
NOTE: However the dependencies of the dynamic libraries are not followed or copied. That would be a feature for the future.
After running many2one with the config.lua of:
This will create the MainApp.lua file in the deploy directory.
The MainApp.lua file will look something like:
This command opens up config.lua as the default configuration file that it expects in the same directory.
This command uses the configuration file myconfig.lua
It's simple to understand. The main program file is added in the variable
mainFile. The output file name is added in the variable
outputFile. The exclude section is optional containing a list of modules that are found in the scripts that you don't want to search and include in the package. For example table module is packaged with lua but some programs sometimes do require("table"). So you can have "table" in the exclude list so you do not get the module not found error from the dependency searcher code.
And that is it.
So now in the code require("pl.app") will work if some external code uses it through your application.
Of course the included libraries should be available to many2one during consolidation.
It includes all the Lua files listed in the fileList of the config file as a string in the table
- submodsearcher - To modify the search paths to search properly for sub modules
- tableUtils - Useful table manipulation utilities
- LuaFileSystem - Lua file system module
- diskOP - Disk Operations library based on LuaFileSystem
- Logging - Logging library
- argparse - Command Line Argument Parsing
github repository. many2one is a single script file and if you have the above dependencies installed most of which (except luafilesystem) are simple Lua modules you can use it directly.
You can also install using LuaRocks:
Once installed through LuaRocks you can directly run the script from the command line as: