www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to get 'import' clauses from d file?

reply "Alex Khmara" <alex.khmara gmail.com> writes:
Hello!

I'm trying to make some home-grown d build system, but and one of my tasks
is to get module dependencies. Yes, I know about -deps DMD switch, but it  
works
when all needed modules are given to compiler. But if some dependencies  
absent compiler
just aborts with error "module foo is in file "foo.d"  that can not be  
read".
Of course, I can extract "foo" from this string, deal with it and repeat,  
but working
one module at a time is not a much fun. Seems like I need to parse d  
source and extract
"import" clauses without compiler help - but may be I missed something?  
And if not -
what tools can I use for parsing?
Jan 15 2011
parent Trass3r <un known.com> writes:
 I'm trying to make some home-grown d build system, but and one of my  
 tasks
 is to get module dependencies. Yes, I know about -deps DMD switch, but  
 it works
 when all needed modules are given to compiler. But if some dependencies  
 absent compiler
 just aborts with error "module foo is in file "foo.d"  that can not be  
 read".
 Of course, I can extract "foo" from this string, deal with it and  
 repeat, but working
 one module at a time is not a much fun. Seems like I need to parse d  
 source and extract
 "import" clauses without compiler help - but may be I missed something?  
 And if not -
 what tools can I use for parsing?

You might look up how xfBuild uses the deps parameter to get all needed modules.
Jan 15 2011