Add Library Folder

I would like to see a separate library folder where all the common library files can be store (ui.lua, moviewclip.lua, etc.). This library would be searched after the project folder for any unresolved "require()" files. This would remove the need to have these library files duplicated for every project that needs them. It would also point to the most recent updated version.

I would expect this library folder to be under Applications (where the current Corona SDK is installed) with an option to specify a new folder location.

Tom

Feature request #250

Or even just being able to require("somedir/myfile.lua").

I forget the reason behind not being able to specify relative paths for everything right now anyway?

I think he is asking for a central place for the libraries. Not about about sub folders inside the project folder!

For me both is not very important for some reasons:

1. I want to have the sources together I used for a build. This includes that I manually update any library file I am using to have full control about this.

2. My source revision control would hate it for the same reason as 1.

3. I use sub folders in the project directory for related data which is not meant to be added to the build. It would be bad if they all would get added!

4. To use relative paths they would need to parse the sources for such statements to device which files to include in the build. afaik they are just adding everything from the projects root to the build and don't care about if the files are used or not (which they can't anyway because they won't understand what the app wants to do with the files there)

I would settle with a simple script which updates my libraries by copying or... by using an external reference in revision control system tree of source files

What I was asking for was a standard library folder to store the Corona supplied library files that would be searched if there any unresolved files specified in the "require" statement. For me it would be nice if I didn't have to have a copy of all Corona library files in my project folder. If I have multiple projects that require these files, they have to be duplicated in each project.

If you have modified a Corona library, you could keep a copy in your project folder and the library folder would never be accessed. Same thing if you want to copy all the Corona files to your project directory.

Instead (or in addition) I would also settle for the ability to specify a path in the "require" statement specifying the location of the file. Either way would suite my needs.

Tom

My problem with that would be that if ansca would change one of their libraries my projects would pick this up which is not what I want.

I just tested if Corona works with aliases or softlinks and it does for softlinks.

It also builds correctly with sources as soft-linked files.

So you could use a central place and just do something like this in your projects:

1
ln -s ~/Documents/Lua-Libraries/hrtools.lua hrtools.lua

My solution would not cause your projects to pick up the new libraries if you already have the library files in your project folder. The builder would only search the "common" library folder if the library file was missing from the project folder.

Stated a different way, if your project is working now, nothing would change moving to the common library folder.

My implementation of the feature would add an option to the Corona Preferences page where you turn this feature on/off and specify the library folder path.

BTW, thanks for your softlink tip. I'll give it a try.

Tom

I still just think that one would need to parse your source and make assumptions about what your "require" means..

Take this:

1
2
3
4
5
6
7
if onDevice then
 lib='hrtools_device.lua'
else
 lib='hrtools_simulator.lua'
end
 
require(lib)

I personally second s.w.powers on this one.

@Fogview

Having a single directory for additional/user lua libs while not being able to arbitrarily put *anything* in separate directories would be extremely strange.

Once you can use directories, in general, you can require your "modified" lua libs from any directory, without having Ansca engineers to keep track of single, tiny and specific features like this one to maintain. (and users to learn)

@erpy how would you specify which files need to be part of a build then?

Don't know if I got your question... I'd simply have a folder named after my app with all the sub-directories in it.

If you mean that Corona Lua libs should be built/copied from within the Corona SDK into your app, I'd just rather copy them by hand into my new app... if I need any of them.

This is because:

1) It's not said I'm going to use them, and it's a (tiny) waste on file size
2) I might modify a lib by hand for a certain app and want to have it left that way...
3) If you system is in place, 2) might not be possible at all if not by duplicating and renaming the lib

So, I'd rather be free to be able to do 2) than save a few clicks for copying 2 or 3 files. :)

I mean how you want to tell the compiler which of the sources need to be inside the build of your project!

Sorry but I really wonder if you have read what I explained before...

Nobody can say which Lua files are being loaded at runtime by a program... and the compiler and packager need to know which files your application is going to use.

That is the reason why all files in the project folder are included always. Even if you do not "require" them inside of you program.

One would need to include ALL of the files in those special shared folder and all of the projects subfolders into every project or have the user manually specify which files are to be included before packaging.

As it currently is you know what files are there... and if you name them appropriately you also can group them visually ... where is the need for subfolders anyway?

I see what you mean, but that's different from your initial post.

Citation:

What I was asking for was a standard library folder to store the Corona supplied library files that would be searched if there any unresolved files specified in the "require" statement. For me it would be nice if I didn't have to have a copy of all Corona library files in my project folder.

Which is useless, IMHO.

@erpy

You don't mean me don't you? :)

I did never request any of this.. I jumped in and explained why it does not work and offered the solution with softlinks for those which want to keep files the same between different projects.

I also explained that I won't need any folders on disk for source-code arrangement because I can use groups in the ide for this.

I posted all of this in my initial and my second post... later I got the impression people did not read what I wrote.. or my english is just to bad to understand as I am german... well

In fact, is it possible to manage different files in folders ?

For example, I'd like to put my interface buttons in a folder, my backgrounds in another... and load them with display.newImage(my/path/to/the/folder). Is it possible ?

Thanks in advance

Nope it is not... at least not currently. Because they will not be included in the build.

woah. I'm shocked at this. I actually submitted a bug report WRT not being able to include folders in project builds.

Funny thing is that when running the simulator, moving things into folders works. it's when you build for devices that it all goes wrong.

In fact, is it possible to manage different files in folders ?

You can do this for all files other than code files. Any .lua must be in the project root, but all graphics and sounds can go in sub-folders. That's how I have my project organized: all code in the root, "graphics" folder with all images, "audio" folder with all sound files.

@achesser: Both device and simulator support sub-folders so that is not your issue. Note that the device is case-sensitive for filenames while the simulator is not, so that is probably your problem. Since you seem to think folders work in simulator and not on device, it's probably your directory names that have capitalization mistakes.

views:2527 update:2011/9/18 20:20:08
corona forums © 2003-2011