Automatic library download plan

Adam Ruppe destructionator at gmail.com
Fri Jun 25 13:17:47 PDT 2010


I was thinking this morning about a way to have a simple way for D
library distribution. Let me run it by you guys, and we'll discuss if
it is a good plan. The short version is it takes a package -> URL
mapping file and downloads on http, based on the .d file being in an
expected folder.

The plan is simple. The program will take a file and parse out its
dependencies, using dmd -v, like rdmd does. Now, it opens a package
mapping file. If this file doesn't exist locally, it can download it
from a central server.

The file looks like this:

arsd   http://arsdnet.net/dcode
mylib  http://dsource.org/libs
mylib.container  http://domain.com
gui    http://dsource.org/libs

It can be customized or you could submit your library for the central
list. Now, say your program has:

import arsd.dom;
import mylib.container;
import mylib.whatever.mod;
import gui.window;

This would look up the most specific entry in the list, and try to
download it. So

arsd.dom matches arsd, so it tries to download
http://arsdnet.net/dcode/arsd/dom.d
mylib.container matches mylib.container, so it gets
http://domain.com/mylib/container.d
mylib.whatever.mod's best match is the package mylib. So:
http://dsource.org/libs/mylib/whatever/mod.d
gui.window gets http://dsource.org/libs/gui/window.d


It downloads them all to a folder, like package/ in the current
directory, or somewhere else if you specify it. If the file is already
in the local folder, it can skip redownloading it.

If the module requires additional command line options, like for
external libraries, pragma(lib) or maybe some magic comments in the
file can list them off. In my old makefile generator, I used the
module line:

module whatever; //@ libs(sdl, sdl_audio)

And this would just be passed off to dmd on the command line. It
wouldn't try to download the library or anything.



Would this work? I'm thinking it would do the job of a CPAN that
people ask for every few months and is incredibly simple to implement.
I could take the submitted packages to the central listing and fetch
ddoc off the url too, assuming the same naming convention, and add it
to my simple search engine at dpldocs.info.


More information about the Digitalmars-d mailing list