Search code examples
oopobjectlualuajit

Create one object file for multiple files in directory


I have around 5 files(a.lua, b.lua, c.lua, d.lua, e.lua) in one directory say dir_1. Is it possible to create one object file for all the files in dir_1?

I want to use dir_1 files in some other directory. What are the possible ways to do so? Thanks.


Solution

  • Yes, you can create a composite compiled script. For example,

    luac -o all_in_some_order.lub *.lua
    

    I gave it a .lub extension for Lua Binary. Nonetheless, Lua treats binary and text scripts the same. Like a text script, the composite is just like a body, except that the composite is one or more function bodies run sequentially.

    You could specify the order of execution on the command line, if necessary.

    See luac for other options.

    Note: your executables might be named like luac53.