www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - building a D app with multiple source files

reply "nikki" <nikkikoole gmail.com> writes:
Hello, I am completely new to D and have been paying around with
the tutorials, some docs and little test programs.

Now I want to try and use https://github.com/elvisxzhou/artemisd
for little gamedev experiment but I am running into build issues.
That project doesn't have a Makefile in the repo, and I am on
linux so I need to build it on the terminal,

I've read about rdmd (and tried it without success) and found a
few 'general' usage Makefiles, can't get any to just work when I
type 'make all'.

in the repo I linked to (artemisd) there are dozens of source
files in various folders, and an example i have to compile at the
same time I think.

could someone show me how it's done ?
Aug 05 2014
next sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 5 August 2014 at 07:27:18 UTC, nikki wrote:
 Hello, I am completely new to D and have been paying around with
 the tutorials, some docs and little test programs.

 Now I want to try and use https://github.com/elvisxzhou/artemisd
 for little gamedev experiment but I am running into build 
 issues.
 That project doesn't have a Makefile in the repo, and I am on
 linux so I need to build it on the terminal,

 I've read about rdmd (and tried it without success) and found a
 few 'general' usage Makefiles, can't get any to just work when I
 type 'make all'.

 in the repo I linked to (artemisd) there are dozens of source
 files in various folders, and an example i have to compile at 
 the
 same time I think.

 could someone show me how it's done ?
What issues have you had with rdmd? The library seems to have a package.json file, so you could also try dub: http://code.dlang.org/download
Aug 05 2014
parent reply "nikki" <nikkikoole gmail.com> writes:
 What issues have you had with rdmd?

 The library seems to have a package.json file, so you could 
 also try dub:
 http://code.dlang.org/download
nikki crunchbang:~/projects/d/artemisd$ rdmd example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"] nikki crunchbang:~/projects/d/artemisd$ rdmd --makedepend example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"]
Aug 05 2014
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 5 August 2014 at 07:43:56 UTC, nikki wrote:
 What issues have you had with rdmd?

 The library seems to have a package.json file, so you could 
 also try dub:
 http://code.dlang.org/download
nikki crunchbang:~/projects/d/artemisd$ rdmd example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"] nikki crunchbang:~/projects/d/artemisd$ rdmd --makedepend example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"]
The search path does not include the artemisd package. Try: cd .. && rdmd artemisd/example/source/app.d Or : rdmd -I.. example/source/app.d
Aug 05 2014
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 5 August 2014 at 07:46:05 UTC, Vladimir Panteleev 
wrote:
 On Tuesday, 5 August 2014 at 07:43:56 UTC, nikki wrote:
 What issues have you had with rdmd?

 The library seems to have a package.json file, so you could 
 also try dub:
 http://code.dlang.org/download
nikki crunchbang:~/projects/d/artemisd$ rdmd example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"] nikki crunchbang:~/projects/d/artemisd$ rdmd --makedepend example/source/app.d example/source/app.d(5): Error: module all is in file 'artemisd/all.d' which cannot be read import path[0] = example/source import path[1] = /usr/include/dmd/phobos import path[2] = /usr/include/dmd/druntime/import Failed: ["dmd", "-v", "-o-", "example/source/app.d", "-Iexample/source"]
The search path does not include the artemisd package. Try: cd .. && rdmd artemisd/example/source/app.d Or : rdmd -I.. example/source/app.d
Correction: rdmd -Isource example/source/app.d
Aug 05 2014
parent reply "nikki" <nikkikoole gmail.com> writes:
 Correction:

 rdmd -Isource example/source/app.d
that one worked, woohoo thanks. what did the -Isource do? it's not in the 'rdmd --help'
Aug 05 2014
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 5 August 2014 at 07:51:53 UTC, nikki wrote:
 Correction:

 rdmd -Isource example/source/app.d
that one worked, woohoo thanks. what did the -Isource do? it's not in the 'rdmd --help'
You'll find it in dmd's --help. It adds the "source" directory to the search path, the list of directories where the compiler looks for imported modules.
Aug 05 2014
parent reply "nikki" <nikkikoole gmail.com> writes:
On Tuesday, 5 August 2014 at 07:57:57 UTC, Vladimir Panteleev 
wrote:
 On Tuesday, 5 August 2014 at 07:51:53 UTC, nikki wrote:
 Correction:

 rdmd -Isource example/source/app.d
