You are not logged in.

#1 2011-02-22 09:25:15

demizer
Member
From: Gilroy, CA
Registered: 2010-03-03
Posts: 116
Website

[SOLVED] Development Process Help

Hey guys/gals,

I am working on a program that will eventually have a lua library that will be installed in "/usr/share/program/runtime/". It is no problem to reference this once the program is installed, but during development, I will have to do some path juggling and I don't feel that is the right solution. Once I have built the application, DATADIR references "/usr/local/share".

1.) So my question is, in order for this to work right, do I have to install the program, or do I set this in the build tool to point to the development directory?
2.) What is the appropiate process for handling this?

I have been googling for the last couple days, and all I get is trash.

Thank you for your time.

Last edited by demizer (2011-02-23 07:30:42)

Offline

#2 2011-02-22 09:58:12

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: [SOLVED] Development Process Help

Your post isn't really clear.  What loads the Lua library (compiled code, a Lua script, ...)?
If the library gets installed in "/usr/share/program/runtime", why did you mention DATADIR (which I suspect is XDG_DATA_DIRS)?

If you're loading the library via a Lua script, check the Lua reference manual for dynamic path configuration. I doubt that's what you're after if you've been searching for days, but I mention it just in case.


If the path is hard-coded in the compiled application, consider changing it to use an environment variable (preferably one of the XDG_* variables). You could then write a simple test script that adds the current location of the library to the path list. Always avoid hard-coded paths if you can.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2011-02-23 03:00:11

demizer
Member
From: Gilroy, CA
Registered: 2010-03-03
Posts: 116
Website

Re: [SOLVED] Development Process Help

Xyne wrote:

Your post isn't really clear.  What loads the Lua library (compiled code, a Lua script, ...)?

Sorry, it was really late and I was sleepy and frustrated. Anyways, I was referring to un-compiled lua code-- as in a source code file "runtime.lua" that will reside in "/usr/share/foo/lib/runtime.lua" once the application is installed.

While the program is in development,  I have it located in "/home/foo/projects/c/foo/lib/runtime.lua" and this is where I am confused. When I compile the project in this directory, it cannot find the file because DATADIR (provided by the build tool) is pointing to "/usr/local/share/".

So my question is, do I have to install the application every time I want to test it?

Is it normal to install a program every time I rebuild it from source to test?

Offline

#4 2011-02-23 06:59:51

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: [SOLVED] Development Process Help

demizer wrote:

Sorry, it was really late and I was sleepy and frustrated. Anyways, I was referring to un-compiled lua code-- as in a source code file "runtime.lua" that will reside in "/usr/share/foo/lib/runtime.lua" once the application is installed.

Isn't Lua always uncompiled? What I wanted to know is if you have a Lua script that is loading a Lua library, in which case you should be able to configure it (at least temporarily) to search for the library in your testing directory (check the Lua manual). If it's Lua code that is being directly pulled in by non-Lua code (apparently C), then you should still be able to configure it in the non-Lua code, assuming that it's code that you have written.

You say that the build tool provides DATADIR and you imply that you cannot change it. Are you sure? If there really isn't, it sounds as though your build tool is painfully myopic.

What build tool are you using?
Show us the code that actually loads the file too.

You should not have to install it to test it. That is either bad design of the application itself, or the build tools.

I still suspect that DATADIR is set from the environment variable XDG_DATA_DIRS:

> echo $XDG_DATA_DIRS
/usr/share/:/usr/local/share/

As you can see, on my system (on which I have not changed the default value), the last path is the same as that reported by your DATADIR. I would test that by appending the desired path to XDG_DATA_DIRS in a terminal before running the build tool:

export XDG_DATA_DIRS="$XDG_DATA_DIRS:/home/foo/projects/c/foo/lib/"
./build...

Note though that even if that works, it's an ugly solution because XDG_DATA_DIRS should be limited to system-wide data directories. User data directories should be in XDG_DATA_HOME.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2011-02-23 07:30:21

demizer
Member
From: Gilroy, CA
Registered: 2010-03-03
Posts: 116
Website

Re: [SOLVED] Development Process Help

Isn't Lua always uncompiled?

Correct. It is not compiled until it hits the vm. The code is kept in plain text on disk. As an example, the awesome window manager keeps its lua library code in "/usr/share/awesome/lib".

You say that the build tool provides DATADIR and you imply that you cannot change it. Are you sure? If there really isn't, it sounds as though your build tool is painfully myopic.

I am using waf, and I can change the DATADIR. Indeed it does use $XDG_DATA_DIRS, and my path is the same as yours.

My time today was spent reading the source code of awesome to see how they handle it, and it looks like they use XDG_DATA_DIRS and the preprocessor to determine the location of the library files, which is what I will do once I get around to implementing it. I haven't actually written the code yet.

I sat down to write an init script loader the other day and did not understand how the program was going to find the init script once the program was installed versus when it is built in the project directory and I am testing it.

You should not have to install it to test it. That is either bad design of the application itself, or the build tools.

Exactly. I felt installing my program to test it was very wrong, and googling for the answer was not helpful. It is only the wisdom a veteran that can answer my question. This is where I really wish I was working in programming professionally.

So waf allows me to adjust the DATADIR variable and I am going to point that to my build directory during testing. One of these days the code will be on github and you can check it out if you like. It is a simple toy text editor that I am writing to get experience with C. Thank you for your time, I really appreciate it.

Offline

Board footer

Powered by FluxBB