Am 30.08.2014 um 01:13 schröbte Steven Degutis:
> I can't for the life of me figure this out.
>
> Here's the module I'm trying to convert:
> https://github.com/mjolnir-io/mjolnir-keycodes
>
> Basically it's a really simple module. The only strange things it
> needs are `CFLAGS += -fobjc-arc -Wall -Wextra` and `LDFLAGS +=
> -framework Cocoa -framework Carbon`, and for `CC` to not contain
> `MACOSX_DEPLOYMENT_TARGET=10.5` by default like it does. Ideally I'd
> like to use the `builtin` back-end according to the [Rockspec
> format](http://luarocks.org/en/Rockspec_format), but I don't think
> that works with this.

No, the "builtin" backend is supposed to be platform- and 
compiler-agnostic, so there is no way to specify compiler switches 
directly in the rockspec. The "make" backend is probably your best bet.

>
> Now, all of the above is strictly about trying to fix the current
> [mjolnir-keycodes-0.1-1.rockspec](https://github.com/mjolnir-io/mjolnir-keycodes/blob/master/mjolnir-keycodes-0.1-1.rockspec)
> file. What I have in the repo right now will *technically* build and
> install. But when I try `k = require 'mj.keycodes'`, it fails saying
> `module 'mj.keycodes.internal' not found` (which is referring to [this
> line](https://github.com/mjolnir-io/mjolnir-keycodes/blob/master/keycodes.lua#L17)
> inside `keycodes.lua`). This means it's actually loading the Lua
> module, but it's not registering the file correctly. Thus I'm pretty
> sure it's related to the `.rockspec` file not being written correctly.
>
> Technically the file is missing also:
>
> ~~~
> $ ls -la /usr/local/share/lua/5.1/mj/
> total 8
> drwxr-xr-x  3 sdegutis  admin   102B Aug 29 18:01 .
> drwxr-xr-x  7 sdegutis  admin   238B Aug 29 18:01 ..
> -rw-r--r--  1 sdegutis  admin   1.2K Aug 29 18:01 keycodes.lua
> ~~~

The compiled C module should be 
`/usr/local/lib/lua/5.1/mj/keycodes/internal.so`, so *not* in 
`/usr/local/share`.

>
> But that's not the only problem. I'm also probably referencing it
> wrongly inside the `.rockspec` file. And on top of that, it probably
> contains the wrong `luaopen_*` name internally.

The correct one should be `luaopen_mj_keycodes_internal`.

>
> Please help. Thanks.

Using the "make" backend has reasonable defaults for most settings, so 
you often only need to pass some variables from LuaRocks to `make`:

     build = {
       type = "make",
       variables = {
         DLL_INSTALL_DIR = "$(LIBDIR)",
         LUA_INSTALL_DIR = "$(LUADIR)",
         LUA_INCDIR = "$(LUA_INCDIR)",
         CC = "$(CC)",
         CFLAGS = "$(CFLAGS)",
         LIBFLAG = "$(LIBFLAG)",
       }
     }

This assumes that you have a `Makefile` in the top directory, the 
default target (usually the topmost target) should build the dynamic 
library, and the `install` target should create the necessary sub 
directories in `${DLL_INSTALL_DIR}` and `${LUA_INSTALL_DIR}` and copy 
the `.lua`/`.so` files there. The variables listed in the rockspec will 
*replace* any variables you set in the `Makefile`, so you can put 
default settings there for use without LuaRocks.

You might need to remove `CC` from the list above, because it will 
evaluate to `export MACOS_DEPLOYMENT_TARGET=10.x; gcc` on your OS, where 
`x` is never greater than 5. `${LIBFLAG}` will evaluate to the compiler 
flags needed to build a C extension module (`-shared` on sane OSes, and 
the whole `-bundle -undefined dynamic_lookup -all_load` on MacOS). And 
you don't need to link your C extension to the Lua library on MacOS, btw.

>
> -Steven
>

HTH,
Philipp




------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Luarocks-developers mailing list
Luarocks-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/luarocks-developers

Reply via email to