On 2012-02-16 22:36+0530 Atri wrote:

> Hi!
>
> Thanks for all the helpful suggestions. My first attempt at building
> with lua 5.2 is outlined below.
>
> On Sat, 2012-02-11 at 14:57 -0800, Alan W. Irwin wrote:
>> Copy the system version of
>> FindLua51.cmake (usually found in
>> /usr/share/cmake-2.8/Modules) to cmake/modules.
>>
>> That copy operation assures that the PLplot system will use the
>> version of FindLua51.cmake in cmake/modules rather than
>> the system one.
>>
>> Then edit the PLplot version as follows:
>>
>> Wherever there is a reference to Lua 5.1 put in additional 5.2 choices
>> first.
>>
>> That is:
>>
>> PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
>>
>> ==>
>>
>> PATH_SUFFIXES include/lua52 include/lua5.2 include/lua51 include/lua5.1 
>> include/lua include
>>
>>
>> NAMES lua51 lua5.1 lua-5.1 lua
>>
>> ==>
>>
>> NAMES lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua
>>
>> Leave
>>
>> FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 ...
>>
>> as is since the 51 there refers to the name of the find module itself
>> which for now should continue to be cmake/modules/FindLua51.cmake.
>>
>
> In addition to these changes, I also had to do the following to the file
> cmake/modules/lua.cmake
>
> --- lua.cmake.orig    2011-10-13 06:13:01.000000000 +0530
> +++ lua.cmake 2012-02-13 00:03:36.000000000 +0530
> @@ -100,6 +100,8 @@
>     set(LUA_VERSION_VALID ON)
>   elseif(${LUA_VERSION} STREQUAL "5.1" AND LUA51_FOUND)
>     set(LUA_VERSION_VALID ON)
> +  elseif(${LUA_VERSION} STREQUAL "5.2" AND LUA51_FOUND)
> +    set(LUA_VERSION_VALID ON)
>   endif(${LUA_VERSION} STREQUAL "5.0" AND LUA50_FOUND)
>
>   if(NOT LUA_VERSION_VALID)
> ---
>
> After these modifications to the source directory, and using a modified
> version of swig-2.0.4 with the following patch applied
> http://sourceforge.net/tracker/index.php?func=detail&aid=3480366&group_id=1645&atid=301645
> I got plplot along with its lua bindings to build successfully with lua
> 5.2.

Good.

>
>
>> If your PLplot lua-5.2 build goes okay (with -DBUILD_TEST=ON cmake
>> option) with the above copy and edit of FindLua51.cmake, then please
>> also try run-time testing of our lua bindings using the following
>> command:
>>
>> make test_lua_psc
>>
>> which runs all our lua examples with -dev psc.
>>
>> If that works without issues (i.e., the lua results in the examples
>> subdirectory of the build tree render okay with a PostScript viewer
>> like gv) I would be happy to copy your modified version of
>> FindLua51.cmake to PLplot so all PLplot/Lua-5.2 users can benefit.
>> __________________________
>> Alan W. Irwin
>>
>
> Now here is where the problem occurs. When attempting the 'make
> test_lua_psc' the first example 'x01' seems to work fine. However, for
> 'x02',
>
> ---
> Testing front-end lua
> x01
> x02
> /usr/bin/lua: x02.lua:105: attempt to call field 'mod' (a nil value)
> stack traceback:
>       x02.lua:105: in function 'demo2'
>       x02.lua:150: in main chunk
>       [C]: in ?
> make[3]: *** [examples/x01lua.psc] Error 1
> make[2]: *** [examples/CMakeFiles/test_lua_psc.dir/all] Error 2
> make[1]: *** [examples/CMakeFiles/test_lua_psc.dir/rule] Error 2
> make: *** [test_lua_psc] Error 2
> error: Bad exit status from /var/tmp/rpm-tmp.RoZaxq (%build)
> ---
>
> ... and there the build halts with an error. Any suggestions about this?

The fact that you got the lua-5.2 build to work and example 1 (which
actually is pretty complicated) to run shows, I think, that
you are down to really specific issues as opposed to "nothing works".
So the prospects for PLplot to completely support lua-5.2 look extremely
promising.

The above "make test_lua_psc" command sets up being able to run
individual lua examples by hand.

Here is how you do that:

In the build directory....
cd examples/lua
lua x01.lua -dev psc -o test.ps

Does test.ps generated this way give a good-looking result using
the gv viewer of PostScript files?

If so, then I would try example 2 which should generate the above error
message

The offending line in question for example 2 is the innocuous looking

h = (360/10) * math.mod(i, 10)

I checked, and example 1 uses the math library as well so access to
that lua library appears not to be an issue.

So it appears that math.mod simply does not exist for 5.2. In fact,
the 5.2 documentation doesn't refer to it and the 5.1 documentation
http://www.lua.org/manual/5.1/manual.html says "Function math.mod was
renamed math.fmod".  Apparently my own 5.1 version of Lua only works
because of compatibility mode.

If you look up the math functions in lua in the above documentation
thy simply appear to be front ends for the C library version, e.g.,
math.fmod corresponds to the C library floating-point fmod function, and I 
presume
lua takes care of all the casting from integers for the above case.

So one possibility to deal with this is simply to replace all math.mod
in the several examples where that occurs with math.fmod.  However,
another alternative is to use the lua % operator (which takes the
remainder relative to minus infinity rather than zero as in the
math.fmod case).  If we are always dealing with positive values using
the % operator might be a better alternative than math.fmod.

Anyhow, let me test the math.fmod and % possibilities for all our lua
examples in the next little while, and I will get back to you.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to