DIP11: Automatic downloading of libraries

Nick Sabalausky a at a.a
Tue Jun 14 20:40:31 PDT 2011


"Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
news:it97ee$ome$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> RDMD never needs to invoke DMD more than twice.
>
> rdmd also doesn't attempt to download libraries.

I know, but that's beside the point. You may need a few invocations of DMD 
or RDMD to *get* dependencies you don't already have (but *at most* only one 
per library, less if any part of the chain has more than one dependency) but 
*once you have them*, then *one* call to DMD will find *all* the files 
needed.

I'll use an example:

MyApp:
  - main.d: Imports 'helper' and 'libA.all'
  - helper.d: Imports 'libB.all'

LibA:
  - libA/all.d: Imports 'libA.util'
  - libA/util.d: Imports nothing of interest.

LibB:
  - libB/all.d: Imports 'libB.baz'
  - libB/baz.d: Imports 'libC'

LibC:
  - libC.d: Imports nothing of interest.

Now, you *only* have the source for MyApp, none of the libs. You built it:

$ nicks-build-tool main.d -of:MyApp.exe
Invoking dmd to find deps of main.d...
    Deps: helper, libA.all, libB.all
    Missing: libA.all, libB.all
Checking if deps can be downloaded...
    libA.all: Exists in LibA
    libB.all: Exists in LibB
Downloading LibA...done
Downloading LibB...done
Invoking dmd to find deps of main.d...
    Deps: helper, libA.all, libB.all,
        libA.util, libB.baz, libC
    Missing: libC
Checking if deps can be downloaded...
    libC.d: Exists in LibC
Downloading LibC...done
Invoking dmd to find deps of main.d...
    Deps: helper, libA.all, libB.all,
        libA.util, libB.baz, libC
    Missing: {none}
Checking if need to rebuild...yes, MyApp.exe missing
Invoking dmd to compile everything...
Done.

Now you make changes to MyApp and want to build again:

$ nicks-build-tool main.d -of:MyApp.exe
Invoking dmd to find deps of main.d...
    Deps: helper, libA.all, libB.all,
        libA.util, libB.baz, libC
    Missing: {none}
Checking if need to rebuild...yes, main.d and helper.d changed.
Invoking dmd to compile everything...
Done.

DMD only needs to be invoked a small handful of times, and only when a 
library is missing.

However, IMO, it would be far better to have dependency metadata for each 
lib/project rather than picking through the source and inferring packages.




More information about the Digitalmars-d mailing list