Help me make a Luvit sandwhich

48 views
Skip to first unread message

develephant

unread,
Mar 15, 2016, 12:33:26 PM3/15/16
to luvit
Hi,

Hopefully this will be a simple one. I'm using Luvi with a Luvit layer and a "MyLib" layer (for example purposes).

When I'm building apps using straight Luvi and an "app" directory, I have access to the main.lua entrypoint.

But I'm not sure how to work with the "main.lua" doing the Luvi/Luvit/"MyLib" way.

I tried creating main.lua in a 'deps' folder in the MyLib directory/layer but it didn't seem to respond to that.

I used this code on the Luvi GitHub as a reference:

# Run an app that layers on top of luvit
luvi path
/to/app path/to/luvit -o /path/to/target

Obviously I've also added the output flag.

Out of curiosity, do these paths need to be full paths, or can they be relative?

Thanks in advance for any tips.

Cheers.

Tim Caswell

unread,
Mar 17, 2016, 2:11:13 PM3/17/16
to lu...@googlegroups.com
Looks like you're doing things right with the old luvi sandwich way.  One suggestion is use the lit assisted way.

- Declare your dependencies in a package.lua file. If you want all of luvit then simply add "luvit/luvit" to your deps.
- You'll also need "luvi" and "files" sections in your package.lua to have finer control of which files are included and what version of luvi is embedded.

Once you have your app with `main.lua` and `package.lua` in the root, use lit to build it.

   lit make path/to/app path/to/target/binary

You don't even need to `lit install` to create the local deps folder, `lit make ...` will fetch any missing dependencies and include them in the generated luvi+zip file.

See some examples of luvi apps that use the lit workflow:

 - luvit - https://github.com/luvit/luvit
 - lit - https://github.com/luvit/lit

Also note that these are all published to lit as applications as well, so if you want to just use them, the `lit make ...` command takes lit urls:

    lit make lit://creationix/wscat /usr/local/bin/wscat
    lit make lit://creationix/simple-http-server /usr/local/bin/simple-http-server


If you can't use lit for some reason, then it looks like you're doing it right, feel free to file a github issue against luvi.  There may have been a regression since this style isn't used much anymore.

--
You received this message because you are subscribed to the Google Groups "luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to luvit+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Caswell

unread,
Mar 17, 2016, 2:13:16 PM3/17/16
to lu...@googlegroups.com
Also I recommend using the new luvit-loader.lua shim instead of the luvit/require module for implementing luvit style package resolution.  luvit-loader uses lua's native require instead of creating a fake environment and injecting globals into each module.

Of the 4 examples all but luvit/luvit now use luvit-loader.  I havn't updated luvit itself since it would be a breaking change in some subtle ways that I'm not ready to deal with.

-Tim

Chris Byerley

unread,
Mar 17, 2016, 4:25:04 PM3/17/16
to lu...@googlegroups.com
Thanks Tim,

Will run through the Lit process. Seems pretty straight-forward.

I think I tried the luvit-loader but wasn't having much luck, but it was like 3am, so I actually forgot about that...

I'll revisit that as well. Thanks for your time.

Cheers.

You received this message because you are subscribed to a topic in the Google Groups "luvit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/luvit/7Pq4P6N32c4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to luvit+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages