aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mhmake')
-rwxr-xr-xtools/mhmake/genkdev4.sh6
-rw-r--r--tools/mhmake/mhmake.vcxproj25
-rw-r--r--tools/mhmake/mhmake.vcxproj.filters13
-rw-r--r--tools/mhmake/src/build.cpp7
-rw-r--r--tools/mhmake/src/commandqueue.cpp6
-rw-r--r--tools/mhmake/src/commandqueue.h10
-rw-r--r--tools/mhmake/src/fileinfo.cpp2
-rw-r--r--tools/mhmake/src/functions.cpp18
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp70
-rw-r--r--tools/mhmake/src/mhmakefileparser.h10
-rw-r--r--tools/mhmake/src/mhmakelexer.l27
-rw-r--r--tools/mhmake/src/mhmakeparser.y23
-rw-r--r--tools/mhmake/src/rule.h2
-rw-r--r--tools/mhmake/src/util.cpp35
-rw-r--r--tools/mhmake/src/util.h2
15 files changed, 142 insertions, 114 deletions
diff --git a/tools/mhmake/genkdev4.sh b/tools/mhmake/genkdev4.sh
index 1acfe13b4..c3b1cbaa5 100755
--- a/tools/mhmake/genkdev4.sh
+++ b/tools/mhmake/genkdev4.sh
@@ -1,12 +1,12 @@
-mkdir build
+[ ! -d build ] && mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release ..
cd ..
-mkdir build.dbg
+[ ! -d build.dbg ] && mkdir build.dbg
cd build.dbg
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug ..
cd ..
-mkdir .kdev4
+[ ! -d .kdev4 ] && mkdir .kdev4
echo [CMake] > .kdev4/mhmake.kdev4
echo BuildDirs[\$e]=$PWD/build,$PWD/build.dbg >> .kdev4/mhmake.kdev4
diff --git a/tools/mhmake/mhmake.vcxproj b/tools/mhmake/mhmake.vcxproj
index 913b03d63..2b395f11f 100644
--- a/tools/mhmake/mhmake.vcxproj
+++ b/tools/mhmake/mhmake.vcxproj
@@ -413,6 +413,7 @@
<ClInclude Include="src\commandqueue.h" />
<ClInclude Include="src\curdir.h" />
<ClInclude Include="src\fileinfo.h" />
+ <ClInclude Include="src\flexint.h" />
<ClInclude Include="src\flexlexer.h" />
<ClInclude Include="src\md5.h" />
<ClInclude Include="src\mhmakefileparser.h" />
@@ -425,24 +426,24 @@
<CustomBuild Include="src\mhmakeLexer.l">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makelex.bat Debug
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(RelativeDir)flex.skl</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makelex.bat Debug64
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makelex.bat Profile
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">%(RelativeDir)flex.skl</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(IntDir)%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makelex.bat Profile64
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makelex.bat Release
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)flex.skl</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makelex.bat Release64</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
@@ -450,23 +451,23 @@
<CustomBuild Include="src\mhmakeParser.y">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makebison.bat Debug
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(RelativeDir)bisondata/bison.m4;%(RelativeDir)bisondata/lalr1.cc;%(RelativeDir)bisondata/c++.m4;%(RelativeDir)bisondata/c.m4;%(RelativeDir)bisondata/location.cc</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename).cpp;$(IntDir)%(Filename).hpp;$(IntDir)location.hh;$(IntDir)position.hh;$(IntDir)stack.hh</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makebison.bat Debug64
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makebison.bat Profile
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">%(RelativeDir)bisondata/bison.m4;%(RelativeDir)bisondata/lalr1.cc;%(RelativeDir)bisondata/c++.m4;%(RelativeDir)bisondata/c.m4;%(RelativeDir)bisondata/location.cc</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(IntDir)%(Filename).cpp;$(IntDir)%(Filename).hpp;$(IntDir)location.hh;$(IntDir)position.hh;$(IntDir)stack.hh</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makebison.bat Profile64</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makebison.bat Release
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(RelativeDir)bisondata/bison.m4;%(RelativeDir)bisondata/lalr1.cc;%(RelativeDir)bisondata/c++.m4;%(RelativeDir)bisondata/c.m4;%(RelativeDir)bisondata/location.cc</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Filename).cpp;$(IntDir)%(Filename).hpp;$(IntDir)location.hh;$(IntDir)position.hh;$(IntDir)stack.hh</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makebison.bat Release64</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
diff --git a/tools/mhmake/mhmake.vcxproj.filters b/tools/mhmake/mhmake.vcxproj.filters
index 77d66e01c..0ec28f785 100644
--- a/tools/mhmake/mhmake.vcxproj.filters
+++ b/tools/mhmake/mhmake.vcxproj.filters
@@ -2,23 +2,23 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
- <UniqueIdentifier>{e9db2f40-4c63-488d-bb89-1eee3e458055}</UniqueIdentifier>
+ <UniqueIdentifier>{bafa54b0-cf70-4114-a02b-5950c0d4d6e3}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
- <UniqueIdentifier>{bf259917-974f-4378-94e5-126d6d1889e9}</UniqueIdentifier>
+ <UniqueIdentifier>{a92d61c8-68ae-49f8-b843-a793ac9bb6c6}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Parser Files">
- <UniqueIdentifier>{5c6c4864-cd40-427e-825a-4a3028933fe0}</UniqueIdentifier>
+ <UniqueIdentifier>{a793606c-0dbc-4f42-9ad8-a61cf7773455}</UniqueIdentifier>
<Extensions>l;y;cpp;h</Extensions>
</Filter>
<Filter Include="Parser Files\Auto">
- <UniqueIdentifier>{06532204-d72c-459e-be81-db8b0725c996}</UniqueIdentifier>
+ <UniqueIdentifier>{e31daf7b-6a21-4a06-ac86-07625e21fd87}</UniqueIdentifier>
<Extensions>cpp;h</Extensions>
</Filter>
<Filter Include="Resource Files">
- <UniqueIdentifier>{c4505c11-9108-48e9-8d61-6247b696335e}</UniqueIdentifier>
+ <UniqueIdentifier>{bd4cf27c-0b86-4d5c-8dae-963cc3953cbb}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
@@ -94,6 +94,9 @@
<ClInclude Include="src\flexlexer.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\flexint.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="src\mhmakeLexer.l">
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index ba6a6e4da..ed9647d17 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -497,7 +497,7 @@ mh_pid_t mhmakefileparser::CopyFiles(const string &Params) const
if (pSrc->IsDir())
{
- SrcFileName+=OSPATHSEPSTR"*";
+ SrcFileName+=OSPATHSEPSTR "*";
pSrc=GetFileInfo(SrcFileName,m_MakeDir);
}
@@ -797,7 +797,7 @@ static void CommandSep(const string &Command, unsigned &EndPos, unsigned &NextBe
{
continue;
}
- while (strchr(" \t|<>",Command[NextBegin])) NextBegin++;
+ while (strchr(" \t|<>",Command[NextBegin])) NextBegin++;
}
while (strchr(" \t|<>",Command[EndPos])) EndPos--;
break;
@@ -838,6 +838,7 @@ mh_pid_t mhmakefileparser::OsExeCommand(const string &Command, const string &Par
unsigned NextBegin=0;
unsigned EndPos=0;
CommandSep(ComspecCommandLine,EndPos,NextBegin);
+
// We have multiple commands so create an temporary batch file
FILE *pFile;
while (1)
@@ -1507,7 +1508,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTarget
}
ImplicitRuleDepsIt++;
}
-
+
IMPLICITRULE::PopRule(ResultIt->second);
#ifdef _DEBUG
m_ImplicitSearch--;
diff --git a/tools/mhmake/src/commandqueue.cpp b/tools/mhmake/src/commandqueue.cpp
index 45a1d1043..c8f823b39 100644
--- a/tools/mhmake/src/commandqueue.cpp
+++ b/tools/mhmake/src/commandqueue.cpp
@@ -80,9 +80,9 @@ commandqueue::commandqueue() :
{
if (!szProc[cur+1])
{
- NrProcs++;
+ NrProcs++;
+ }
}
- }
cur++;
}
}
@@ -120,7 +120,7 @@ void commandqueue::SetNrParallelBuilds(unsigned NrParallelBuilds)
void commandqueue::ThrowCommandExecutionError(refptr<activeentry> pActiveEntry)
{
fileinfo* pTarget=pActiveEntry->pTarget;
- const string &Command=pActiveEntry->Command;
+ const string &Command=pActiveEntry->Command;
mhmakefileparser *pMakefile=pTarget->GetRule()->GetMakefile();
string ErrorMessage = string("Error running command: ")+ Command +"\n";
diff --git a/tools/mhmake/src/commandqueue.h b/tools/mhmake/src/commandqueue.h
index 8b327be8c..815dba643 100644
--- a/tools/mhmake/src/commandqueue.h
+++ b/tools/mhmake/src/commandqueue.h
@@ -41,11 +41,11 @@ class commandqueue
};
private:
queue<fileinfo*> m_Queue;
- unsigned m_MaxNrCommandsInParallel;
- mh_pid_t *m_pActiveProcesses;
- refptr<activeentry> *m_pActiveEntries;
- unsigned m_NrActiveEntries;
- mh_pid_t m_DummyWaitHandle;
+ unsigned m_MaxNrCommandsInParallel;
+ mh_pid_t *m_pActiveProcesses;
+ refptr<activeentry> *m_pActiveEntries;
+ unsigned m_NrActiveEntries;
+ mh_pid_t m_DummyWaitHandle;
private:
void ThrowCommandExecutionError(refptr<activeentry> pActiveEntry);
diff --git a/tools/mhmake/src/fileinfo.cpp b/tools/mhmake/src/fileinfo.cpp
index 9f4ae1ca1..884d645b5 100644
--- a/tools/mhmake/src/fileinfo.cpp
+++ b/tools/mhmake/src/fileinfo.cpp
@@ -257,7 +257,7 @@ string &NormalizePathName(string &Name)
if (pLastSlash<pBeg)
pWr=(char*)pBeg;
else
- pWr=(char*)pLastSlash;
+ pWr=(char*)pLastSlash;
}
}
else
diff --git a/tools/mhmake/src/functions.cpp b/tools/mhmake/src/functions.cpp
index 7393035cf..cd08dd957 100644
--- a/tools/mhmake/src/functions.cpp
+++ b/tools/mhmake/src/functions.cpp
@@ -738,12 +738,12 @@ static string dir(const string &FileName, void *)
return g_EmptyString;
}
- string Ret=g_EmptyString;
- Ret+=FileName.substr(0,Pos+1);
- if (FileName[0]=='"' && FileName.end()[-1]=='"')
- Ret+=s_QuoteString;
- return Ret;
- }
+ string Ret=g_EmptyString;
+ Ret+=FileName.substr(0,Pos+1);
+ if (FileName[0]=='"' && FileName.end()[-1]=='"')
+ Ret+=s_QuoteString;
+ return Ret;
+}
///////////////////////////////////////////////////////////////////////////////
string mhmakefileparser::f_dir(const string & FileNames) const
@@ -801,7 +801,7 @@ static string relpath(const string &FileName,void *pvDir)
while (*pCur)
{
if (*pCur==OSPATHSEP)
- retPath+=OSPATHSEPSTR"..";
+ retPath+=OSPATHSEPSTR "..";
pCur++;
}
if (pszPath)
@@ -810,11 +810,11 @@ static string relpath(const string &FileName,void *pvDir)
else
{
if (*pCur)
- retPath=".."OSPATHSEPSTR;
+ retPath=".." OSPATHSEPSTR;
while (*pCur)
{
if (*pCur==OSPATHSEP)
- retPath+=".."OSPATHSEPSTR;
+ retPath+=".." OSPATHSEPSTR;
pCur++;
}
retPath+=pLast;
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index d1f41b07f..55ad056db 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -27,7 +27,7 @@
#include "flexlexer.h"
#include "mhmakeparser.hpp"
-commandqueue mhmakefileparser::sm_CommandQueue;
+commandqueue mhmakefileparser::sm_CommandQueue;
stack<yy::mhmakeparser*> mhmakefileparser::sm_ParserStack; // Keeps track of the currently active parser
string mhmakefileparser::GetFileNameLineNo(void)
@@ -93,11 +93,7 @@ bool mhmakefileparser::IsDefined(const string &Var) const
bool Ret = m_Variables.find(Var)!=m_Variables.end();
if (!Ret)
{
- string Env=GetFromEnv(Var);
- if (!Env.empty())
- {
- Ret=true;
- }
+ GetFromEnv(Var, &Ret);
}
return Ret;
}
@@ -185,21 +181,21 @@ inline string mhmakefileparser::ExpandExpression(const string &ExprIn) const
char Char=Expr[i++];
if (Char=='$')
{
- size_t inew=SkipMakeExpr(Expr,i);
- i++;
- if (inew>i)
- {
- ToAdd=ExpandMacro(Expr.substr(i,inew-i-1));
- i=inew;
- }
- else
- {
- // This is a single character expression
- ToAdd=ExpandMacro(string(1,Expr[i-1]));
- }
- if (ToAdd.find('$')!=string::npos && ToAdd.length()!=1)
- {
- Recurse=true;
+ size_t inew=SkipMakeExpr(Expr,i);
+ i++;
+ if (inew>i)
+ {
+ ToAdd=ExpandMacro(Expr.substr(i,inew-i-1));
+ i=inew;
+ }
+ else
+ {
+ // This is a single character expression
+ ToAdd=ExpandMacro(string(1,Expr[i-1]));
+ }
+ if (ToAdd.find('$')!=string::npos && ToAdd.length()!=1)
+ {
+ Recurse=true;
}
Ret+=ToAdd;
}
@@ -298,7 +294,7 @@ string mhmakefileparser::ExpandMacro(const string &Expr) const
return ExpandExpression(Ret);
else
return Ret;
-}
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -682,7 +678,7 @@ const refptr<fileinfoarray> mhmakefileparser::GetIncludeDirs() const
((mhmakefileparser*)this)->m_IncludeDirs=Includes;
((mhmakefileparser*)this)->m_pIncludeDirs=refptr<fileinfoarray>(new fileinfoarray);
if (Includes.empty()) // If not defined try a default path
- Includes="include inc .."OSPATHSEPSTR"include .."OSPATHSEPSTR"inc";
+ Includes="include inc .." OSPATHSEPSTR "include .." OSPATHSEPSTR "inc";
const char *pTmp=Includes.c_str();
while (*pTmp)
{
@@ -774,7 +770,7 @@ void mhmakefileparser::LoadAutoDepsFile(fileinfo *pDepFile)
if (!pTarget->CompareMd5_32(0) && !pTarget->CompareMd5_32(Md5_32))
{
- MakeNotDirty=false; /* BuildTarget had set the dirty flag, but since the md5 did not change it was a false dirty. This is for BuildTargets called before this routine */
+ MakeNotDirty=false; /* BuildTarget had set the dirty flag, but since the md5 did not change it was a false dirty. This is for BuildTargets called before this routine */
#ifdef _DEBUG
cout << "Warning: trying to set to different md5's for Target "<<pTarget->GetQuotedFullFileName()<<" Old: "<<hex<<pTarget->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl;
#endif
@@ -946,7 +942,7 @@ void mhmakefileparser::SetExport(const string &Var, const string &Val)
{
const char *pVar=Var.c_str();
char *pStart=pEnv;
- while (*pEnv!='=' && *pEnv==*pVar)
+ while (*pEnv!='=' && tolower(*pEnv)==tolower(*pVar))
{
pEnv++; pVar++;
}
@@ -1141,16 +1137,7 @@ void mhmakefileparser::CheckEnv(void)
//
-static bool SkipVar(const string &Var)
-{
- if (Var==WC_REVISION)
- return true;
- if (Var==WC_URL)
- return true;
- if (Var==MAKE)
- return true;
- return false;
-}
+#define SkipVar(Var) (m_EnvVarsToIgnore.find(Var)!=m_EnvVarsToIgnore.end())
#define DBGOUT(stuff)
@@ -1208,32 +1195,33 @@ void mhmakefileparser::InitBuildTime()
///////////////////////////////////////////////////////////////////////////////
// Returns a variable from the environment or from the command line and adds it the m_UsedEnvVars
-string mhmakefileparser::GetFromEnv(const string &Var, bool Cache) const
+string mhmakefileparser::GetFromEnv(const string &Var, bool *pDefined) const
{
/* First we look into the command line variables, before we are looking in the environment */
map<string,string>::const_iterator pLineFind=m_CommandLineVars.find(Var);
if (pLineFind!=m_CommandLineVars.end())
{
((mhmakefileparser*)this)->m_UsedEnvVars.insert(Var);
- if (Cache)
- ((mhmakefileparser*)this)->m_Variables[Var]=pLineFind->second;
+ ((mhmakefileparser*)this)->m_Variables[Var]=pLineFind->second;
+ if (pDefined) *pDefined=true;
return pLineFind->second;
}
const char *pEnv=getenv(Var.c_str());
if (!pEnv)
{
+ if (pDefined) *pDefined=false;
return g_EmptyString;
}
((mhmakefileparser*)this)->m_UsedEnvVars.insert(Var);
- if (Cache)
- ((mhmakefileparser*)this)->m_Variables[Var]=pEnv;
+ ((mhmakefileparser*)this)->m_Variables[Var]=pEnv;
+ if (pDefined) *pDefined=true;
return pEnv;
}
///////////////////////////////////////////////////////////////////////////////
-// Creates the variable USER_ENVVARS to be saved in the autodeps file
+// Creates the variable USED_ENVVARS to be saved in the autodeps file
//
void mhmakefileparser::CreateUSED_ENVVARS()
diff --git a/tools/mhmake/src/mhmakefileparser.h b/tools/mhmake/src/mhmakefileparser.h
index 9ad13446c..848329226 100644
--- a/tools/mhmake/src/mhmakefileparser.h
+++ b/tools/mhmake/src/mhmakefileparser.h
@@ -57,7 +57,7 @@ class mhmakefileparser : public refbase
friend class yy::mhmakeparser;
private:
- static commandqueue sm_CommandQueue;
+ static commandqueue sm_CommandQueue;
static stack<yy::mhmakeparser*> sm_ParserStack; // Keeps track of the currently active parser
private:
fileinfo *m_RuleThatIsBuild;
@@ -93,6 +93,7 @@ protected:
bool m_RebuildAll; /* true when to rebuild all targets of this makefile */
set<string> m_UsedEnvVars; // Array containing a list of variables that are taken from the environment (This is used for rebuild checking)
+ set<string> m_EnvVarsToIgnore; // List of env vars that do not have to be taken into account for rebuild checking
set<string> m_Exports; // Array containing a list of exported variables in the makefile (This is used for rebuild checking)
vector< pair< string, refptr<fileinfoarray> > > m_vPath;
#ifdef WIN32
@@ -135,6 +136,9 @@ public:
SetVariable("MAKE_VERSION",MHMAKEVER);
SetVariable(OBJEXTVAR,OBJEXT);
SetVariable(EXEEXTVAR,EXEEXT);
+ m_EnvVarsToIgnore.insert(WC_REVISION);
+ m_EnvVarsToIgnore.insert(WC_URL);
+ m_EnvVarsToIgnore.insert(MAKE);
}
/* Needed if you only want to use the searchcommand and execommand functions */
@@ -151,7 +155,7 @@ public:
bool CompareEnv() const;
uint32 CreateEnvMd5_32() const;
- string GetFromEnv(const string &Var,bool Cache=true) const;
+ string GetFromEnv(const string &Var, bool *pDefined=NULL) const;
void CreateUSED_ENVVARS();
void SetExport(const string & Var, const string & Val);
@@ -350,7 +354,7 @@ public:
mh_time_t TargetDate=StartBuildTarget(pTarget,bCheckTargetDir);
if (!TargetDate.IsDateValid())
TargetDate=WaitBuildTarget(pTarget);
- return TargetDate;
+ return TargetDate;
}
void BuildDependencies(const refptr<rule> &pRule, fileinfo* pTarget, mh_time_t TargetDate, mh_time_t &YoungestDate, bool &MakeTarget);
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l
index 9dc1a23a0..9b933c305 100644
--- a/tools/mhmake/src/mhmakelexer.l
+++ b/tools/mhmake/src/mhmakelexer.l
@@ -35,7 +35,7 @@ static uint32 LoadMakMd5(fileinfo *pTarget)
return Md5_32;
if (1!=fread(&Md5_32,sizeof(Md5_32),1,pFile))
{
- fclose(pFile);
+ fclose(pFile);
return Md5_32;
}
pTarget->SetCommandsMd5_32(Md5_32);
@@ -71,7 +71,7 @@ static void ReplaceCurlyBraces(string &String)
Pos=0;
while ((Pos=String.find_first_of('}',Pos))!=(int)string::npos)
String.replace(Pos,1,1,')');
- }
+ }
}
#include "mhmakeparser.hpp"
@@ -248,6 +248,13 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
+[ \t]*override[ \t]* {
+ // override is not supported by mhmake, it is the default behavior
+ PRINTF(("%s %d: SPACE (ignoring override):\n",m_InputFileName.c_str(),lineno()));
+ return yy::mhmakeparser::token::SPACE;
+}
+
+ /*---------------------------------------------------------------------------*/
[ \t]*=[ \t]*\\[ \t\r]*\n[ \t]* {
PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),lineno(),yytext));
inclineno();
@@ -298,6 +305,12 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
+\\; {
+ PRINTF(("%s %d: -Escaped SEMICOLON (STRING): %s\n",m_InputFileName.c_str(),lineno(),yytext));
+ yylval->theString=(const char *)yytext+1;
+ return yy::mhmakeparser::token::STRING;
+}
+ /*---------------------------------------------------------------------------*/
[ \t]*;[ \t]*\\[ \t\r]*\n[ \t]* {
PRINTF(("%s %d: -SEMICOLON (NEWLINE): %s\n",m_InputFileName.c_str(),lineno(),yytext));
m_curtoken=g_EmptyString;
@@ -595,7 +608,7 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
-<SKIPUNTILELSEORENDIF>[a-zA-Z]+ /* skip */
+<SKIPUNTILELSEORENDIF>[a-zA-Z]+ /* skip */
/*---------------------------------------------------------------------------*/
<SKIPUNTILELSEORENDIF>[^a-zA-Z\n]+ /* skip */
/*---------------------------------------------------------------------------*/
@@ -632,6 +645,12 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
+\.ENVVARS_TOIGNORE {
+ PRINTF(("%s %d: .ENVVARS_TOIGNORE: %s\n",m_InputFileName.c_str(),lineno(),yytext));
+ return yy::mhmakeparser::token::ENVVARS_TOIGNORE;
+}
+
+ /*---------------------------------------------------------------------------*/
export {
PRINTF(("%s %d: export: %s\n",m_InputFileName.c_str(),lineno(),yytext));
return yy::mhmakeparser::token::EXPORT;
@@ -842,7 +861,7 @@ export {
<SINGLEQUOTE>[^\\\'\r\n$]+ |
<SINGLEQUOTE>[\\\$] |
-<SINGLEQUOTE>\\\' |
+<SINGLEQUOTE>\\\' |
<SINGLEQUOTE>\\# {
yymore();
}
diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y
index 847cda48a..d8edb1d51 100644
--- a/tools/mhmake/src/mhmakeparser.y
+++ b/tools/mhmake/src/mhmakeparser.y
@@ -53,7 +53,7 @@ const char Test[]="dit is een test";
%token <theString> COMMAND
%token <theString> COMMA
%token <theString> STRING DOLLAREXPR EQUAL COLON DOUBLECOLON VARDEF VARVAL
-%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE VPATH
+%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE VPATH ENVVARS_TOIGNORE
%type <theString> expression nonspaceexpression simpleexpression
%type <theString> maybeemptyexpression
@@ -92,6 +92,7 @@ statement: NEWLINE |
ruledef |
phonyrule |
autodepsrule |
+ envvarstoignorerule |
varassignment |
imvarassignment |
pvarassignment |
@@ -179,6 +180,26 @@ autodepsrule: AUTODEPS COLON expression
NEWLINE
;
+envvarstoignorerule: ENVVARS_TOIGNORE COLON expression
+ {
+ string VarsStr=m_pMakefile->ExpandExpression($3);
+ PRINTF(("Defining envvarstoignore rule : %s\n",$3.c_str()));
+ PRINTF((" Expanded to : %s\n",m_pMakefile->ExpandExpression($3).c_str()));
+ const char *pTmp=VarsStr.c_str();
+ while (*pTmp)
+ {
+ string Var;
+ pTmp=NextItem(pTmp,Var);
+ if (!Var.empty())
+ { // Add it to the list of env vars to ignore
+ m_pMakefile->m_EnvVarsToIgnore.insert(Var);
+ }
+ }
+ }
+ NEWLINE
+;
+
+
exportrule: EXPORT space exportstrings NEWLINE |
EXPORT space STRING EQUAL maybeemptyexpression
{
diff --git a/tools/mhmake/src/rule.h b/tools/mhmake/src/rule.h
index 7cc287600..04827b129 100644
--- a/tools/mhmake/src/rule.h
+++ b/tools/mhmake/src/rule.h
@@ -82,7 +82,7 @@ class IMPLICITRULE
static set<rule*> m_ImplicitRuleRecurseDetStack;
static vector<implicitrule_t> m_ImplicitRules; // Use a vector and not a map because the order of the implicit rules is important
public:
- static void AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps, refptr<rule> pRule);
+ static void AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps,refptr<rule> pRule);
static void SearchImplicitRule(const fileinfo *pTarget, implicitruledep_t &Result);
static void PrintImplicitRules();
static bool PushRule(rule *pRule)
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index 3e20706dd..9fe006e95 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -650,27 +650,7 @@ void loadedmakefile::LoadMakefile()
}
else
{
- /* Create a file that is depending on the makefile name and the arguments */
- md5_context ctx;
-
- md5_starts( &ctx );
-
- map<string,string>::const_iterator pIt=m_CommandLineVars.begin();
- while (pIt!=m_CommandLineVars.end())
- {
- if (pIt->first!="MAKE")
- {
- md5_update(&ctx, (uint8*)pIt->first.c_str(), pIt->first.size());
- md5_update(&ctx, (uint8*)pIt->second.c_str(), pIt->second.size());
- }
- pIt++;
- }
- md5_update(&ctx, (uint8*)m_Makefile->GetFullFileName().c_str(), m_Makefile->GetFullFileName().size());
-
- char ID[10];
- sprintf(ID,"_%lx",md5_finish32( &ctx));
-
- pDepFile=GetFileInfo(string(".") + m_Makefile->GetName()+ ".dep"+ID,m_MakeDir);
+ pDepFile=GetFileInfo(string(".") + m_Makefile->GetName()+ ".dep",m_MakeDir);
m_pMakefileParser->SetVariable(AUTODEPFILE,pDepFile->GetQuotedFullFileName());
}
@@ -683,10 +663,12 @@ void loadedmakefile::LoadMakefile()
{
throw string("Error parsing ")+m_Makefile->GetQuotedFullFileName();
}
+
+ fileinfo *pMaybeNewDepFile=GetFileInfo(m_pMakefileParser->ExpandVar(AUTODEPFILE),m_MakeDir);
#ifdef _DEBUG
/* Check if the makefile has changed the AUTODEPFILE variable, if so generate a warning that a
* rebuild could happen for the rules defined for making included makefiles */
- if (m_pMakefileParser->ExpandVar(AUTODEPFILE)!=pDepFile->GetQuotedFullFileName())
+ if (pMaybeNewDepFile!=pDepFile)
{
cout << "\n\nWARNING:\n makefile '"<< m_Makefile->GetQuotedFullFileName() <<"' re-defines AUTODEPFILE\n from '"<< pDepFile->GetQuotedFullFileName() <<"'\n to '"<<
m_pMakefileParser->ExpandVar(AUTODEPFILE) << "'\n (may cause needless rebuilds when having rules for included makefiles!!!!!)\n\n\n";
@@ -700,6 +682,15 @@ void loadedmakefile::LoadMakefile()
cout<<"No First target for "<<m_Makefile->GetQuotedFullFileName()<<endl;
}
#endif
+
+ if (pMaybeNewDepFile!=pDepFile)
+ {
+ // this means the makefile has overruled the AUTODEPFILE, so parse it again
+ pDepFile=pMaybeNewDepFile;
+ if (pDepFile->Exists())
+ m_pMakefileParser->LoadAutoDepsFile(pDepFile); /* If it already exists, load it. */
+ }
+
m_pMakefileParser->UpdateDate(m_Makefile->GetDate());
if (sm_Statics.m_MhMakeConf)
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index b4a17a6cf..e7f9ccf57 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.15"
+#define MHMAKEVER "3.0.19"
class makecommand
{