that one worked, woohoo thanks. what did the -Isource do? it's not in the 'rdmd --help'
You'll find it in dmd's --help. It adds the "source" directory to the search path, the list of directories where the compiler looks for imported modules.
edit: couldn't find that flag in dmd --help (only -Ipath), atleast I know what it does now, hope I'll remember.. thanks a lot though great helpful community
Aug 05 2014
next sibling parent reply Mike Parker <aldacron gmail.com> writes:
On 8/5/2014 5:06 PM, nikki wrote:
 On Tuesday, 5 August 2014 at 07:57:57 UTC, Vladimir Panteleev wrote:
 On Tuesday, 5 August 2014 at 07:51:53 UTC, nikki wrote:
 Correction:

 rdmd -Isource example/source/app.d
that one worked, woohoo thanks. what did the -Isource do? it's not in the 'rdmd --help'
You'll find it in dmd's --help. It adds the "source" directory to the search path, the list of directories where the compiler looks for imported modules.
edit: couldn't find that flag in dmd --help (only -Ipath), atleast I know what it does now, hope I'll remember.. thanks a lot though great helpful community
The switch itself is -I, not -Ipath. 'path' indicates a parameter for which you need to substitute something, in this case a directory path. It should be the root folder for the source modules you want to add to the search path. In this case, for artemisd, the source files are in the 'source' directory, so -Isource is what you pass to dmd. If the directory were named 'foo' instead, you would pass -Ifoo. --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Aug 05 2014
parent "nikki" <nikkikoole gmail.com> writes:
 The switch itself is -I, not -Ipath. 'path' indicates a 
 parameter for which you need to substitute something, in this 
 case a directory path. It should be the root folder for the 
 source modules you want to add to the search path. In this 
 case, for artemisd, the source files are in the 'source' 
 directory, so -Isource is what you pass to dmd. If the 
 directory were named 'foo' instead, you would pass -Ifoo.
aha! that would've bitten me in the future, now I get it, thanks.
Aug 05 2014
prev sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 5 August 2014 at 08:06:57 UTC, nikki wrote:
 edit: couldn't find that flag in dmd --help (only -Ipath), 
 atleast I know what it does now, hope I'll remember..
 thanks a lot though   great helpful community
Remember rdmd is just a program to help collect and organise parameters. It still passes everything to dmd. In fact if you use the --chatty option with rdmd it will show you everything it is doing including what it is passing to dmd.
Aug 05 2014
prev sibling parent reply "nikki" <nikkikoole gmail.com> writes:
edit : btw, I understand how to build an app that conscists out 
of a few source files, I'd just do 'dmd file1.d file2.d' I 
amtalking here about the situation where that's unpractical 
because of the amount and folder structure.
Aug 05 2014
next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 5 August 2014 at 07:29:46 UTC, nikki wrote:
 edit : btw, I understand how to build an app that conscists out 
 of a few source files, I'd just do 'dmd file1.d file2.d' I 
 amtalking here about the situation where that's unpractical 
 because of the amount and folder structure.
With rdmd, simply run `rdmd --build-only mainfile.d` (mainfile.d being the file that contains the "main" function). Omit --build-only to build the program to a temporary directory, then run it.
Aug 05 2014
prev sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 5 August 2014 at 07:29:46 UTC, nikki wrote:
 edit : btw, I understand how to build an app that conscists out 
 of a few source files, I'd just do 'dmd file1.d file2.d' I 
 amtalking here about the situation where that's unpractical 
 because of the amount and folder structure.
You can take a look at the dub build tool to automate all this (as mentioned above). Dub works by compiling and linking everything together in your source folder. You specify the main entry point in a dub.json file. It's pretty easy to use and good for handling dependencies over the internet. To compile things manually you can use rdmd to automatically parse the files that need compiling. When using rdmd you only need to specify the file that contains the main function to build everything around it. for example: rdmd program.d This will pull in all imports inside program.d and compile and link them too.
Aug 05 2014