Bug 404491 - Build TCF Lua integration as sharedlib optionally
Summary: Build TCF Lua integration as sharedlib optionally
Status: NEW
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Gaetan Morice CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-27 16:05 EDT by Martin Oberhuber CLA
Modified: 2013-03-28 03:15 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2013-03-27 16:05:34 EDT
The main_lua.c should optionally be built as a shared library, such that it can link against any Lua VM (specifically, the Mihini Lua VM).
Comment 1 Martin Oberhuber CLA 2013-03-27 16:06:42 EDT
Gaetan said they will try making a patch :)

Files to look at:
- Some preprocessor magic in
https://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.git/tree/agent/tcf/main/main_lua.c

- Some make magic in
https://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.git/tree/agent/Makefile
Comment 2 Martin Oberhuber CLA 2013-03-27 16:07:26 EDT
For the records, to bootstrap the build:

git clone git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
cd org.eclipse.tcf.agent/agent
make LUADIR=$HOME/lua
Comment 3 Martin Oberhuber CLA 2013-03-27 16:09:47 EDT
On a related note, it would be cool if the Lua binding could also live on the agent, along with 
- a "Lua" Service which can evaluate Lua scripts on the target ... or loading 
- automatically loading Lua scripts on the agent to define service providers

But those things are outside the scope of this bug, for now the goal is enabling the Mihini Lua VM to be a TCF client, by adding the TCF Lua binding as a sharedlib.
Comment 4 Martin Oberhuber CLA 2013-03-27 16:13:34 EDT
Documentation for the TCF Lua Integration:

https://git.eclipse.org/c/tcf/org.eclipse.tcf.git/plain/docs/TCF%20Lua%20Integration.html
Comment 5 Martin Oberhuber CLA 2013-03-27 17:30:12 EDT
Thinking about this again, I believe the trick to solve will be making sure that a TCF event loop can run.

In the current code, TCF is the "master" and Lua is invoked as a "slave". When Lua is a module in a sharedlib, the Lua VM is the "master" and TCF is the "slave".

It might be interesting to learn from how it's done in the TCF Python binding (which is plain Python without any C) - there also the TCF event loop needs to be implemented in plain Python as a "slave".
Comment 6 Anton Leherbauer CLA 2013-03-28 03:15:43 EDT
(In reply to comment #5)
> It might be interesting to learn from how it's done in the TCF Python
> binding (which is plain Python without any C) - there also the TCF event
> loop needs to be implemented in plain Python as a "slave".

Python comes with a threading module which provides very similar functionality to Java threads. I don't know if Lua has support for that. I know it has built-in support for co-routines, but I am not sure this is sufficient to create an event loop. And of course you need to deal with sockets.