lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Compile with Copas only #47

Closed drasko closed 9 years ago

drasko commented 9 years ago

Hi, I would like to use lua-websocket on a microcontroller with Lua, and without operating system. That means that I can not use libev, bacause AFAIK libev depends on the mechanisms of OS (like epoll or POSIX select).

As I understand copas is pure Lua implementation of cooperative multithreading and depends only to Lua supported coroutines, so completely independent of OS, wich makes it good candidate for running it on bare-metal microcontroller (actually I am using eLua: http://www.eluaproject.net/).

Is it possible to compile lua-websockets with Copas support only, and how to achieve that?

Not only that I do not need libev for runtime, but also i am using Cygwin host for compilation, and over there I have:

/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lev
collect2: error: ld returned 1 exit status

Error: Build error: Failed compiling module ev.so

although I compiled and installed libev in Cygwin (I did it just to compile lua-websockets, not really because I need it).

BR, Drasko

lipp commented 9 years ago

very interesting! yes you dont need (lua)ev. there are server/client backends for ev and copas available. the luarocks install grabs everything although most likely you choose either one.

if you have copas up and running, this should be sufficient. you still need:

"struct", "luasocket", "luabitop",

drasko commented 9 years ago

Yes, but how to achieve this? Do I have to change some Makefile? How to mark that these are the only dependences? (I am new to Lua :)).

I think this would be good to have as the compilation choice.

lipp commented 9 years ago

there is no compilation step. lua-websockets uses C modules (which need to be compiled) but itself is 100% lua. installing lua-websockets is just a matter of copying all files to a lua module search folder/path.

you could leave out some files (like all the ev files), but they dont hurt.

drasko commented 9 years ago

OK, thanks.

I will try deleting this line: https://github.com/lipp/lua-websockets/blob/master/rockspecs/lua-websockets-scm-1.rockspec#L20 before doing

luarocks make rockspecs/lua-websockets-scm-1.rockspec
lipp commented 9 years ago

perfect! that's a good option if you still want to use luarocks.