www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - New to D: Building multiple files

reply chris <cmjreyes gmail.com> writes:
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


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
Mar 29 2009
next sibling parent reply Trass3r <mrmocool gmx.de> writes:
How do you import the modules?
You must specify the correct name, i.e. import clo.clo;

Oh and you should get familiar with the dsss.conf file.
This is the way you normally build your project.
http://www.dsource.org/projects/dsss/wiki/DSSSForSoftwareEngineers
Mar 29 2009
parent reply chris <cmjreyes gmail.com> writes:
The file clo.d is in module clo; while GameState is in module
slo.common;

I just import clo; and import clo.common; when using stuff in either
of those files, I hope that's correct.

Also thanks for the link, I was going to ask about .conf files.
Mar 29 2009
parent Trass3r <mrmocool gmx.de> writes:
chris schrieb:
 The file clo.d is in module clo; while GameState is in module
 slo.common;
 
you probably mean it is in package clo.
 Also thanks for the link, I was going to ask about .conf files.
You're welcome.
Mar 29 2009
prev sibling next sibling parent reply torhu <no spam.invalid> writes:
On 29.03.2009 17:04, 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

[...]
 C:\Users\me\Projects\clo>  dsss build -v Main.d clo.d commo
 n\GameState.d
I don't know if dsss supports building without a config file. Just doing 'rebuild Main.d' should work. Or 'dmd Main.d clo.d common\GameState.d'. Make sure that Gamestate.d has a 'module common.GameState;' declaration.
Mar 29 2009
parent Jesse Phillips <jessekphillips gmail.com> writes:
On Sun, 29 Mar 2009 17:43:51 +0200, torhu wrote:

 On 29.03.2009 17:04, 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

[...]
 C:\Users\me\Projects\clo>  dsss build -v Main.d clo.d commo
 n\GameState.d
I don't know if dsss supports building without a config file. Just doing 'rebuild Main.d' should work. Or 'dmd Main.d clo.d common\GameState.d'. Make sure that Gamestate.d has a 'module common.GameState;' declaration.
Yes DSSS can build without a conf file. I think it basically passes the command to rebuild.
Apr 01 2009
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
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

 
 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.
Mar 29 2009
parent chris <cmjreyes gmail.com> writes:
Yea I just realized it follows the directory structure and not some
arbitrary system I made up.

Thanks for the .config info, I was just putting one together of
similar structure, this'll absolutely help.

Much appreciated
Mar 29 2009