aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/util.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-09-12 11:38:41 +0200
committermarha <marha@users.sourceforge.net>2013-09-12 11:40:36 +0200
commit5a54fa6e45ee10cf58ee1b6d2eb5522a24bb8745 (patch)
tree02781984e9417bc04a726fcb7ac6cf17f8169920 /tools/mhmake/src/util.cpp
parentaf858aeb7348909e334cfd0db0070e1661df00fc (diff)
downloadvcxsrv-5a54fa6e45ee10cf58ee1b6d2eb5522a24bb8745.tar.gz
vcxsrv-5a54fa6e45ee10cf58ee1b6d2eb5522a24bb8745.tar.bz2
vcxsrv-5a54fa6e45ee10cf58ee1b6d2eb5522a24bb8745.zip
Some minor modifications
Ignore pipe symbols when in dependency list Solved some linking problems in linux Solved problem calling svn info when using svn version from cygwin
Diffstat (limited to 'tools/mhmake/src/util.cpp')
-rw-r--r--tools/mhmake/src/util.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index 9fe006e95..e1fcf0d27 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -335,92 +335,92 @@ refptr<loadedmakefile> LOADEDMAKEFILES::find(const loadedmakefile &ToSearch)
return refptr<loadedmakefile>();
}
-LOADEDMAKEFILES g_LoadedMakefiles;
-
///////////////////////////////////////////////////////////////////////////////
-loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
+bool loadedmakefile::loadedmakefile_statics::GetSvnRevision(void)
{
- m_GlobalCommandLineVars[MAKE]=g_MakeCommand;
- const char *pEnv=getenv(MHMAKECONF);
- if (pEnv)
- {
- m_MhMakeConf=GetAbsFileInfo(pEnv);
- m_GlobalCommandLineVars[MHMAKECONF]=QuoteFileName(m_MhMakeConf->GetFullFileName());
+ // Get the revision of the working copy
+ // We do it with the svn info command (do it without path arguments, only current directory, to avoid problems with path names and junctions/links
- // Get the revision of the working copy
- // We do it with the svn info command
+ string Output;
+ try
+ {
+ mhmakefileparser Dummy(m_MhMakeConf);
+ string SvnCommand=Dummy.SearchCommand("svn",EXEEXT);
+ Dummy.OsExeCommand(SvnCommand,string(" info"),false,&Output);
+ }
+ catch (string Message)
+ {
+ #ifdef _DEBUG
+ cerr << "Exception: " << Message << endl;
+ #endif
+ }
- string Output;
- try
+ char *pTok=strtok((char*)Output.c_str(),"\n"); // doing this is changing string, so this is very dangerous !!!
+ while (pTok)
+ {
+ if (!strncmp(pTok,"URL: ",5))
{
- mhmakefileparser Dummy(curdir::GetCurDir());
- string SvnCommand=Dummy.SearchCommand("svn",EXEEXT);
- #ifdef WIN32
- if (GetFileAttributes(m_MhMakeConf->GetFullFileName().c_str())&FILE_ATTRIBUTE_REPARSE_POINT)
- {
- WIN32_FIND_DATA FindData;
- HANDLE hFind=FindFirstFile(m_MhMakeConf->GetFullFileName().c_str(),&FindData);
- if (hFind!=INVALID_HANDLE_VALUE)
- {
- if (FindData.dwReserved0==IO_REPARSE_TAG_MOUNT_POINT)
- {
- HANDLE hDir = ::CreateFile(m_MhMakeConf->GetFullFileName().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
-
- BYTE buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; // We need a large buffer
- REPARSE_MOUNTPOINT_DATA_BUFFER& ReparseBuffer = (REPARSE_MOUNTPOINT_DATA_BUFFER&)buf;
- DWORD dwRet;
-
- if (::DeviceIoControl(hDir, FSCTL_GET_REPARSE_POINT, NULL, 0, &ReparseBuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &dwRet, NULL))
- {
- // Success
- ::CloseHandle(hDir);
-
- LPCWSTR pPath = ReparseBuffer.ReparseTarget;
- if (wcsncmp(pPath, L"\\??\\", 4) == 0) pPath += 4; // Skip 'non-parsed' prefix
- char szPath[MAX_PATH];
- ::WideCharToMultiByte(CP_ACP, 0, pPath, -1, szPath, MAX_PATH, NULL, NULL);
- Dummy.OsExeCommand(SvnCommand,string(" info ")+GetFileInfo(szPath,m_MhMakeConf->GetDir())->GetQuotedFullFileName(),false,&Output);
- }
- else
- { // Error
- ::CloseHandle(hDir);
- }
- }
- FindClose(hFind);
- }
- }
- #else
- struct stat Stat;
- lstat(m_MhMakeConf->GetFullFileName().c_str(),&Stat);
- if (S_ISLNK(Stat.st_mode))
- {
- char FileName[1024];
- int len=readlink(m_MhMakeConf->GetFullFileName().c_str(),FileName,sizeof(FileName));
- FileName[len]=0;
- Dummy.OsExeCommand(SvnCommand,string(" info ")+GetFileInfo(FileName,m_MhMakeConf->GetDir())->GetQuotedFullFileName(),false,&Output);
- }
- #endif
- else
- Dummy.OsExeCommand(SvnCommand,string(" info ")+m_MhMakeConf->GetQuotedFullFileName(),false,&Output);
+ m_GlobalCommandLineVars[WC_URL]=pTok+5+7;
}
- catch (string Message)
+ else if (!strncmp(pTok,"Revision: ",10))
{
+ m_GlobalCommandLineVars[WC_REVISION]=pTok+10;
+ return true;
}
+ pTok=strtok(NULL,"\n");
+ }
+ return false;
+}
- char *pTok=strtok((char*)Output.c_str(),"\n"); // doing this is changing string, so this is very dangerous !!!
- while (pTok)
+///////////////////////////////////////////////////////////////////////////////
+bool loadedmakefile::loadedmakefile_statics::GetGitSvnRevision(void)
+{
+ // Get the revision of the working copy
+ // We do it with the svn info command
+
+ string Output;
+ try
+ {
+ mhmakefileparser Dummy(m_MhMakeConf);
+ string GitCommand=Dummy.SearchCommand("git",EXEEXT);
+ Dummy.OsExeCommand(GitCommand,string(" svn info ."), false, &Output);
+ }
+ catch (string Message)
+ {
+ #ifdef _DEBUG
+ cerr << "Exception: " << Message << endl;
+ #endif
+ }
+
+ char *pTok=strtok((char*)Output.c_str(),"\n"); // doing this is changing string, so this is very dangerous !!!
+ while (pTok)
+ {
+ if (!strncmp(pTok,"URL: ",5))
{
- if (!strncmp(pTok,"URL: ",5))
- {
- m_GlobalCommandLineVars[WC_URL]=pTok+5+7;
- }
- else if (!strncmp(pTok,"Revision: ",10))
- {
- m_GlobalCommandLineVars[WC_REVISION]=pTok+10;
- break;
- }
- pTok=strtok(NULL,"\n");
+ m_GlobalCommandLineVars[WC_URL]=pTok+5+7;
+ }
+ else if (!strncmp(pTok,"Revision: ",10))
+ {
+ m_GlobalCommandLineVars[WC_REVISION]=pTok+10;
+ return true;
}
+ pTok=strtok(NULL,"\n");
+ }
+ return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
+{
+ m_GlobalCommandLineVars[MAKE]=g_MakeCommand;
+ const char *pEnv=getenv(MHMAKECONF);
+ if (pEnv)
+ {
+ m_MhMakeConf=GetAbsFileInfo(pEnv);
+ m_GlobalCommandLineVars[MHMAKECONF]=QuoteFileName(m_MhMakeConf->GetFullFileName());
+
+ if (!GetSvnRevision())
+ GetGitSvnRevision();
}
}