www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - rdmd bug?

reply CrypticMetaphor <CrypticMetaphor88 gmail.com> writes:
Hello, I'm being driven nuts by this problem, I don't know 100% if it's 
it's a bug or if it's intended behavior, I'm new to D( also new to 
reporting bugs ) so I can't really tell.

Anyway, the problem is, if I call rdmd from outside the folder in which 
the main source resides in, and main includes another file in that 
folder, I get an error.

example:

...\projectfolder\src\main.d
...\projectfolder\src\test.d

// main.d
module main;
import test.d;
void main()
{
	hello();
}
// end main.d
// test.d
module test.d;
import std.stdio;
void hello()
{
	writeln("Hello");
}
// end test.d

// If I'm in a shell, and I do this, I get an error:
...\projectfolder>rdmd src\main.d
src\main.d(2): Error: module test is in file 'test.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

// but if I do this, it works:
...\projectfolder\src>rdmd main.d

...\projectfolder\src>Hello world

// also works
...\projectfolder\src>dmd main.d test.d


Anyway, I want to be able to compile with rdmd from a different folder, 
is this a bug? or should I use a different tool? :-S
*aahhh*

Other info:
OS: Windows
rdmd build 20101220
dmd: 2.050
Dec 19 2010
parent reply Nick Voronin <elfy.nv gmail.com> writes:
On Mon, 20 Dec 2010 01:24:02 +0100
CrypticMetaphor <CrypticMetaphor88 gmail.com> wrote:

 Anyway, the problem is, if I call rdmd from outside the folder in which 
 the main source resides in, and main includes another file in that 
 folder, I get an error.
 // If I'm in a shell, and I do this, I get an error:
 ...\projectfolder>rdmd src\main.d
 src\main.d(2): Error: module test is in file 'test.d' which cannot be read
 import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
 import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
 Anyway, I want to be able to compile with rdmd from a different folder, 
 is this a bug? or should I use a different tool? :-S
 *aahhh*
Add -Ifullpath_to_projectfolder\src. It's the way it works IMHO, if you import something it must be relative to search path or to current dir. There may be a better way (replace current dir with the dir where source is, but it will take away control), but this works. There is a bug though, I can't make it work with -Irelative_path_to_src. Looks like .deps contain paths relative to where rdmd was ran, while dmd interprets them as paths relative to where .deps file is. -- Nick Voronin <elfy.nv gmail.com>
Dec 19 2010
next sibling parent reply CrypticMetaphor <CrypticMetaphor88 gmail.com> writes:
 Add -Ifullpath_to_projectfolder\src. It's the way it works IMHO, if you import
something it must be relative to search path or to current dir. There may be a
better way (replace current dir with the dir where source is, but it will take
away control), but this works.

 There is a bug though, I can't make it work with -Irelative_path_to_src. Looks
like .deps contain paths relative to where rdmd was ran, while dmd interprets
them as paths relative to where .deps file is.
I've tried -I"path to src" but this doesn't work either, but I've found a workaround. I start a batch file that goes to the correct directory and then executes rdmd with the argument(the absolute path) I pass to the batch file, this works :D Thanks for the help! So, should I report this as a bug?
Dec 19 2010
parent CrypticMetaphor <CrypticMetaphor88 gmail.com> writes:
 So, should I report this as a bug?
What am i saying!? of course I should. It annoyed the hell outta me >_< *goes to report*
Dec 19 2010
prev sibling parent spir <denis.spir gmail.com> writes:
On Mon, 20 Dec 2010 04:27:33 +0300
Nick Voronin <elfy.nv gmail.com> wrote:

 On Mon, 20 Dec 2010 01:24:02 +0100
 CrypticMetaphor <CrypticMetaphor88 gmail.com> wrote:
=20
 Anyway, the problem is, if I call rdmd from outside the folder in which=
=20
 the main source resides in, and main includes another file in that=20
 folder, I get an error.
=20
 // If I'm in a shell, and I do this, I get an error:
 ...\projectfolder>rdmd src\main.d
 src\main.d(2): Error: module test is in file 'test.d' which cannot be r=
ead
 import path[0] =3D C:\D\dmd2\windows\bin\..\..\src\phobos
 import path[1] =3D C:\D\dmd2\windows\bin\..\..\src\druntime\import
=20
 Anyway, I want to be able to compile with rdmd from a different folder,=
=20
 is this a bug? or should I use a different tool? :-S
 *aahhh*
=20 Add -Ifullpath_to_projectfolder\src. It's the way it works IMHO, if you i=
mport something it must be relative to search path or to current dir. There= may be a better way (replace current dir with the dir where source is, but= it will take away control), but this works.
=20
 There is a bug though, I can't make it work with -Irelative_path_to_src. =
Looks like .deps contain paths relative to where rdmd was ran, while dmd in= terprets them as paths relative to where .deps file is. Yes, I think it cannot work, since -I is a option of dmd, not of rdmd. rdmd= just passes by options to dmd if I understand correctly. What you want is = to influence a feature provided dy rdmd, not dmd, namely automatic inclusio= n of (non-standard) imports. But sure, it may be a bug: rdmd should look for imports using pathes relati= ve to the location of the (app) module it is given. Or, for simplicity, we = can just state it must be called from this location. Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 20 2010