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

Announce: Dbuild V0.1B

 
Post new topic   Reply to topic     Forum Index -> DSP
View previous topic :: View next topic  
Author Message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Sun Dec 19, 2004 11:38 pm    Post subject: Announce: Dbuild V0.1B Reply with quote

Cross Posted to the DNG
With all the talk around here lately about improvements to dmake, with custom pragmas and such, I thought I should go ahead and let the group know that I too have been working on a similar project. To that end, I've pushed DBuild through to an early beta for public consumption. Since I'm using it in conjunction with my development of DSP, it's available in the same source repo:

http://svn.dsource.org/svn/projects/dsp/trunk/misc/dbuild/
http://svn.dsource.org/svn/projects/dsp/downloads/dbuild.zip

Tip: take a look at the dbuild.id file in case dmd is not on the path.

Feedback is always welcome.


-A Quick Overview-

DBuild, like dmake and digc, navigates a tree of source files from a single root, then launches dmd based on the information it gathers. What is different, is that it more closely matches to 'make' in that one can specify *any* tool to run for a given kind of file.

For example, the following is a configuration statement in Dbuild:
Code:

pragma(tool,"d","obj","$root$\\","dmd $in$ -c -release -of$out$ -od$outdir$");

The parameters (after 'tool') are: source extension, output extension, output directory, and the tool's path/commandline. The dollar-sign expressions are substitutions used to help make tool declarations a little more flexible. For example $root$ is the directory where the tool is started, $in$ is the source file, and $out$ is the output file (composed from $in$, the output extension and the output directory).

All these different parameters are important, since the tool keeps track of tool 'products' as it goes along. This is what enables DBuild to compose a target file.
Code:

pragma(tool,"*","exe","$root$\\","dmd $*.obj$ $*.lib$ -release -of$out$ -od$outdir$");
pragma(target,"myprogram.exe");

These two lines specify a dmd command line for creating an exe, from all the .obj and .lib files garnered from the rest of the source tree. The second pragma, 'target', is the trigger for the use of the '*' rule; it matches based on the output file extension.

To use other files as products for tools in DBuild, simply use the 'dependency' pragma to add them to the product list.
Code:

pragma(dependency,"foo.lib");
pragma(dependency,"exports.def"); // useful for dll compilation

All of this is so that Dbuild remains open-ended for tools aside from dmd. For example, we could build documentation using a tool (ddoc) that would spit out an xml file for each .d file, then complete a cross-reference and html files as an explicit target:
Code:

pragma(tool,"d","xml","$root$\\doc\\","ddoc $in$ -of$out$");
pragma(tool,"*","html","$root$\\doc\\","ddoc $*.xml$ -of$out$");
pragma(target,"$root$\\doc\\index.html");

DBuild makes no assumptions about what libraries to include or exclude. To that end, the 'ignore' statement helps weed out namespaces that you don't want to include in your build. Simply provide the prefix(es) for any namespace and off you go:
Code:

pragma(ignore,"std.");
pragma(ignore,"concurrent.");
pragma(ignore,"mango.");

It also doesn't assume where to find things. Use the 'path' statement to direct dbuild where to go:
Code:

pragma(path,"\\");
pragma(path,"d:\\progra~1\\d\\dmd\\src\\phobos\\");

Also, DBuild honors the 'msg' pragma and will echo these statements to the console while it hides successful tool output.
Code:

pragma(msg,"hello world");

Lastly, these are all (except for 'msg') non-standard pragmas, so enclose them in a version statement to make sure that dmd doesn't trip on them:
Code:

version(dbuild){ /*only dbuild will see this*/ }


-What's Missing & Broken-

At a minimum, dbuild is self-hosting (can build itself) and has been tested against rather tivial source trees. It doesn't take advantage of response files when talking to DMD, so if things fail on large projects, it may be due to limited environment space.

I'm not proud of the tool syntax statements, and would like to improve them for santiy's sake. I'll likely remove the 'from' extension from the delcaration since its barely even used, and will probably use another pragma name to differentiate between a d-sourcefile tool and a target tool. Also, it's not checking the date/time of inputs and outputs in the same fashion as make; its an obvious place to improve things and pick up some speed. Lastly, multiple tool definitions, with the same output extension, do not override correctly.

Lastly: the "_timer" pragmas do not report the correct time, and "_debug" is only so useful.

-Under the Hood-

DBuild uses an experimental D-based spirit library to define enough of the D language grammar to do the job (*). The parsing engine uses these grammar definitions to properly recognize version, debug and pragma statements. It also understands comments and strings, plus the various escape sequences typically found in strings (eg. \n \r \t, etc).

That having been said, the code is an undocumented mess, which is in dire need of refactoring. The DFileParser uses a state-stack class which is a horrid mess of arrays and accessors. The D-Spirit classes need some more testing to ensure proper traversal of a given grammar. Also, the event hooks in the d-grammar need some work to assist readability.

* This was made possible, in no small part, to the minimal Spirit-style library I stumbled upon online some time ago... Ben, was that you? The parser is not templatized in the same manner as the C++ library; its somewhat slower than I would like. Also, the lack of certain operators in D makes for some /very/ interesting grammar definitions.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Sark7



Joined: 02 Jun 2004
Posts: 9
Location: Russia

PostPosted: Mon Mar 21, 2005 7:26 pm    Post subject: DBuild parsing engine Reply with quote

Great work.
One of most interesting projects on DSource.
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Mon Mar 21, 2005 9:24 pm    Post subject: Re: DBuild parsing engine Reply with quote

Sark7 wrote:
Great work.
One of most interesting projects on DSource.


Thank you. Smile

However, I've mothballed dbuild as Derek's "build" utility is vastly superior (not to mention faster). If you're interested in the D-spirit lib I cooked up, let me know and I'll re-add it to the SVN repository.

DSP will be up for another update soon enough.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Sark7



Joined: 02 Jun 2004
Posts: 9
Location: Russia

PostPosted: Tue Mar 22, 2005 6:56 pm    Post subject: D-Spirit rocks! Reply with quote

pragma wrote:
If you're interested in the D-spirit lib I cooked up, let me know and I'll re-add it to the SVN repository.


I am very interested.
Is it mean that you stops development of the D-Spirit?
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Tue Mar 22, 2005 7:51 pm    Post subject: Re: D-Spirit rocks! Reply with quote

Sark7 wrote:
pragma wrote:
If you're interested in the D-spirit lib I cooked up, let me know and I'll re-add it to the SVN repository.


I am very interested.
Is it mean that you stops development of the D-Spirit?


For now, yes.

I'll re-add it to the repository on my next update. Eventually, it may get its own project. Wink
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DSP 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