FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Issue importing hirarchical imported .di files

 
Post new topic   Reply to topic     Forum Index -> Visual D
View previous topic :: View next topic  
Author Message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Sat Jan 14, 2012 6:06 am    Post subject: Issue importing hirarchical imported .di files Reply with quote

Hi,

I have some issues with importing hirarchical ( public ) imported modules within auto generated .di files. So far I've been using D only in combination with VisualD and I am not sure if my problem is D or VisualD related. As a side note, I'm trying to mimic the project structure of Derelict2.
I created a library ( MyLib ) with five modules, all in one Folder ( src ). Two of these modules ( moduleA, moduleB ) are imported in one of the other modules ( moduleParent ).

moduleParent ;

public {
import moduleA ;
import moduleB ;
}

I auto create Interface Files and write them into another Folder ( MyLibProjectDir/import/MyLib ). In the moduleParent.di file I can read the same public { import ... } lines as in moduleParent.d file.
This is the Folder Structure of the Project:

MyLibProjectDir
- src ( all .d files )
- lib ( the MyLib.lib file )
- import/MyLib ( all .di files )

In another ( VisualD ) Project ( MyProject ) I setup the Additional ImportPath to: MyLibProjectDir/import
and to the Library Files Field I add this entry: MyLibProjectDir/lib/MyLib.lib
In some of the source files I import muduleParent from MyLib with:
import MyLib.moduleParent ;

When I compile MyProject, the compiler gives me following error:
Error: module moduleA is in file 'moduleA.d' which cannot be read
Then all the looked up search paths are listed, including MyLibProjectDir/import, where moduleA.di IS located.
MyLibProjectDir/src is not listed, which has the moduleA.d file, but thats what I want, using only the .di files, right ?

Where is my mistake ?
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Tue Jan 17, 2012 5:57 pm    Post subject: Reply with quote

Hi,

the problem has nothing to do with Visual D, but comes from the different usages of the MyLib subdirectory/package.

When compiling MyProject, you are importing MyLib.moduleParent, so you are saying that it is in a package MyLib. But the module declaration and the import don't specify the package. The result is that the "import moduleA" statement cannot find the file with the search paths from MyProject. The compiler is not searching relative to the importing source file.

What you should do is put the source files into src/MyLib and use MyLib.moduleParent, MyLib.moduleA and MyLib.moduleA as the module names and imports.

Personally, I don't use di files at all, they cause too much trouble and don't give enough benefit. I would just import the sources directly.

You also don't need to add the library to MyProject if you set a project dependency on MyLib.

I hope this helps,
Rainer
Back to top
View user's profile Send private message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Wed Jan 18, 2012 3:15 pm    Post subject: Reply with quote

Hi,

what you suggest makes sense, but unfortunately still does not work, with a wired twist:
I put all my source files into src/MyLib ( and re added to my VisualD project ), and in moduleParent.d I import public moduleA and moduleB

public {
import MyLib.moduleA ;
import MyLib.moduleB ;
}

Now I get this error message when I try to build MyLib.lib
src\MyLib\moduleParent.d(14): Error: module modulA is in file 'MyLib\moduleA.d' which cannot be read

After that I tried to add the entry MyLibProjectDir\src to MyLib Additional ImportPath, and get this wired error message:
src\MyLib\moduleParent.d(14): Error: module moduleParent from file FullPathToMyLib\src\MyLib\moduleA.d conflicts with another module moduleA from file src\Engine\moduleA.d

So if I am getting it right the source file is not found, or it is found twice and conflicts with itself ?

Quote:
You also don't need to add the library to MyProject if you set a project dependency on MyLib.

That's fine, I am doing it this way, but I just wanted to learn the process of creating a lib and interface files in the case I want to pass on a closed source library. Its my D learning process Smile
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Wed Jan 18, 2012 3:55 pm    Post subject: Reply with quote

Hi,

If MyLib.visualdproj is in FullPathToMyLib, you should specify "src" as the import path.

From the error messages I suspect that you have not changed the module declaration inside moduleA to MyLib.moduleA. And that you have another module moduleA.d in src/Engine that also declares "module moduleA;" instead of "module Engine.moduleA;".

Rainer
Back to top
View user's profile Send private message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Thu Jan 19, 2012 4:36 am    Post subject: Reply with quote

Hi,

finally, got it, and learned. In such a case I need to manually declare any module of MyLib to:
module MyLib.moduleName ;

everything works perfectly now.

Thank you for all your help and time Smile
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Visual D All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group