aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/util.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-08-04 11:56:03 +0000
committermarha <marha@users.sourceforge.net>2009-08-04 11:56:03 +0000
commite5838b892c8f8041868d3ee08110261cde13e098 (patch)
treef69d9e97a800f62bcf8798199559b0d96abd14a9 /tools/mhmake/src/util.cpp
parente2cafb0970b536247274e86ae949beeb7ab1e814 (diff)
downloadvcxsrv-e5838b892c8f8041868d3ee08110261cde13e098.tar.gz
vcxsrv-e5838b892c8f8041868d3ee08110261cde13e098.tar.bz2
vcxsrv-e5838b892c8f8041868d3ee08110261cde13e098.zip
- Made copy command recursive when copying a directory.
- When -q is specified output nothing. - Solved problem when mhmake is run from inside Visual Studio (output of cl.exe was send directly to the IDE instead of stdout) - Added strip function - Now use the svn info command to get the revision from the working copy. - Removed VC6 solution file.
Diffstat (limited to 'tools/mhmake/src/util.cpp')
-rw-r--r--tools/mhmake/src/util.cpp82
1 files changed, 20 insertions, 62 deletions
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index 2e0b7dea6..824c94b4d 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -255,6 +255,9 @@ refptr<loadedmakefile> LOADEDMAKEFILES::find(const loadedmakefile &ToSearch)
LOADEDMAKEFILES g_LoadedMakefiles;
+bool OsExeCommand(const string &Command,const string &Params,bool IgnoreError,string *pOutput);
+string SearchCommand(const string &Command, const string &Extension="");
+
///////////////////////////////////////////////////////////////////////////////
loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
{
@@ -266,79 +269,34 @@ loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
m_MhMakeConf=GetFileInfo(pEnv);
// Get the revision of the working copy
- // We do it the fastest way: this means just parsing the entries file in the .svn directory of the mhmakeconf directory
- string EntriesFile=m_MhMakeConf->GetFullFileName()+OSPATHSEPSTR".svn"OSPATHSEPSTR"entries";
- FILE *pFile=fopen(EntriesFile.c_str(),"r");
- if (!pFile)
- {
- /* Entries file cannot be opened. Maybe it is not an svn working copy, so ignore it */
- #ifdef _DEBUG
- if (g_PrintAdditionalInfo) cout<<"Warning: Assuming no subversion working copy: Error opening "<<EntriesFile<<endl;
- #endif
- return;
- }
+ // We do it with the svn info command
- /* Check the format of this file, if it is 8 it is the new format else it is the old format. We do
- * this by inspecting the first line of the file
- */
- char Line[255];
- if (fgets(Line,sizeof(Line),pFile))
- {
- int iVersion=atoi(Line);
- if (iVersion<8)
- {
- // This is the old format
- while (fgets(Line,sizeof(Line),pFile))
- {
- if (!strncmp(Line," url=\"",8))
+ string Output;
+ bool Ret;
+ try
{
- char *pUrl=Line+8+7;
- char *pEnd=strchr(pUrl,'"');
- #ifdef _DEBUG
- if (!pEnd)
- {
- cerr<<"Format of entries file in .svn directory must have been changed. Update mhmake!\n";
- exit(1);
+ string SvnCommand=SearchCommand("svn",EXEEXT);
+ Ret=OsExeCommand(SvnCommand,string(" info ")+m_MhMakeConf->GetFullFileName(),false,&Output);
}
- #endif
- *pEnd='\0';
- m_GlobalCommandLineVars[WC_URL]=pUrl;
- }
- if (!strncmp(Line," revision=\"",13))
- {
- char *pRevision=Line+13;
- char *pEnd=strchr(pRevision,'"');
- #ifdef _DEBUG
- if (!pEnd)
+ catch (int)
{
- cerr<<"Format of entries file in .svn directory must have been changed. Update mhmake!\n";
- exit(1);
- }
- #endif
- *pEnd='\0';
- m_GlobalCommandLineVars[WC_REVISION]=pRevision;
- break;
- }
+ Ret=false;
}
- }
- else
+
+ char *pTok=strtok((char*)Output.c_str(),"\n"); // doing this is changing string, so this is very dangerous !!!
+ while (pTok)
{
- /* This is the new format */
- fgets(Line,sizeof(Line),pFile);
- fgets(Line,sizeof(Line),pFile);
- if (fgets(Line,sizeof(Line),pFile))
+ if (!strncmp(pTok,"URL: ",5))
{
- Line[strlen(Line)-1]=0;
- m_GlobalCommandLineVars[WC_REVISION]=Line;
+ m_GlobalCommandLineVars[WC_URL]=pTok+5+7;
}
- if (fgets(Line,sizeof(Line),pFile))
+ else if (!strncmp(pTok,"Revision: ",10))
{
- Line[strlen(Line)-1]=0;
- m_GlobalCommandLineVars[WC_URL]=Line+7;
- }
+ m_GlobalCommandLineVars[WC_REVISION]=pTok+10;
+ break;
}
+ pTok=strtok(NULL,"\n");
}
- fclose(pFile);
}
}