Hi Philipp,
On 06/09/2015 06:46 PM, Philipp Janda wrote:
>> Is there any way I can tackle this in LuaRocks?
>
> You don't have access to the Lua version in rockspecs. But since the
> number of Lua versions is manageable, you could provide multiple
> different rockspecs. This is what I have done for my Testy[1] project,
> and it works great so far.
>
> I use `-51`, `-52`, and `-53` as the rockspec revision. In the
> dependencies table, I make sure that the rockspec is valid only for the
> intended Lua version (e.g. `lua ~> 5.1`), and in the `build.install`
> table I copy the versioned script (`testy-5.1` and additionally an
> unversioned script (`testy.lua`). The unversioned one may be overwritten
> by later installs for different Lua versions, the versioned one should stay.
Thanks for sharing your solution. It's an interesting approach and it
gets the job done, although there are two slight problems (which,
granted, probably can't currently be addressed with LuaRocks):
a) You have to maintain multiple rock files, each with mostly the same
contents.
For this reason I've impelmented version-specific overrides, which work
basically exactly like platform-specific overrides. With this feature,
you can just say something like this:
build = {
...
versions = {
["5.1"] = {
install = {
bin = {
["luap-5.1"] = 'luap.lua',
},
},
},
["5.2"] = {
install = {
bin = {
["luap-5.2"] = 'luap.lua',
},
},
},
},
....
}
The pull request is here: https://github.com/keplerproject/luarocks/pull/384
Hopefully I haven't missed something and it can be merged.
b) You have to install the same file multiple times.
Okay, no-one is likely to miss a few kilobytes nowadays, and you can
reduce duplication by shipping an unversioned script that just runs the
versioned one, instead of duplicating it. Still this feels a bit
hackish so I though a bit about implementing linking in LuaRocks, but
there are a couple of problems. For one I can't think of a syntax that
would be backwards-compatible, so that the rock would not fail on older
versions of LuaRock (I assume this is important) and additionally lfs,
which LuaRocks uses, doesn't support links on Windows, so they wouldn't
be portable.
In any case, as I've said your method works so I'll probably be going
that way if my pull request isn't merged.
Thanks,
Dimitris
------------------------------------------------------------------------------
_______________________________________________
Luarocks-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luarocks-developers