New to D: Building multiple files

Mike Parker aldacron at gmail.com
Sun Mar 29 18:24:54 PDT 2009


chris wrote:
> Alright so I'm not too familiar with building D or having to build
> multiple files from the command line (Java usually takes care of
> that). Basically I have a small game I put together as  a test
> project. Here's the structure:
> 
> clo/clo.d
> clo/Main.d
> clo/common/GameState.d
> 
> clo is in module clo , while GameState is in module clo.common.
> 
> Main.d imports both clo and clo.common
> 
> I'm using the latest 'Easy D' installation on windows (so I've been
> building simple single files with dsss build (filename). I'm just
> assuming building Main.d would grab the other stuff and build that
> (like Java or C#), but I get the following.
> 
> C:\Users\me\Projects\clo> dsss build Main.d
> Main.d => Main
> + C:\dmd\dsss\bin\rebuild.exe -Idsss_imports\ -I. -S.\ -
> IC:\dmd\dsss\include\d -
> SC:\dmd\dsss\lib\  -IC:\dmd\dsss\include\d -SC:\dmd\dsss\lib  -
> oqdsss_objs\D  Ma
> in.d -ofMain
> Command C:\dmd\dsss\bin\rebuild.exe returned with code 1, aborting.
> Error: Command failed, aborting.
> 
> Listing all the files to build doesn't prove to be much better:
> 
> C:\Users\me\Projects\clo> dsss build -v Main.d clo.d commo
> n\GameState.d
> Main.d => Main
> + C:\dmd\dsss\bin\rebuild.exe -Idsss_imports\ -I. -S.\ -
> IC:\dmd\dsss\include\d -
> SC:\dmd\dsss\lib\ -v  -IC:\dmd\dsss\include\d -SC:\dmd\dsss\lib  -
> oqdsss_objs\D
>  Main.d -ofMain
> parse     Main
> meta      Main
> import    clo   (clo.d)
> Command C:\dmd\dsss\bin\rebuild.exe returned with code 1, aborting.
> Error: Command failed, aborting.
> 
> (I jsut guessed -v was verbose)
> 
> Any help/suggestions would be greatly appreciated.
> 
> Thanks

I think the problem here is that you are trying to build from within the 
package hierarchy. Your imports aren't being found because the compiler 
(or DSSS?) is searching for clo\clo\clo.d and 
clo\clo\common\GameState.d. You have two options.

1) CD one level up to C:\Users\me\Projects and run the command like so:

dsss build clo/Main.d

2) stay where you are and tell the compiler where to find the imports 
via the -I switch (sort of like the Java classpath)

dsss build Main.d -I..

Using .. here will cause it to look in C:\Users\me\Projects for the clo 
hierarchy.

I second the recommendation that you start using DSSS configuration 
files to manage project builds. I tend to structure my D projects like so:

- ProjectName
     - src  (project-specific package tree)
         - MyPackage
             - MySubPackage
             - AnotherSubPackage
     - import (third-party packages)
         - libPackage (like, maybe, derelict)
         - anotherLibPackage
     - dist (the binary and other distributables)

Then, in the ProjectName directory, I keep a dsss.conf file with the 
build configuration. Something like this:

[src/MyPackage/Main.d]
target=dist/MyApp
buildflags=-Iimport -clean

Then, from the ProjectName directory I just run

dsss build

DSSS reads the configuration file and does its thing.



More information about the Digitalmars-d-learn mailing list