Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resetting resource locations via command line 1

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
I expected to find these answers via google and I've come up short. So, my apologies if this has been answered elsewhere already.

I've got a project that I've taken over, and the way our licensing works, it is necessary to turn the build process over to administrative people.(But I don't let them build from the IDE directly)

The prior developer had pieces of source scattered all over multiple computers. I've made the build process more flexible, with params for every part.
So when the build runs it copies all requisites to a compile directory, and gets from SVN, then builds it from there.
Some resource paths are relative, and as such are able to be moved and compiled more flexibly. Others, (specifically a compiled .DBF) hangs on to an absolute path.
The old build program used an SVN checkout instead of an SVN get and as such was dependent on the SVN working directory.

I don't want to be tied to that path anymore, but I don't even see that directory listed under 'options'->'file locations'.

How can I, during the cmdline build, specify a new resource path? Or even just clear the old path so that it will look in home directory?
I cannot figure out how to access that Project variable. (even with the UI, the only thing I can think of is to remove it and re-add it.)


Code:
TRY
   MODI PROJ Prg.PJX nowait
   WAIT WINDOW "building EXE from " + cCompileSource+"\Prg.PJX to " + cExeDir+'\'+cExeName+nVersion+"exe..." NOWAIT
   BUILD EXE cExeDir+'\'+cExeName+nVersion FROM cCompileSource+"\Prg.PJX" RECOMPILE 
CATCH TO oErr
   MESSAGEBOX(oErr.Message)
   ! notepad cExeDir+'\'+cExename+'.err'
ENDTRY

Thanks!
-Stephen
 
You need to become familiar with the ProjectHook class.

Code:
MODI PROJ Prg.PJX nowait
oProj = _VFP.ActiveProject
?oProj.Files.Count
FOR EACH oFile IN oProj.Files
  ?oFile.Name
ENDFOR

The Google can probably cough up hundreds of useful ProjectHook examples. We've all done various build hooks. I suspect you'll want the BeforeBuild method in particular.

Also,, remember that projects are just DBFs in drag. All the data commands (like REPLACE) work on them just fine. :)
 
I actually haven't used projecthook in VFP yet.(forgot it exists in v9) I'll play with that Dan, Thanks for the tip.

In the meantime I just removed the offending file and re-added it which I think is working.

Then I realized how simple setting the search paths is and did a [palm:forehead]
SET PATH TO .\source, .\include, .\data, .\libs ADDITIVE (I don't see anyone else using additive in samples.. default?)
 
No, ADDITIVE isn't default. Most examples probably pre-date the existence of ADDITIVE.

However, if you indiscriminately use ADDITIVE the path can get inordinately long (and redundant), and cause performance issues. (Or tip you over the length limit.)

Code:
If Not "\data" $ Lower(Set("PATH"))
   SET PATH TO .... ADDITIVE
Endif

etc.

Practice safe HEX.
 
Thanks again Dan. Good point.
Also made use of your other note..
USE f:\compile\source\prg.pjx EXCLUSIVE
REPLACE ALL homedir WITH ".\source"
REPLACE ALL homedir WITH ".\libs" FOR type = 'V'
REPLACE ALL homedir WITH ".\include" FOR type = 'H' and key != 'ASDF' and key != 'PRG'
REPLACE ALL homedir WITH ".\data" FOR type = 'D' AND key = 'DF'

The libraries don't care about homedir though, so I still have to set paths if they don't reside with the headers.
Build works now at any location.

Thanks!
 
Stephen,

Glad to see you've got it working - with Dan's help.

I can't add much what Dan told you. But regarding SET PATH, the ADDITIVE clause was only introduced in VFP 9.0, which is why you probably didn't know about it. Before that, we had to do something like this:

Code:
lcPath = SET("Path")
lcPath = lcPath + ", Data"
SET PATH TO (lcPath)

One other minor point. You use this code to open the error log:

Code:
! notepad cExeDir+'\'+cExename+'.err'

That's fine. But it's simpler and faster just to MODIFY FILE.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks Mike, helpful as always.

Yeah, I think the reason I ended up using notepad was that I was originally going to let the build program close and just leave notepad visible.
I've got some other information in the build program that is just printed to the screen that I might push to a txt file and just append the error file to the end of that. This way FoxPro can close when it's finished regardless of the error state.

Thanks for all of your help Dan.
 
Just a followup incase someone else ends up using this as reference.
Setting the Path and HomeDir did not fix many of the references. Foxpro actually included the location in the NAME of the reference within the PJX.

Code:
USE f:\compile\source\prg.pjx EXCLUSIVE
Replace ALL name WITH '..\libs\' + RIGHT(name,LEN(name)-rat('\',name)), homedir WITH (cCompileSource) FOR type = 'V'

Unfortunately there were still a handful of libs that included a specific (pseudo relative) path. "..\..\..\..\dev\libs\someheader.h". So without altering each of these directly, my only option was to create that directory for those headers on any partition where this operation might be run. Frustratingly, the headers weren't even necessary for the operation, but they were included and as such had to be located.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top