Ian MacLean wrote:
Gert Driesen wrote:
Actually whenever we load a file we store the location map - mapping each xml node to a file and line-number. So the information is there - the major issue I see is that you would need to obtain the task/Target object that is being referenced at the function call site. So in the example above :
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Jansen
Sent: vrijdag 3 december 2004 17:19
To: [EMAIL PROTECTED]
Subject: [nant-dev] <include> task question
Hi again,
I have a question about the <include> task and the project::get-buildfile-path() function.
I would like to know if there is a way to get the path of an included build file, rather than the containing build file, from withing the included file.
Example:
C:\folder\project.build ----------------------- <project> <include buildfile="..\include.build" /> </project>
C:\include.build ----------------------- <project> <echo message="${project::get-buildfile-path()}" /> </project>
In this case, the message display is "C:\folder\project.build", but, I need to find a way to have a function return "C:\include.build".
Any suggestions?
As far as I know this is not possible.
Ian: do you have anything to add to this ?
<snip> a bunch of unnecessarily complicated stuff </snip>
It turns out its actually quite simple. We already pass a Location reference when we expand properties ( ie when functions get evaluated )
Properties.ExpandProperties(attributeValue, Location);
This Location object contains the path of file where that property was defined. So its not too hard to pass that location on to the FunctionSet classes via their constructor. I have this working locally
such that :
<project name="include" >
<echo message="this file is :${project::get-buildfile-path()}" />
<echo message="main file is: ${project::get-master-buildfile-path()}" /> </project>
when included in another file called "Simple.build" produces :
Buildfile: file:///K:/dev/test/csharp/GetBuildFileTest/Simple.build Target(s) specified: run
[echo] this file is :K:\dev\test\csharp\GetBuildFileTest\include.build [echo] main file is: K:\dev\test\csharp\GetBuildFileTest\Simple.build
Now i just have a question on the naming. Should we :
A) keep get-buildfile-path() as it is returning the the including file and add a get-current-file-path() function or
B) change get-buildfile-path() to return the current file and add a project::get-master-buildfile-path() function to return the including (ie master ) file .
( as demonstrated above )
Ian
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers