aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mhmake/src')
-rw-r--r--tools/mhmake/src/curdir.cpp3
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp2
-rw-r--r--tools/mhmake/src/mhmakelexer.l28
-rw-r--r--tools/mhmake/src/mhmakeparser.y7
-rw-r--r--tools/mhmake/src/rule.cpp1
-rw-r--r--tools/mhmake/src/util.cpp150
-rw-r--r--tools/mhmake/src/util.h39
7 files changed, 142 insertions, 88 deletions
diff --git a/tools/mhmake/src/curdir.cpp b/tools/mhmake/src/curdir.cpp
index b87dc4f6f..d2b43ab52 100644
--- a/tools/mhmake/src/curdir.cpp
+++ b/tools/mhmake/src/curdir.cpp
@@ -23,9 +23,12 @@
#include "fileinfo.h"
#include "curdir.h"
#include "util.h"
+#include "mhmakeparser.hpp"
fileinfos g_FileInfos; // declare here since it is important that it is constructed before m_pcurrentdir
curdir::initcurdir curdir::m_pCurrentDir;
+loadedmakefile::loadedmakefile_statics loadedmakefile::sm_Statics; // Declare this here because this constructor is using g_FileInfos and m_pCurrentDir
+LOADEDMAKEFILES g_LoadedMakefiles; // Declare it here otherwize problems in the destructor (still using items from g_FileInfos)
///////////////////////////////////////////////////////////////////////////////
curdir::initcurdir::initcurdir()
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index 4a50d6edd..0731d1ce9 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -379,7 +379,7 @@ void mhmakefileparser::SplitToItems(const string &String,vector<fileinfo*> &Item
{
string Item;
pTmp=NextItem(pTmp,Item);
- if (!Item.empty())
+ if (!Item.empty() && Item!="|")
{
Items.push_back(GetFileInfo(Item,m_MakeDir));
}
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l
index 9b933c305..e336fefbf 100644
--- a/tools/mhmake/src/mhmakelexer.l
+++ b/tools/mhmake/src/mhmakelexer.l
@@ -255,6 +255,20 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
+[ \t]*\|[ \t]*\\[ \t\r]*\n[ \t]* {
+ PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),lineno(),yytext));
+ inclineno();
+ yylval->theString=" | ";
+ return yy::mhmakeparser::token::PIPE;
+}
+
+[ \t]*\|[ \t]* {
+ PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),lineno(),yytext));
+ yylval->theString=" | ";
+ return yy::mhmakeparser::token::PIPE;
+}
+
+ /*---------------------------------------------------------------------------*/
[ \t]*=[ \t]*\\[ \t\r]*\n[ \t]* {
PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),lineno(),yytext));
inclineno();
@@ -680,7 +694,7 @@ export {
}
/*---------------------------------------------------------------------------*/
-([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#|\\\")+\\[ \t\r]*\n {
+([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*]|\\\ |\\#|\\\"|\|)+\\[ \t\r]*\n {
size_t EndIndex=yyleng;
while (strchr(" \t\r\n\\",yytext[--EndIndex]));
yyless(EndIndex+1);
@@ -690,14 +704,14 @@ export {
return yy::mhmakeparser::token::STRING;
}
-([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#|\\\")+\+= {
+([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*]|\\\ |\\#|\\\"|\|)+\+= {
PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),lineno(),yytext));
yyless(yyleng-2);
yylval->theString=(const char *)yytext;
return yy::mhmakeparser::token::STRING;
}
-([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|\[\]]|\\\ |\\#|\\\")+ {
+([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\[\]]|\\\ |\\#|\\\"|\|)+ {
PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),lineno(),yytext));
yylval->theString=(const char *)yytext;
return yy::mhmakeparser::token::STRING;
@@ -841,8 +855,8 @@ export {
/*---------------------------------------------------------------------------*/
<QUOTE>\r /* skip */
-<QUOTE>[^\\\"\r\n$]+ |
-<QUOTE>[\\\$] |
+<QUOTE>[^\\\"\r\n$]+ |
+<QUOTE>[\\\$] |
<QUOTE>\\\" |
<QUOTE>\\# {
yymore();
@@ -860,8 +874,8 @@ export {
<SINGLEQUOTE>\r /* skip */
<SINGLEQUOTE>[^\\\'\r\n$]+ |
-<SINGLEQUOTE>[\\\$] |
-<SINGLEQUOTE>\\\' |
+<SINGLEQUOTE>[\\\$] |
+<SINGLEQUOTE>\\\' |
<SINGLEQUOTE>\\# {
yymore();
}
diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y
index d8edb1d51..f9042f780 100644
--- a/tools/mhmake/src/mhmakeparser.y
+++ b/tools/mhmake/src/mhmakeparser.y
@@ -52,7 +52,7 @@ const char Test[]="dit is een test";
%token END 0 "end of file"
%token <theString> COMMAND
%token <theString> COMMA
-%token <theString> STRING DOLLAREXPR EQUAL COLON DOUBLECOLON VARDEF VARVAL
+%token <theString> STRING DOLLAREXPR PIPE EQUAL COLON DOUBLECOLON VARDEF VARVAL
%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE VPATH ENVVARS_TOIGNORE
%type <theString> expression nonspaceexpression simpleexpression
@@ -136,8 +136,8 @@ ruledef: expression_nocolorequal rulecolon maybeemptyexpression
throw string("Empty left hand side in rule: ") + $1 + " : " + $3;
}
#endif
- m_pMakefile->SplitToItems(m_pMakefile->ExpandExpression($1),*m_pMakefile->m_pCurrentItems);
- m_pMakefile->SplitToItems(m_pMakefile->ExpandExpression($3),*m_pMakefile->m_pCurrentDeps);
+ m_pMakefile->SplitToItems(m_pMakefile->ExpandExpression($1), *m_pMakefile->m_pCurrentItems);
+ m_pMakefile->SplitToItems(m_pMakefile->ExpandExpression($3), *m_pMakefile->m_pCurrentDeps);
m_pMakefile->m_DoubleColonRule= ($2==1) ;
PRINTF(("Defining rule %s : %s\n",$1.c_str(),$3.c_str()));
PRINTF((" Expanded to %s : %s\n",m_pMakefile->ExpandExpression($1).c_str(),m_pMakefile->ExpandExpression($3).c_str()));
@@ -286,6 +286,7 @@ nonspaceexpression_nocolorequal: simpleexpression_nocolorequal |
;
simpleexpression: simpleexpression_nocolorequal |
+ PIPE |
EQUAL |
COLON |
DOUBLECOLON |
diff --git a/tools/mhmake/src/rule.cpp b/tools/mhmake/src/rule.cpp
index 35884e2f0..b3f682e95 100644
--- a/tools/mhmake/src/rule.cpp
+++ b/tools/mhmake/src/rule.cpp
@@ -32,7 +32,6 @@ vector<implicitrule_t> IMPLICITRULE::m_ImplicitRules;
makecommand g_MakeCommand; // Order is important since sm_Statics is using g_MakeCommand
const string g_QuoteString("\""); // Order is important since sm_Statics is using g_QuoteString
-loadedmakefile::loadedmakefile_statics loadedmakefile::sm_Statics;
///////////////////////////////////////////////////////////////////////////////
static bool FindDep(fileinfo *pTarget, implicitruledep_t *pImplicitRule,refptr<rule> &Rule)
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();
}
}
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index b1a18c3ed..01e766520 100644
--- a/tools/mhmake/src/util.h
+++ b/tools/mhmake/src/util.h
@@ -50,7 +50,7 @@
#define PLATFORM "linux"
#endif
-#define MHMAKEVER "3.0.21"
+#define MHMAKEVER "3.0.25"
class makecommand
{
@@ -66,6 +66,24 @@ public:
extern makecommand g_MakeCommand;
///////////////////////////////////////////////////////////////////////////////
+inline string unescapeString(const string &InStr)
+{
+ string OutStr;
+ string::const_iterator It=InStr.cbegin();
+ string::const_iterator ItEnd=InStr.cend();
+ while (It!=ItEnd)
+ {
+ char Ch=*It++;
+ if (Ch=='\\' && It!=ItEnd)
+ {
+ Ch=*It++;
+ }
+ OutStr+=Ch;
+ }
+ return OutStr;
+}
+
+///////////////////////////////////////////////////////////////////////////////
inline const char *NextItem(const char *pTmp,string &Output, const char *pToks=" \t")
{
const char *pStart;
@@ -202,6 +220,9 @@ struct loadedmakefile : public refbase
fileinfo *m_MhMakeConf;
loadedmakefile_statics();
+
+ bool GetSvnRevision(void);
+ bool GetGitSvnRevision(void);
};
static loadedmakefile_statics sm_Statics;
@@ -212,6 +233,11 @@ struct loadedmakefile : public refbase
vector<string> m_CommandLineTargets;
refptr<mhmakefileparser> m_pMakefileParser;
+ loadedmakefile()
+ {
+ // Dummy, only used below
+ }
+
loadedmakefile(const fileinfo *pDir, vector<string> &Args,const string &Makefile=g_EmptyString);
void LoadMakefile();
@@ -261,11 +287,22 @@ struct loadedmakefile : public refbase
}
return 1;
}
+public:
+ fileinfo *GetMhMakeConf()
+ {
+ return sm_Statics.m_MhMakeConf;
+ }
+
};
class LOADEDMAKEFILES : public vector<refptr<loadedmakefile> >
{
public:
+ LOADEDMAKEFILES()
+ {
+ loadedmakefile temp;
+ temp.GetMhMakeConf(); // Just to be here to control the order of destruction (sm_Statics may not be destructed before g_LoadedMakefiles)
+ }
refptr<loadedmakefile> find(const loadedmakefile &pToSearch);
typedef vector<refptr<loadedmakefile> >::iterator iterator;
};