Page 1 of 1

running same tool with differing initial directories

Posted: Wed Oct 22, 2003 4:07 pm
by dvheuvel
I have duplicate code trees that differ only (for the most part) in the "root" of the code tree. When I'm working on a file and invoke a tool from treeA, I'd like the tool in the root of treeA to be run. When editing a file in treeB, I'd like the tool in the root of treeB to be run.

example:

c:\treeA\x\y\z\myfile.java
c:\treeB\x\y\z\myfile.java

and the I have the follwing batch files:
c:\treeA\mytool.bat
c:\treeB\mytool.bat

in my tool setup, the command to be run is simply mytool.bat but I want the initial folder to be either c:\treeA or c:\treeB depending on which version of myfile.java I'm editing.
$Filedir doesn't work because it will give me the entire c:\treeA\x\y\z or c:\treeB\x\y\z

$Filedir\..\..\.. doesn't work for me (although it would in this case) since working on another file in a different path that doesn't have the same number of directories won't work.

can I run a regex on $Filedir to extract out the root? or would the tool parameter macros have to support it explicitly? something like $filedir[1] = c:\treeA or $filedir[2]=c:\treeA\x etc. etc.

ideas anyone?

Posted: Wed Oct 22, 2003 4:20 pm
by dvheuvel
I suppose I could maintain 2 workspaces. One in c:\treeA and on in c:\treeB and use the $wspdir macro.

not what I was looking for though.

Posted: Wed Oct 22, 2003 5:14 pm
by s_reynisson
Define a tool for each code tree?

I'm I missing something? Oh well, it's not the first time :oops:

Posted: Wed Oct 22, 2003 7:25 pm
by bbadmin
How about passing $FileDir as an extra parameter to a common batch file, which parses the path and calls the correct mytool.bat file?

Keith MacDonald
Helios Software Solutions

Posted: Wed Oct 22, 2003 8:08 pm
by dvheuvel
having multiple tools is not what I wanted since I have to keep updating them as I move code trees. might have 4 or more on the go at anyone time. having multiple tools would work, but I think it's the brute force method :) this may be the way I have to go...

Keith,
I considered the batch file method, but my tool returns a pathname, relative to my rootpath (in my case c:\treeA). Double clicking on the command window will parse the out the filename, but wouldn't the load the file since the parsed path is relative to c:\treeA and the initial folder (tool setting) is a different directory.

The batch file in question is actually just a grep of a TAGS file I make prior to running the tool (70Meg). So I can't append the rootdir to the command output (easily)

example:
tool: mytool.bat $filedir
initial folder: c:\

output:
x\y\z\someotherfile.java

which I can no longer click on to load the file since the initial folder is c:\ not c:\treeA

am I making sense?