aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-10-22 14:00:01 +0000
committermarha <marha@users.sourceforge.net>2010-10-22 14:00:01 +0000
commitd74d9f4e60e48260ff1fad3ff00aaf000f111a66 (patch)
treefcf6ceee3ec04dc8521bbf12453d95cbe187dc40 /tools/mhmake
parent5a05343a8071f769d092d5bb6bdea9adf65eda9c (diff)
downloadvcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.tar.gz
vcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.tar.bz2
vcxsrv-d74d9f4e60e48260ff1fad3ff00aaf000f111a66.zip
Increased gnu make compatibility
Optimised
Diffstat (limited to 'tools/mhmake')
-rw-r--r--tools/mhmake/mhmake.kdevelop8
-rw-r--r--tools/mhmake/mhmake.sln9
-rw-r--r--tools/mhmake/mhmake.vcxproj12
-rw-r--r--tools/mhmake/mhmakevc10.sln9
-rw-r--r--tools/mhmake/src/bison.cc2
-rw-r--r--tools/mhmake/src/bison.h2
-rw-r--r--tools/mhmake/src/build.cpp194
-rw-r--r--tools/mhmake/src/commandqueue.cpp18
-rw-r--r--tools/mhmake/src/commandqueue.h12
-rw-r--r--tools/mhmake/src/curdir.cpp12
-rw-r--r--tools/mhmake/src/curdir.h13
-rw-r--r--tools/mhmake/src/fileinfo.cpp53
-rw-r--r--tools/mhmake/src/fileinfo.h98
-rw-r--r--tools/mhmake/src/flexskel.cc2
-rw-r--r--tools/mhmake/src/flexskel.h2
-rw-r--r--tools/mhmake/src/functions.cpp60
-rw-r--r--tools/mhmake/src/md5.cpp2
-rw-r--r--tools/mhmake/src/md5.h2
-rw-r--r--tools/mhmake/src/mhmake.cpp10
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp192
-rw-r--r--tools/mhmake/src/mhmakefileparser.h68
-rw-r--r--tools/mhmake/src/mhmakelexer.l61
-rw-r--r--tools/mhmake/src/mhmakeparser.y21
-rw-r--r--tools/mhmake/src/refptr.h2
-rw-r--r--tools/mhmake/src/rule.cpp88
-rw-r--r--tools/mhmake/src/rule.h11
-rw-r--r--tools/mhmake/src/stdafx.cpp2
-rw-r--r--tools/mhmake/src/stdafx.h2
-rw-r--r--tools/mhmake/src/util.cpp103
-rw-r--r--tools/mhmake/src/util.h13
30 files changed, 657 insertions, 426 deletions
diff --git a/tools/mhmake/mhmake.kdevelop b/tools/mhmake/mhmake.kdevelop
index a271870fe..003b7032d 100644
--- a/tools/mhmake/mhmake.kdevelop
+++ b/tools/mhmake/mhmake.kdevelop
@@ -1,8 +1,8 @@
<?xml version = '1.0'?>
<kdevelop>
<general>
- <author>Marc Haesen</author>
- <email>hmca@telenet.be</email>
+ <author>marha</author>
+ <email>marc@hc-consult.be</email>
<version>1.1.12</version>
<projectmanagement>KDevAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
@@ -164,8 +164,8 @@
<APPNAMELC>mhmake</APPNAMELC>
<APPNAMESC>Mhmake</APPNAMESC>
<APPNAMEUC>MHMAKE</APPNAMEUC>
- <AUTHOR>Marc Haesen</AUTHOR>
- <EMAIL>hmca@telenet.be</EMAIL>
+ <AUTHOR>marha</AUTHOR>
+ <EMAIL>marc@hc-consult.be</EMAIL>
<LICENSE>Custom</LICENSE>
<VERSION>0.1</VERSION>
<YEAR>2006</YEAR>
diff --git a/tools/mhmake/mhmake.sln b/tools/mhmake/mhmake.sln
index 8c7fe9bc9..7121b8286 100644
--- a/tools/mhmake/mhmake.sln
+++ b/tools/mhmake/mhmake.sln
@@ -5,16 +5,25 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
Profile|Win32 = Profile|Win32
+ Profile|x64 = Profile|x64
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|Win32.ActiveCfg = Debug|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|Win32.Build.0 = Debug|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|x64.ActiveCfg = Debug|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|x64.Build.0 = Debug|x64
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|Win32.ActiveCfg = Profile|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|Win32.Build.0 = Profile|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|x64.ActiveCfg = Profile|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|x64.Build.0 = Profile|x64
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|Win32.ActiveCfg = Release|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|Win32.Build.0 = Release|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|x64.ActiveCfg = Release|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/tools/mhmake/mhmake.vcxproj b/tools/mhmake/mhmake.vcxproj
index f5e8f2da3..8b7faed2c 100644
--- a/tools/mhmake/mhmake.vcxproj
+++ b/tools/mhmake/mhmake.vcxproj
@@ -114,6 +114,9 @@
<IntDir Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mhmake_dbg</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mhmake_dbg</TargetName>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
@@ -130,7 +133,6 @@
<AdditionalIncludeDirectories>.;src;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>false</FunctionLevelLinking>
@@ -158,6 +160,8 @@
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -296,8 +300,6 @@
<AdditionalIncludeDirectories>.;src;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>
- </ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>false</FunctionLevelLinking>
@@ -311,13 +313,13 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CallingConvention>FastCall</CallingConvention>
<CompileAs>Default</CompileAs>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <OutputFile>$(Configuration)/mhmake.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -329,6 +331,8 @@
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
diff --git a/tools/mhmake/mhmakevc10.sln b/tools/mhmake/mhmakevc10.sln
index 142a822cc..aa927ed5f 100644
--- a/tools/mhmake/mhmakevc10.sln
+++ b/tools/mhmake/mhmakevc10.sln
@@ -5,16 +5,25 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
Profile|Win32 = Profile|Win32
+ Profile|x64 = Profile|x64
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|Win32.ActiveCfg = Debug|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|Win32.Build.0 = Debug|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|x64.ActiveCfg = Debug|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Debug|x64.Build.0 = Debug|x64
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|Win32.ActiveCfg = Profile|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|Win32.Build.0 = Profile|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|x64.ActiveCfg = Profile|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Profile|x64.Build.0 = Profile|x64
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|Win32.ActiveCfg = Release|Win32
{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|Win32.Build.0 = Release|Win32
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|x64.ActiveCfg = Release|x64
+ {7F1669C8-7974-45DF-9B71-0E2A8DC44C06}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/tools/mhmake/src/bison.cc b/tools/mhmake/src/bison.cc
index e0315efd4..5a203f719 100644
--- a/tools/mhmake/src/bison.cc
+++ b/tools/mhmake/src/bison.cc
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/bison.h b/tools/mhmake/src/bison.h
index ac5c56bf2..0724ae112 100644
--- a/tools/mhmake/src/bison.h
+++ b/tools/mhmake/src/bison.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index bfd5d0211..525ff8c05 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -242,20 +242,20 @@ void mhmakefileparser::CreatePythonExe(const string &FullCommand)
/*****************************************************************************/
int mhmakefileparser::SearchPath(const char *szCommand, const char *pExt, size_t Len, char *szFullCommand,char **pFilePart) const
{
- static vector< refptr<fileinfo> > vSearchPath;
+ static vector< fileinfo* > vSearchPath;
string Command(szCommand);
if (pExt)
Command+=pExt;
- vector< refptr<fileinfo> >::iterator It;
- vector< refptr<fileinfo> >::iterator ItEnd;
+ vector< fileinfo* >::iterator It;
+ vector< fileinfo* >::iterator ItEnd;
- refptr<fileinfo> CommandFile=GetFileInfo(Command,m_MakeDir);
- if (CommandFile->Exists())
+ fileinfo* pCommandFile=GetFileInfo(Command,m_MakeDir);
+ if (pCommandFile->Exists())
{
goto found;
}
- CommandFile->InvalidateDate(); // It could be created in the makefile later
+ pCommandFile->InvalidateDate(); // It could be created in the makefile later
if (!vSearchPath.size())
{
char *pPath=getenv(PATH);
@@ -274,8 +274,8 @@ int mhmakefileparser::SearchPath(const char *szCommand, const char *pExt, size_t
ItEnd=vSearchPath.end();
while (It!=ItEnd)
{
- CommandFile=GetFileInfo(Command,*It);
- if (CommandFile->Exists())
+ pCommandFile=GetFileInfo(Command,*It);
+ if (pCommandFile->Exists())
goto found;
It++;
}
@@ -283,7 +283,7 @@ int mhmakefileparser::SearchPath(const char *szCommand, const char *pExt, size_t
return 0;
found:
- string FullCommand=CommandFile->GetFullFileName();
+ string FullCommand=pCommandFile->GetFullFileName();
size_t CommandLen=FullCommand.size();
if (CommandLen>Len-1)
{
@@ -392,7 +392,7 @@ static bool DeleteDir(const string &Dir,const string WildSearch="*",bool bRemove
mh_pid_t mhmakefileparser::DeleteFiles(const string &Params) const
{
bool IgnoreError=false;
- vector< refptr<fileinfo> > Files;
+ vector<fileinfo*> Files;
// First check if the first parameter is -e meaning don't give an error when file does not exist
if (Params[1]=='-')
@@ -413,10 +413,10 @@ mh_pid_t mhmakefileparser::DeleteFiles(const string &Params) const
SplitToItems(Params,Files);
}
- vector< refptr<fileinfo> >::const_iterator It=Files.begin();
+ vector<fileinfo*>::const_iterator It=Files.begin();
while (It!=Files.end())
{
- refptr<fileinfo> pFile=*It++;
+ fileinfo* pFile=*It++;
string DirSearch="*";
bool bRemoveDir=true;
@@ -457,7 +457,7 @@ mh_pid_t mhmakefileparser::DeleteFiles(const string &Params) const
/*****************************************************************************/
/* pDest can be a directory or a file */
-static bool CopyFile(refptr<fileinfo> pSrc, refptr<fileinfo> pDest)
+static bool CopyFile(fileinfo* pSrc, fileinfo* pDest)
{
if (pDest->IsDir())
{
@@ -494,7 +494,7 @@ static bool CopyFile(refptr<fileinfo> pSrc, refptr<fileinfo> pDest)
/*****************************************************************************/
/* Copies a complete directory to a destination (currenlty not recursive */
-static bool CopyDir(refptr<fileinfo> pDir,refptr<fileinfo> pDest,const string WildSearch="*")
+static bool CopyDir(fileinfo* pDir, fileinfo* pDest,const string WildSearch="*")
{
bool Error=true;
string Pattern=pDir->GetFullFileName()+OSPATHSEP+WildSearch;
@@ -513,11 +513,11 @@ static bool CopyDir(refptr<fileinfo> pDir,refptr<fileinfo> pDest,const string Wi
{
if (FindData.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN)
continue;
- refptr<fileinfo> pSrc=GetFileInfo(FindData.cFileName,pDir);
+ fileinfo* pSrc=GetFileInfo(FindData.cFileName,pDir);
if (pSrc->IsDir())
{
- refptr<fileinfo> pNewDest=GetFileInfo(FindData.cFileName,pDest);
+ fileinfo* pNewDest=GetFileInfo(FindData.cFileName,pDest);
if (!pNewDest->IsDir())
{
if (pNewDest->Exists())
@@ -554,7 +554,7 @@ exit:
for (int i=0; i<Res.gl_pathc; i++)
{
- refptr<fileinfo> pSrc=GetFileInfo(Res.gl_pathv[i],pDir);
+ fileinfo* pSrc=GetFileInfo(Res.gl_pathv[i],pDir);
if (pSrc->IsDir())
{
*(strrchr(Res.gl_pathv[i],'/'))='\0';
@@ -563,7 +563,7 @@ exit:
if (SrcDirName[0]=='.')
continue;
- refptr<fileinfo> pNewDest=GetFileInfo(SrcDirName,pDest);
+ fileinfo* pNewDest=GetFileInfo(SrcDirName,pDest);
if (!pNewDest->IsDir())
{
if (pNewDest->Exists())
@@ -615,14 +615,14 @@ mh_pid_t mhmakefileparser::EchoCommand(const string &Params) const
if (Params[Pos+1]=='>')
{
NextItem(Params.substr(Pos+2).c_str(),Filename);
- refptr<fileinfo> pFile=GetFileInfo(Filename,m_MakeDir);
+ fileinfo* pFile=GetFileInfo(Filename,m_MakeDir);
// Open file in append
pfFile=fopen(pFile->GetFullFileName().c_str(),"a");
}
else
{
NextItem(Params.substr(Pos+1).c_str(),Filename);
- refptr<fileinfo> pFile=GetFileInfo(Filename,m_MakeDir);
+ fileinfo* pFile=GetFileInfo(Filename,m_MakeDir);
pfFile=fopen(pFile->GetFullFileName().c_str(),"w");
}
if (!pfFile)
@@ -646,7 +646,7 @@ mh_pid_t mhmakefileparser::EchoCommand(const string &Params) const
/*****************************************************************************/
mh_pid_t mhmakefileparser::CopyFiles(const string &Params) const
{
- vector< refptr<fileinfo> > Files;
+ vector<fileinfo*> Files;
SplitToItems(Params,Files);
@@ -658,7 +658,7 @@ mh_pid_t mhmakefileparser::CopyFiles(const string &Params) const
return false;
}
- refptr<fileinfo> pDest=Files[NrSrcs];
+ fileinfo* pDest=Files[NrSrcs];
if (NrSrcs>1 && !pDest->IsDir())
{
cerr << "copy: Destination must be a directory when more then one source : "<<Params<<endl;
@@ -667,7 +667,7 @@ mh_pid_t mhmakefileparser::CopyFiles(const string &Params) const
for (size_t i=0; i<NrSrcs; i++)
{
- refptr<fileinfo> pSrc=Files[i];
+ fileinfo* pSrc=Files[i];
string SrcFileName=pSrc->GetFullFileName();
@@ -704,14 +704,14 @@ mh_pid_t mhmakefileparser::CopyFiles(const string &Params) const
/*****************************************************************************/
mh_pid_t mhmakefileparser::TouchFiles(const string &Params) const
{
- vector< refptr<fileinfo> > Files;
+ vector<fileinfo*> Files;
SplitToItems(Params,Files);
- vector< refptr<fileinfo> >::const_iterator It=Files.begin();
+ vector<fileinfo*>::const_iterator It=Files.begin();
while (It!=Files.end())
{
- refptr<fileinfo> pFile=*It++;
+ fileinfo* pFile=*It++;
const string &FileName=pFile->GetFullFileName();
/* Since this can be part of a list of commands for a certain rule, and it is possible that the file
@@ -904,8 +904,8 @@ string mhmakefileparser::GetFullCommand(string Command)
Command=FullCommand;
if (!PythonFullCommand.empty()&&s_Py2ExeInstalled)
{
- refptr<fileinfo> pExeFile=GetFileInfo(FullCommand,m_MakeDir);
- refptr<fileinfo> pPyFile=GetFileInfo(PythonFullCommand,m_MakeDir);
+ fileinfo* pExeFile=GetFileInfo(FullCommand,m_MakeDir);
+ fileinfo* pPyFile=GetFileInfo(PythonFullCommand,m_MakeDir);
bool bBuild=false;
if (pExeFile->GetDate().IsOlder(pPyFile->GetDate()))
{
@@ -950,7 +950,7 @@ string mhmakefileparser::GetFullCommand(string Command)
/* Now first try to create an executable for it */
if (s_Py2ExeInstalled)
{
- refptr<fileinfo> pExeFile;
+ fileinfo* pExeFile;
CreatePythonExe(FullCommand);
string ExeFullCommand=SearchCommand(Command,EXEEXT);
if (!ExeFullCommand.empty())
@@ -1435,11 +1435,11 @@ mh_pid_t mhmakefileparser::ExecuteCommand(string Command, bool &IgnoreError, str
}
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, const refptr<fileinfo> &Target, mh_time_t TargetDate, mh_time_t &YoungestDate, bool &MakeTarget)
+void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, fileinfo* pTarget, mh_time_t TargetDate, mh_time_t &YoungestDate, bool &MakeTarget)
{
- vector< refptr<fileinfo> > &Deps=Target->GetDeps();
- vector< refptr<fileinfo> >::iterator pDepIt=Deps.begin();
+ vector<fileinfo*> &Deps=pTarget->GetDeps();
+ vector<fileinfo*>::iterator pDepIt=Deps.begin();
while (pDepIt!=Deps.end())
{
StartBuildTarget(*pDepIt);
@@ -1455,7 +1455,7 @@ void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, const refptr
{
#ifdef _DEBUG
if (pRule&&g_pPrintDependencyCheck && DepDate.IsExistingFile() && TargetDate.IsExistingFile())
- cout<<"Going to build "<<Target->GetQuotedFullFileName()<<" because "<<(*pDepIt)->GetQuotedFullFileName()<<" is more recent\n";
+ cout<<"Going to build "<<pTarget->GetQuotedFullFileName()<<" because "<<(*pDepIt)->GetQuotedFullFileName()<<" is more recent\n";
#endif
MakeTarget=true;
}
@@ -1464,24 +1464,24 @@ void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, const refptr
}
///////////////////////////////////////////////////////////////////////////////
-mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool bCheckTargetDir)
+mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTargetDir)
{
#ifdef _DEBUG
if (g_CheckCircularDeps)
{
- deque< refptr<fileinfo> >::const_iterator pFind=find(m_TargetStack.begin(),m_TargetStack.end(),Target);
+ deque<fileinfo*>::const_iterator pFind=find(m_TargetStack.begin(),m_TargetStack.end(),pTarget);
if (pFind!=m_TargetStack.end())
{
- cout << "Circular dependency detected.\n"<<Target->GetQuotedFullFileName()<<" depending on itself.\n";
+ cout << "Circular dependency detected.\n"<<pTarget->GetQuotedFullFileName()<<" depending on itself.\n";
cout << "Dependency stack:\n";
- deque< refptr<fileinfo> >::const_iterator pIt=m_TargetStack.begin();
+ deque<fileinfo*>::const_iterator pIt=m_TargetStack.begin();
while (pIt!=m_TargetStack.end())
{
cout << " " << (*pIt)->GetQuotedFullFileName() << endl;
pIt++;
}
}
- if (!Target->IsBuildStarted()) m_TargetStack.push_back(Target);
+ if (!pTarget->IsBuildStarted()) m_TargetStack.push_back(pTarget);
}
#endif
@@ -1494,46 +1494,46 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
throw string("Compilation Interrupted by user.");
}
- if (Target->IsBuild())
+ if (pTarget->IsBuild())
{
#ifdef _DEBUG
if (g_pPrintDependencyCheck)
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<" Already build "<<Target->GetQuotedFullFileName()<<" : "<<Target->GetDate()<<endl;
+ cout<<" Already build "<<pTarget->GetQuotedFullFileName()<<" : "<<pTarget->GetDate()<<endl;
}
#endif
- return Target->GetDate();
+ return pTarget->GetDate();
}
- if (Target->IsBuilding())
- return mh_time_t(); // Target is still building, so we have to wait
+ if (pTarget->IsBuilding())
+ return mh_time_t(); // pTarget is still building, so we have to wait
#ifdef _DEBUG
if (g_GenProjectTree)
- cout << Target->GetQuotedFullFileName() << endl;
+ cout << pTarget->GetQuotedFullFileName() << endl;
Indent++;
if (g_pPrintDependencyCheck)
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building dependencies of "<<Target->GetQuotedFullFileName()<<endl;
+ cout<<"Building dependencies of "<<pTarget->GetQuotedFullFileName()<<endl;
}
#endif
- Target->SetBuild();
+ pTarget->SetBuild();
/* Optimisation: do not build target when target dir does not exist,
but first build the target dir, in case there exists a rule for it*/
- refptr<rule> pRule=Target->GetRule();
+ refptr<rule> pRule=pTarget->GetRule();
if (!pRule && bCheckTargetDir)
{
- refptr<fileinfo> TargetDir=Target->GetDir();
- mh_time_t TargetDirDate=BuildTarget(TargetDir,false);
+ fileinfo *pTargetDir=pTarget->GetDir();
+ mh_time_t TargetDirDate=BuildTarget(pTargetDir,false);
- if (!TargetDir->Exists())
+ if (!pTargetDir->Exists())
{
#ifdef _DEBUG
Indent--;
@@ -1546,29 +1546,28 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
}
}
- mh_time_t TargetDate=Target->GetDate();
+ mh_time_t TargetDate=pTarget->GetDate();
bool MakeTarget=false;
mh_time_t YoungestDate=TargetDate;
if (!pRule || !pRule->GetCommands().size())
{
- vector< pair<refptr<fileinfo>,refptr<rule> > > Result;
+ vector< pair<fileinfo*,refptr<rule> > > Result;
+ IMPLICITRULE::SearchImplicitRule(pTarget,Result);
- IMPLICITRULE::SearchImplicitRule(Target,Result);
-
- vector< pair<refptr<fileinfo>,refptr<rule> > >::iterator ResultIt=Result.begin();
+ vector< pair<fileinfo*,refptr<rule> > >::iterator ResultIt=Result.begin();
while (ResultIt!=Result.end())
{
- if (ResultIt->first==NullFileInfo)
+ if (ResultIt->first==NULL)
{
pRule=ResultIt->second;
- Target->SetRule(pRule);
+ pTarget->SetRule(pRule);
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
{
- cout<<"Found implicit rule for "<<Target->GetQuotedFullFileName()<<endl;
- pRule->PrintCommands(Target);
+ cout<<"Found implicit rule for "<<pTarget->GetQuotedFullFileName()<<endl;
+ pRule->PrintCommands(pTarget);
}
#endif
break;
@@ -1578,28 +1577,36 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
#ifdef _DEBUG
m_ImplicitSearch++;
#endif
- mh_time_t DepDate=BuildTarget(ResultIt->first);
+ fileinfo* pNewTarget=ResultIt->first;
+ mh_time_t DepDate=BuildTarget(pNewTarget);
+ if (!DepDate.DoesExist())
+ {
+ pNewTarget=ResultIt->second->GetMakefile()->SearchvPath(pNewTarget);
+ if (pNewTarget!=NULL)
+ DepDate=pNewTarget->GetDate();
+ }
#ifdef _DEBUG
m_ImplicitSearch--;
#endif
- if (DepDate.DoesExist()) {
+ if (DepDate.DoesExist())
+ {
if (DepDate.IsNewer(YoungestDate))
YoungestDate=DepDate;
pRule=ResultIt->second;
- Target->AddMainDep(ResultIt->first);
- Target->SetRule(pRule); /* This is an implicit rule so do not add the target */
+ pTarget->AddMainDep(pNewTarget);
+ pTarget->SetRule(pRule); /* This is an implicit rule so do not add the target */
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
{
- cout<<"Found implicit rule for "<<Target->GetQuotedFullFileName()<<". Dependent "<<ResultIt->first->GetQuotedFullFileName()<<endl;
- pRule->PrintCommands(Target);
+ cout<<"Found implicit rule for "<<pTarget->GetQuotedFullFileName()<<". Dependent "<<ResultIt->first->GetQuotedFullFileName()<<endl;
+ pRule->PrintCommands(pTarget);
}
#endif
if (DepDate.IsNewer(TargetDate))
{
#ifdef _DEBUG
if (pRule,g_pPrintDependencyCheck && DepDate.IsExistingFile() && TargetDate.IsExistingFile())
- cout<<"Going to build "<<Target->GetQuotedFullFileName()<<" because "<<ResultIt->first->GetQuotedFullFileName()<<" is more recent\n";
+ cout<<"Going to build "<<pTarget->GetQuotedFullFileName()<<" because "<<ResultIt->first->GetQuotedFullFileName()<<" is more recent\n";
#endif
MakeTarget=true;
}
@@ -1611,11 +1618,11 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
if (pRule)
{
#ifdef _DEBUG
- Target->SetBuilding();
- Target->SetRule(pRule);
- Target->ClearBuilding();
+ pTarget->SetBuilding();
+ pTarget->SetRule(pRule);
+ pTarget->ClearBuilding();
#else
- Target->SetRule(pRule);
+ pTarget->SetRule(pRule);
#endif
}
}
@@ -1625,12 +1632,12 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
{
pMakefile=pRule->GetMakefile();
if (pMakefile->ForceAutoDepRescan()||MakeTarget==true)
- pMakefile->UpdateAutomaticDependencies(Target);
+ pMakefile->UpdateAutomaticDependencies(pTarget);
}
- else if (Target->GetAutoDepsMakefile())
- Target->GetAutoDepsMakefile()->UpdateNoRuleAutomaticDependencies(Target);
+ else if (pTarget->GetAutoDepsMakefile())
+ pTarget->GetAutoDepsMakefile()->UpdateNoRuleAutomaticDependencies(pTarget);
- BuildDependencies(pRule,Target,TargetDate,YoungestDate,MakeTarget);
+ BuildDependencies(pRule,pTarget,TargetDate,YoungestDate,MakeTarget);
if (pRule)
{
@@ -1639,7 +1646,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building "<<Target->GetQuotedFullFileName()<<endl;
+ cout<<"Building "<<pTarget->GetQuotedFullFileName()<<endl;
}
#endif
if (!MakeTarget)
@@ -1651,12 +1658,12 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
{
if (!TargetDate.DoesExist())
{
- if (!m_ImplicitSearch && !Target->IsPhony())
- cout<<"Building "<<Target->GetQuotedFullFileName()<<" because it does not exist yet\n";
+ if (!m_ImplicitSearch && !pTarget->IsPhony())
+ cout<<"Building "<<pTarget->GetQuotedFullFileName()<<" because it does not exist yet\n";
}
else if (TargetDate.IsOlder(m_sBuildTime))
{
- cout<<"Building "<<Target->GetQuotedFullFileName()<<" because need to rebuild all (-a)\n";
+ cout<<"Building "<<pTarget->GetQuotedFullFileName()<<" because need to rebuild all (-a)\n";
}
}
#endif
@@ -1675,7 +1682,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
md5_starts( &ctx );
while (CommandIt!=Commands.end())
{
- pMakefile->SetRuleThatIsBuild(Target); // Make sure that the command expension is correct
+ pMakefile->SetRuleThatIsBuild(pTarget); // Make sure that the command expension is correct
string Command=pMakefile->ExpandExpression(*CommandIt);
pMakefile->ClearRuleThatIsBuild(); /* Make sure that further expansion is not taking this rule into account.*/
md5_update( &ctx, (uint8 *)Command.c_str(), (unsigned long)Command.size());
@@ -1683,20 +1690,20 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
}
uint32 Md5_32=md5_finish32( &ctx);
- if (!Target->CompareMd5_32(Md5_32))
+ if (!pTarget->CompareMd5_32(Md5_32))
{
if (TargetDate.IsNewerOrSame(m_sBuildTime) || TargetDate.IsDir())
{
// Only rebuild if it is not yet rebuild in this current run. This may happen for implicit rules that have multiple targets (implicit rules that build more then one target at the same time
- Target->SetCommandsMd5_32(Md5_32);
- pMakefile->AddTarget(Target);
+ pTarget->SetCommandsMd5_32(Md5_32);
+ pMakefile->AddTarget(pTarget);
pMakefile->SetAutoDepsDirty(); /* We need to update the autodeps file if the md5 has been changed */
}
else
{
#ifdef _DEBUG
if (!g_GenProjectTree)
- cout << "Md5 is different for " << Target->GetQuotedFullFileName() << " Old:"<<hex<<Target->GetCommandsMd5_32()<<", New: "<<Md5_32<<". Commandline must have been changed so recompiling\n";
+ cout << "Md5 is different for " << pTarget->GetQuotedFullFileName() << " Old:"<<hex<<pTarget->GetCommandsMd5_32()<<", New: "<<Md5_32<<". Commandline must have been changed so recompiling\n";
#endif
#ifdef _DEBUG
@@ -1714,10 +1721,9 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
if (MakeTarget)
{
// Queue for execution
-// Target->SetDate(YoungestDate);
- if (sm_CommandQueue.QueueTarget(Target))
+ if (sm_CommandQueue.QueueTarget(pTarget))
return mh_time_t();
- mh_time_t NewDate=Target->GetDate();
+ mh_time_t NewDate=pTarget->GetDate();
if (NewDate.IsNewer(YoungestDate))
YoungestDate=NewDate;
}
@@ -1728,7 +1734,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building "<<Target->GetQuotedFullFileName()<<" finished : "<< YoungestDate << endl;
+ cout<<"Building "<<pTarget->GetQuotedFullFileName()<<" finished : "<< YoungestDate << endl;
}
Indent--;
if (g_CheckCircularDeps)
@@ -1736,26 +1742,26 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr<fileinfo> &Target,bool
m_TargetStack.pop_back();
}
- if (!m_ImplicitSearch && !Target->Exists() && !Target->IsPhony() && !g_DoNotExecute && !g_GenProjectTree)
+ if (!m_ImplicitSearch && !pTarget->Exists() && !pTarget->IsPhony() && !g_DoNotExecute && !g_GenProjectTree)
{
// This is only a warning for phony messages
- cout<<"Warning: don't know how to make "<<Target->GetQuotedFullFileName()<<"\nMake the rule a phony rule to avoid this warning (but only do it when it is really phony).\n";;
+ cout<<"Warning: don't know how to make "<<pTarget->GetQuotedFullFileName()<<"\nMake the rule a phony rule to avoid this warning (but only do it when it is really phony).\n";;
}
#endif
- Target->SetDate(YoungestDate); /* This is especially needed for phony targets in between real targets */
+ pTarget->SetDate(YoungestDate); /* This is especially needed for phony targets in between real targets */
return YoungestDate;
}
///////////////////////////////////////////////////////////////////////////////
-mh_time_t mhmakefileparser::WaitBuildTarget(const refptr<fileinfo> &Target)
+mh_time_t mhmakefileparser::WaitBuildTarget(fileinfo* pTarget)
{
- return sm_CommandQueue.WaitForTarget(Target);
+ return sm_CommandQueue.WaitForTarget(pTarget);
}
///////////////////////////////////////////////////////////////////////////////
void mhmakefileparser::BuildIncludedMakefiles()
{
- vector< refptr<fileinfo> >::iterator MakefileIt=m_IncludedMakefiles.begin();
+ vector<fileinfo*>::iterator MakefileIt=m_IncludedMakefiles.begin();
while (MakefileIt!=m_IncludedMakefiles.end())
{
#ifdef _DEBUG
diff --git a/tools/mhmake/src/commandqueue.cpp b/tools/mhmake/src/commandqueue.cpp
index c09f505d7..fca26f997 100644
--- a/tools/mhmake/src/commandqueue.cpp
+++ b/tools/mhmake/src/commandqueue.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -114,7 +114,7 @@ void commandqueue::SetNrParallelBuilds(unsigned NrParallelBuilds)
void commandqueue::ThrowCommandExecutionError(refptr<activeentry> pActiveEntry)
{
- refptr<fileinfo> pTarget=pActiveEntry->pTarget;
+ fileinfo* pTarget=pActiveEntry->pTarget;
const string &Command=pActiveEntry->Command;
mhmakeparser *pMakefile=pTarget->GetRule()->GetMakefile();
@@ -166,7 +166,7 @@ void commandqueue::RemoveActiveEntry(unsigned Entry)
upon return */
bool commandqueue::StartExecuteNextCommand(refptr<activeentry> pActiveEntry, mh_pid_t *pActiveProcess)
{
- refptr<fileinfo> pTarget=pActiveEntry->pTarget;
+ fileinfo* pTarget=pActiveEntry->pTarget;
mhmakeparser *pMakefile=pTarget->GetRule()->GetMakefile();
pMakefile->SetRuleThatIsBuild(pTarget); // Make sure that the command expension is correct
@@ -208,7 +208,7 @@ bool commandqueue::StartExecuteNextCommand(refptr<activeentry> pActiveEntry, mh_
void commandqueue::TargetBuildFinished(refptr<activeentry> pActiveEntry)
{
- refptr<fileinfo> pTarget=pActiveEntry->pTarget;
+ fileinfo* pTarget=pActiveEntry->pTarget;
// Building of this target finished
uint32 Md5_32=md5_finish32( &pActiveEntry->md5ctx);
@@ -246,7 +246,7 @@ void commandqueue::TargetBuildFinished(refptr<activeentry> pActiveEntry)
/* Start executing the commands of a target
*/
-bool commandqueue::StartExecuteCommands(const refptr<fileinfo> &pTarget)
+bool commandqueue::StartExecuteCommands(fileinfo* pTarget)
{
cout << "Building " << pTarget->GetQuotedFullFileName()<<endl;
// We do not have to put it in the queue, we can start executing directly
@@ -287,7 +287,7 @@ bool commandqueue::StartExecuteCommands(const refptr<fileinfo> &pTarget)
/* put the target in the execution queue or start executing immediately
*/
-bool commandqueue::QueueTarget(const refptr<fileinfo> &pTarget)
+bool commandqueue::QueueTarget(fileinfo* pTarget)
{
pTarget->SetBuilding();
// First check if there is place in the active entries
@@ -306,7 +306,7 @@ bool commandqueue::QueueTarget(const refptr<fileinfo> &pTarget)
/* Wait for all the commands being executed of a target. In the mean time also continue
executing all other commands in the queue
*/
-mh_time_t commandqueue::WaitForTarget(const refptr<fileinfo> &pTarget)
+mh_time_t commandqueue::WaitForTarget(fileinfo *pTarget)
{
if (!pTarget->IsBuilding())
return pTarget->GetDate();
@@ -331,7 +331,7 @@ mh_time_t commandqueue::WaitForTarget(const refptr<fileinfo> &pTarget)
throw("fatal error: unexpected return value of WaitForMultipleObjects " + stringify(Ret));
#endif
refptr<activeentry> pActiveEntry=m_pActiveEntries[Ret];
- refptr<fileinfo> pCurrentTarget=pActiveEntry->pTarget;
+ fileinfo* pCurrentTarget=pActiveEntry->pTarget;
refptr<rule> pRule=pCurrentTarget->GetRule();
// First check the error code of the command
@@ -391,7 +391,7 @@ mh_time_t commandqueue::WaitForTarget(const refptr<fileinfo> &pTarget)
}
else
{
- refptr<fileinfo> pNewTarget=m_Queue.front();
+ fileinfo* pNewTarget=m_Queue.front();
m_Queue.pop();
if (StartExecuteCommands(pNewTarget))
{
diff --git a/tools/mhmake/src/commandqueue.h b/tools/mhmake/src/commandqueue.h
index d29057443..8b327be8c 100644
--- a/tools/mhmake/src/commandqueue.h
+++ b/tools/mhmake/src/commandqueue.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,14 +33,14 @@ class commandqueue
{
struct activeentry : public refbase
{
- refptr<fileinfo> pTarget;
+ fileinfo* pTarget;
vector<string>::const_iterator CurrentCommandIt;
string Command;
md5_context md5ctx;
bool IgnoreError;
};
private:
- queue< refptr<fileinfo> > m_Queue;
+ queue<fileinfo*> m_Queue;
unsigned m_MaxNrCommandsInParallel;
mh_pid_t *m_pActiveProcesses;
refptr<activeentry> *m_pActiveEntries;
@@ -56,7 +56,7 @@ private:
{
RemoveActiveEntry(GetActiveEntryId(pActiveEntry));
}
- bool StartExecuteCommands(const refptr<fileinfo> &pTarget);
+ bool StartExecuteCommands(fileinfo *pTarget);
bool StartExecuteNextCommand(refptr<activeentry> pActiveEntry, mh_pid_t *pActiveProcess);
void TargetBuildFinished(refptr<activeentry> pActiveEntry);
@@ -64,8 +64,8 @@ public:
commandqueue();
~commandqueue();
- bool QueueTarget(const refptr<fileinfo> &pTarget); // Returns true if target has been queued, false when commands are executed upon return
- mh_time_t WaitForTarget(const refptr<fileinfo> &pTarget);
+ bool QueueTarget(fileinfo *pTarget); // Returns true if target has been queued, false when commands are executed upon return
+ mh_time_t WaitForTarget(fileinfo *pTarget);
void SetNrParallelBuilds(unsigned NrParallelBuilds);
};
diff --git a/tools/mhmake/src/curdir.cpp b/tools/mhmake/src/curdir.cpp
index 094093a9b..4b905a327 100644
--- a/tools/mhmake/src/curdir.cpp
+++ b/tools/mhmake/src/curdir.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,20 +24,14 @@
#include "curdir.h"
#include "util.h"
-set<refptr<fileinfo>,less_refptrfileinfo> g_FileInfos; // declare here since it is important that it is constructed before m_pcurrentdir
+fileinfos g_FileInfos; // declare here since it is important that it is constructed before m_pcurrentdir
curdir::initcurdir curdir::m_pCurrentDir;
///////////////////////////////////////////////////////////////////////////////
-curdir::initcurdir &curdir::initcurdir::operator=(const refptr<fileinfo>& Src)
-{
- return (curdir::initcurdir&)refptr<fileinfo>::operator=(Src);
-}
-
-///////////////////////////////////////////////////////////////////////////////
curdir::initcurdir::initcurdir()
{
char CurDir[MAX_PATH];
getcwd(CurDir,MAX_PATH);
string strCurDir=CurDir;
- *this=GetAbsFileInfo(NormalizePathName(strCurDir));
+ m_pDir=GetAbsFileInfo(NormalizePathName(strCurDir));
}
diff --git a/tools/mhmake/src/curdir.h b/tools/mhmake/src/curdir.h
index 169dca8a7..56f835fbe 100644
--- a/tools/mhmake/src/curdir.h
+++ b/tools/mhmake/src/curdir.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,26 +21,25 @@
#ifndef __CURDIR_H
#define __CURDIR_H
-#include "refptr.h"
class fileinfo;
class curdir
{
public:
- class initcurdir : public refptr<fileinfo>
+ class initcurdir
{
+ friend curdir;
+ const fileinfo *m_pDir;
public:
- initcurdir &operator=(const refptr<fileinfo>& Src);
-
initcurdir();
};
private:
static initcurdir m_pCurrentDir;
public:
- static refptr<fileinfo> &GetCurDir()
+ static const fileinfo* GetCurDir()
{
- return m_pCurrentDir;
+ return m_pCurrentDir.m_pDir;
}
};
diff --git a/tools/mhmake/src/fileinfo.cpp b/tools/mhmake/src/fileinfo.cpp
index d63724882..7174c49a4 100644
--- a/tools/mhmake/src/fileinfo.cpp
+++ b/tools/mhmake/src/fileinfo.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,9 +29,6 @@
#define S_ISDIR(val) ((val)&_S_IFDIR)
#endif
-const string NullString;
-refptr<fileinfo> NullFileInfo;
-
///////////////////////////////////////////////////////////////////////////////
string QuoteFileName(const string &Filename)
{
@@ -78,7 +75,7 @@ string UnquoteFileName(const string &Filename)
}
///////////////////////////////////////////////////////////////////////////////
-refptr<fileinfo> fileinfo::GetDir() const
+fileinfo* fileinfo::GetDir() const
{
return GetAbsFileInfo(m_AbsFileName.substr(0,m_AbsFileName.find_last_of(OSPATHSEP)));
}
@@ -90,15 +87,15 @@ string fileinfo::GetName() const
}
///////////////////////////////////////////////////////////////////////////////
-mh_time_t fileinfo::realGetDate()
+mh_time_t fileinfo::realGetDate() const
{
struct stat Buf;
if (-1==stat(m_AbsFileName.c_str(),&Buf))
- m_Date.SetNotExist();
+ ((fileinfo*)this)->m_Date.SetNotExist();
else if (S_ISDIR(Buf.st_mode))
- m_Date.SetDir();
+ ((fileinfo*)this)->m_Date.SetDir();
else
- m_Date=Buf.st_mtime;
+ ((fileinfo*)this)->m_Date=Buf.st_mtime;
return m_Date;
}
@@ -145,7 +142,7 @@ string fileinfo::GetPrerequisits() const
{
// Build a string with all prerequisits, but make sure that every dependency
// is only in there once (we do this be building a set in parallel
- vector< refptr<fileinfo> >::const_iterator DepIt=m_Deps.begin();
+ vector<fileinfo*>::const_iterator DepIt=m_Deps.begin();
deps_t Deps;
bool first=true;
string Ret=g_EmptyString;
@@ -171,10 +168,10 @@ string fileinfo::GetPrerequisits() const
}
///////////////////////////////////////////////////////////////////////////////
-void fileinfo::AddDeps(vector< refptr<fileinfo> > &Deps)
+void fileinfo::AddDeps(vector<fileinfo*> &Deps)
{
- vector< refptr<fileinfo> >::iterator It=Deps.begin();
- vector< refptr<fileinfo> >::iterator ItEnd=Deps.end();
+ vector<fileinfo*>::iterator It=Deps.begin();
+ vector<fileinfo*>::iterator ItEnd=Deps.end();
while (It!=ItEnd)
{
AddDep(*It++);
@@ -293,7 +290,7 @@ string &NormalizePathName(string &Name)
///////////////////////////////////////////////////////////////////////////////
-const refptr<fileinfo> &GetFileInfo(const string &NameIn,const refptr<fileinfo> &RelDir)
+fileinfo* GetFileInfo(const string &NameIn,const fileinfo* pRelDir)
{
string Name=UnquoteFileName(NameIn);
bool DoesExist=true;
@@ -305,36 +302,36 @@ const refptr<fileinfo> &GetFileInfo(const string &NameIn,const refptr<fileinfo>
{
if (Name[0]!=OSPATHSEP)
{
- Name=RelDir->GetFullFileName()+OSPATHSEPSTR+Name;
- if (!RelDir->Exists()) /* if the directory does not exist, the file will not exist either */
+ Name=pRelDir->GetFullFileName()+OSPATHSEPSTR+Name;
+ if (!pRelDir->Exists()) /* if the directory does not exist, the file will not exist either */
DoesExist=false;
}
#ifdef WIN32
else
{
/* The filename is absolute but does not contain a driver letter. So add it (only on windows) */
- Name=RelDir->GetFullFileName().substr(0,2)+Name;
+ Name=pRelDir->GetFullFileName().substr(0,2)+Name;
}
#endif
}
- const refptr<fileinfo> &Ret=GetAbsFileInfo(NormalizePathName(Name));
+ fileinfo* pRet=GetAbsFileInfo(NormalizePathName(Name));
if (!DoesExist)
- Ret->SetNotExist();
- return Ret;
+ pRet->SetNotExist();
+ return pRet;
}
#ifdef _DEBUG
///////////////////////////////////////////////////////////////////////////////
void PrintFileInfos()
{
- set<refptr<fileinfo>,less_refptrfileinfo>::iterator pIt=g_FileInfos.begin();
+ fileinfos::iterator pIt=g_FileInfos.begin();
while (pIt!=g_FileInfos.end())
{
cout<<(*pIt)->GetQuotedFullFileName()<<" :";
if ((*pIt)->IsPhony())
cout<<" (phony)";
- vector< refptr<fileinfo> > &Deps=(*pIt)->GetDeps();
- vector< refptr<fileinfo> >::iterator pDepIt=Deps.begin();
+ vector<fileinfo*> &Deps=(*pIt)->GetDeps();
+ vector<fileinfo*>::iterator pDepIt=Deps.begin();
while (pDepIt!=Deps.end())
{
cout<<g_SpaceString<<(*pDepIt)->GetQuotedFullFileName();
@@ -354,3 +351,13 @@ void PrintFileInfos()
}
#endif
+///////////////////////////////////////////////////////////////////////////////
+fileinfos::~fileinfos()
+{
+ fileinfos::iterator It=begin();
+ while (It!=end())
+ {
+ delete (*It);
+ It++;
+ }
+}
diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h
index 3c7917be3..8d58a1efa 100644
--- a/tools/mhmake/src/fileinfo.h
+++ b/tools/mhmake/src/fileinfo.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -130,22 +130,21 @@ inline ostream& operator<<(ostream& out,const mh_time &Src)
return out;
}
-class fileinfo : public refbase
+class fileinfo
{
string m_AbsFileName;
bool m_IsPhony;
int m_BuildStatus; /* Bit 0 means the target built is started, Bit 1 means the target is still building */
refptr<rule> m_pRule;
mhmakeparser *m_pAutoDepsMakefile;
- vector< refptr<fileinfo> > m_Deps;
+ vector<fileinfo*> m_Deps;
mh_time_t m_Date;
uint32 m_CommandsMd5_32; // 32-bit Md5 checksum of commands to build this target
fileinfo(const fileinfo &Src);
fileinfo(void);
-public:
- fileinfo(const string &AbsFileName,uint32 Md5_32)
+ void init(const string &AbsFileName,uint32 Md5_32)
{
m_IsPhony=false;
m_pAutoDepsMakefile=NULL;
@@ -158,9 +157,15 @@ public:
cout << "Initialising Md5 of "<<GetQuotedFullFileName().c_str()<<" to 0x"<<hex<<Md5_32<<endl;
#endif
}
+ fileinfo &operator = (const fileinfo &Src); // Do not allow copying
+public:
+ fileinfo(const string &AbsFileName,uint32 Md5_32)
+ {
+ init(AbsFileName,Md5_32);
+ }
fileinfo(const string &AbsFileName)
{
- new (this) fileinfo(AbsFileName,0);
+ init(AbsFileName,0);
}
/* The following constructor is only used for name comparisons, and should only be used for that */
fileinfo(int Dummy,const string &AbsFileName)
@@ -170,14 +175,11 @@ public:
fileinfo(const char *szFile)
{
- new (this) fileinfo(string(szFile));
+ init(szFile,0);
}
fileinfo(const char *szFile,uint32 Md5_32)
{
- new (this) fileinfo(string(szFile),Md5_32);
- }
- ~fileinfo()
- {
+ init(szFile,Md5_32);
}
const string &GetFullFileName(void) const
{
@@ -194,13 +196,8 @@ public:
if (!m_AbsFileName.empty() && m_AbsFileName[m_AbsFileName.length()-1]==OSPATHSEP)
m_AbsFileName.resize(m_AbsFileName.length()-1);
}
- fileinfo &operator = (const fileinfo &Src)
- {
- new (this) fileinfo(Src);
- return *this;
- }
- refptr<fileinfo> GetDir(void) const;
+ fileinfo* GetDir(void) const;
string GetName() const;
bool IsDir() const;
@@ -241,28 +238,28 @@ public:
}
}
- refptr<rule> GetRule(void)
+ refptr<rule> GetRule(void) const
{
return m_pRule;
}
- void AddDep(const refptr<fileinfo> &Dep)
+ void AddDep(fileinfo *pDep)
{
- if (&*Dep==this)
+ if (&*pDep==this)
{
#ifdef _DEBUG
cout << GetQuotedFullFileName()<<" is directly dependent on itself\n";
#endif
return;
}
- m_Deps.push_back(Dep);
+ m_Deps.push_back(pDep);
}
- void AddDeps(vector< refptr<fileinfo> > &Deps);
+ void AddDeps(vector<fileinfo*> &Deps);
- void InsertDeps(vector< refptr<fileinfo> > &Deps)
+ void InsertDeps(vector<fileinfo*> &Deps)
{
- vector< refptr<fileinfo> > NewDeps;
- vector< refptr<fileinfo> >::const_iterator It=Deps.begin();
- vector< refptr<fileinfo> >::const_iterator ItEnd=Deps.end();
+ vector<fileinfo*> NewDeps;
+ vector<fileinfo*>::const_iterator It=Deps.begin();
+ vector<fileinfo*>::const_iterator ItEnd=Deps.end();
while (It!=ItEnd)
{
if (&**It==this)
@@ -278,18 +275,18 @@ public:
if (NewDeps.size())
m_Deps.insert(m_Deps.begin(),NewDeps.begin(),NewDeps.end());
}
- void AddMainDep(refptr<fileinfo> &MainDep)
+ void AddMainDep(fileinfo* pMainDep)
{
- if (&*MainDep==this)
+ if (&*pMainDep==this)
{
#ifdef _DEBUG
cout << GetQuotedFullFileName()<<" is directly dependent on itself\n";
#endif
return;
}
- m_Deps.insert(m_Deps.begin(),MainDep);
+ m_Deps.insert(m_Deps.begin(),pMainDep);
}
- vector< refptr<fileinfo> > &GetDeps(void)
+ vector<fileinfo*> &GetDeps(void)
{
return m_Deps;
}
@@ -311,11 +308,11 @@ public:
m_IsPhony=true;
m_Date.SetNotExist(); // This will sure that this target will always be build (even if a corresponding file exists)
}
- bool IsPhony(void)
+ bool IsPhony(void) const
{
return m_IsPhony;
}
- mh_time_t realGetDate(void);
+ mh_time_t realGetDate(void) const;
void SetDateToNow(void);
void SetDate(mh_time_t Date)
@@ -332,7 +329,7 @@ public:
m_Date.Invalidate();
}
- mh_time_t GetDate(void)
+ mh_time_t GetDate(void) const
{
if (m_Date.IsDateValid())
return m_Date;
@@ -343,7 +340,7 @@ public:
{ // this is used to make sure that this item is rebuild, even if it really exists
m_Date.SetNotExist();
}
- bool Exists(void)
+ bool Exists(void) const
{
return GetDate().DoesExist();
}
@@ -402,14 +399,6 @@ public:
}
};
-struct less_refptrfileinfo : public binary_function <refptr<fileinfo>, refptr<fileinfo>, bool>
-{
- bool operator()(const refptr<fileinfo>& _Left, const refptr<fileinfo>& _Right) const
- {
- return less<string>().operator ()(_Left->GetFullFileName(),_Right->GetFullFileName());
- }
-};
-
struct less_fileinfo : public binary_function <const fileinfo*, const fileinfo*, bool>
{
bool operator()(const fileinfo *_Left, const fileinfo *_Right) const
@@ -418,31 +407,34 @@ struct less_fileinfo : public binary_function <const fileinfo*, const fileinfo*,
}
};
-extern const string NullString;
-extern refptr<fileinfo> NullFileInfo;
+fileinfo *GetFileInfo(const string &szName,const fileinfo* pRelDir);
-const refptr<fileinfo> &GetFileInfo(const string &szName,const refptr<fileinfo> &pRelDir);
+class fileinfos : public set<fileinfo*,less_fileinfo>
+{
+ public:
+ ~fileinfos();
+};
-extern set<refptr<fileinfo>,less_refptrfileinfo > g_FileInfos;
+extern fileinfos g_FileInfos;
-inline const refptr<fileinfo> &GetAbsFileInfo(const string &strAbsName)
+inline fileinfo *GetAbsFileInfo(const string &strAbsName)
{
- static refptr<fileinfo> SearchFileInfo(new fileinfo(""));
- SearchFileInfo->SetFullFileName(strAbsName);
+ static fileinfo SearchFileInfo("");
+ SearchFileInfo.SetFullFileName(strAbsName);
/* Using find is just an optimalisation, you could use insert immediately */
- set<refptr<fileinfo>,less_refptrfileinfo >::const_iterator pFind=g_FileInfos.find(SearchFileInfo);
+ fileinfos::const_iterator pFind=g_FileInfos.find(&SearchFileInfo);
if (pFind==g_FileInfos.end())
{
- pair <set<refptr<fileinfo>,less_refptrfileinfo >::iterator, bool> pPair=g_FileInfos.insert(new fileinfo(SearchFileInfo->GetFullFileName()));
+ pair <fileinfos::iterator, bool> pPair=g_FileInfos.insert(new fileinfo(SearchFileInfo.GetFullFileName()));
return *(pPair.first);
}
else
return *pFind;
}
-inline const refptr<fileinfo> &GetFileInfo(const char *szName,const refptr<fileinfo> &RelDir)
+inline fileinfo *GetFileInfo(const char *szName,const fileinfo* pRelDir)
{
- return GetFileInfo(string(szName),RelDir);
+ return GetFileInfo(string(szName),pRelDir);
}
string &NormalizePathName(string &Name);
diff --git a/tools/mhmake/src/flexskel.cc b/tools/mhmake/src/flexskel.cc
index a08f23fd3..e83775372 100644
--- a/tools/mhmake/src/flexskel.cc
+++ b/tools/mhmake/src/flexskel.cc
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha_at_sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/flexskel.h b/tools/mhmake/src/flexskel.h
index 563e469c7..69d0eeeb4 100644
--- a/tools/mhmake/src/flexskel.h
+++ b/tools/mhmake/src/flexskel.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/functions.cpp b/tools/mhmake/src/functions.cpp
index b1a5f7a46..97dc99c01 100644
--- a/tools/mhmake/src/functions.cpp
+++ b/tools/mhmake/src/functions.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -351,45 +351,45 @@ string mhmakefileparser::f_firstword(const string & Arg) const
///////////////////////////////////////////////////////////////////////////////
string mhmakefileparser::f_wildcard(const string & Arg) const
{
- refptr<fileinfo> FileSpec=GetFileInfo(TrimString(Arg),m_MakeDir); /* Use GetFileInfo to make the relative path absolute */
- refptr<fileinfo> Dir=FileSpec->GetDir();
+ fileinfo *pFileSpec=GetFileInfo(TrimString(Arg),m_MakeDir); /* Use GetFileInfo to make the relative path absolute */
+ fileinfo *pDir=pFileSpec->GetDir();
#ifdef WIN32
struct _finddata_t FileInfo;
- intptr_t hFile=_findfirst(FileSpec->GetFullFileName().c_str(),&FileInfo);
+ intptr_t hFile=_findfirst(pFileSpec->GetFullFileName().c_str(),&FileInfo);
if (hFile==-1)
return g_EmptyString;
string Ret=g_EmptyString;
/* We have to verify with percentmatch since the find functions *.ext also matches the functions *.extbrol */
- string CheckSpec=FileSpec->GetName();
- if (PercentMatch(FileInfo.name,CheckSpec,NULL,'*'))
+ string CheckSpec=pFileSpec->GetName();
+ if (PercentMatchNoCase(FileInfo.name,CheckSpec,NULL,'*'))
{
- Ret=GetFileInfo(FileInfo.name,Dir)->GetQuotedFullFileName();
+ Ret=GetFileInfo(FileInfo.name,pDir)->GetQuotedFullFileName();
}
while (-1!=_findnext(hFile,&FileInfo))
{
- if (PercentMatch(FileInfo.name,CheckSpec,NULL,'*'))
+ if (PercentMatchNoCase(FileInfo.name,CheckSpec,NULL,'*'))
{
Ret+=g_SpaceString;
- Ret+=GetFileInfo(FileInfo.name,Dir)->GetQuotedFullFileName();
+ Ret+=GetFileInfo(FileInfo.name,pDir)->GetQuotedFullFileName();
}
}
_findclose(hFile);
#else
glob_t Res;
- if (glob (FileSpec->GetFullFileName().c_str(), GLOB_ERR|GLOB_NOSORT|GLOB_MARK, NULL, &Res))
+ if (glob (pFileSpec->GetFullFileName().c_str(), GLOB_ERR|GLOB_NOSORT|GLOB_MARK, NULL, &Res))
return g_EmptyString;
string Ret=g_EmptyString;
string SepStr=g_EmptyString;
- string CheckSpec=FileSpec->GetName();
+ string CheckSpec=pFileSpec->GetName();
for (int i=0; i<Res.gl_pathc; i++)
{
if (PercentMatch(Res.gl_pathv[i],CheckSpec,NULL,'*'))
{
Ret+=SepStr;
- Ret+=GetFileInfo(Res.gl_pathv[i],Dir)->GetQuotedFullFileName();
+ Ret+=GetFileInfo(Res.gl_pathv[i],pDir)->GetQuotedFullFileName();
SepStr=g_SpaceString;
}
}
@@ -403,7 +403,7 @@ string mhmakefileparser::f_wildcard(const string & Arg) const
string mhmakefileparser::f_exist(const string & Arg) const
{
string File=TrimString(Arg);
- refptr<fileinfo> pFile=GetFileInfo(File,m_MakeDir);
+ fileinfo *pFile=GetFileInfo(File,m_MakeDir);
if (pFile->Exists())
{
return string("1");
@@ -427,7 +427,7 @@ string mhmakefileparser::f_filesindirs(const string & Arg) const
string strDirs;
NextCharItem(pTmp,strDirs,',');
- vector< refptr<fileinfo> > Dirs;
+ vector<fileinfo*> Dirs;
SplitToItems(strDirs,Dirs);
pTmp=strFiles.c_str();
@@ -436,11 +436,11 @@ string mhmakefileparser::f_filesindirs(const string & Arg) const
while (*pTmp)
{
string File;
- refptr<fileinfo> pFile;
+ fileinfo *pFile;
pTmp=NextItem(pTmp,File);
- vector< refptr<fileinfo> >::iterator It=Dirs.begin();
- vector< refptr<fileinfo> >::iterator ItEnd=Dirs.end();
+ vector<fileinfo*>::iterator It=Dirs.begin();
+ vector<fileinfo*>::iterator ItEnd=Dirs.end();
while (It!=ItEnd)
{
pFile=GetFileInfo(File,*It++);
@@ -448,7 +448,7 @@ string mhmakefileparser::f_filesindirs(const string & Arg) const
{
break;
}
- pFile=NullFileInfo;
+ pFile=NULL;
}
if (!pFile)
continue;
@@ -471,7 +471,7 @@ string mhmakefileparser::f_filesindirs(const string & Arg) const
string mhmakefileparser::f_fullname(const string & Arg) const
{
string File=TrimString(Arg);
- refptr<fileinfo> pFile=GetFileInfo(File,m_MakeDir);
+ fileinfo *pFile=GetFileInfo(File,m_MakeDir);
return pFile->GetQuotedFullFileName();
}
@@ -674,26 +674,26 @@ string mhmakefileparser::f_shell(const string & Command) const
///////////////////////////////////////////////////////////////////////////////
static string relpath(const string &FileName,void *pvDir)
{
- const refptr<fileinfo> pDir=*(const refptr<fileinfo> *)pvDir;
- refptr<fileinfo> Path=GetFileInfo(FileName,pDir);
+ const fileinfo *pDir=*(const fileinfo **)pvDir;
+ const fileinfo *pPath=GetFileInfo(FileName,pDir);
const char *pCur=pDir->GetFullFileName().c_str();
- const char *pPath=Path->GetFullFileName().c_str();
+ const char *pszPath=pPath->GetFullFileName().c_str();
- const char *pLast=pPath;
- while (*pCur==*pPath)
+ const char *pLast=pszPath;
+ while (*pCur==*pszPath)
{
- char Char=*pPath;
+ char Char=*pszPath;
if (!Char)
{
return "."; // Means that FileName is the same as the current directory
}
if (Char==OSPATHSEP)
- pLast=pPath+1;
+ pLast=pszPath+1;
pCur++;
- pPath++;
+ pszPath++;
}
- if (*pPath==OSPATHSEP && !*pCur)
- pLast=pPath+1;
+ if (*pszPath==OSPATHSEP && !*pCur)
+ pLast=pszPath+1;
string retPath;
if (*pCur==OSPATHSEP) {
bool first=true;
@@ -705,7 +705,7 @@ static string relpath(const string &FileName,void *pvDir)
retPath+=OSPATHSEPSTR"..";
pCur++;
}
- if (pPath)
+ if (pszPath)
retPath=retPath+OSPATHSEPSTR+pLast;
}
else
diff --git a/tools/mhmake/src/md5.cpp b/tools/mhmake/src/md5.cpp
index 908f28134..0ffba0d48 100644
--- a/tools/mhmake/src/md5.cpp
+++ b/tools/mhmake/src/md5.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/md5.h b/tools/mhmake/src/md5.h
index d2e3ef62f..f16c9bd19 100644
--- a/tools/mhmake/src/md5.h
+++ b/tools/mhmake/src/md5.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/mhmake.cpp b/tools/mhmake/src/mhmake.cpp
index db9a13682..6d99e5f3d 100644
--- a/tools/mhmake/src/mhmake.cpp
+++ b/tools/mhmake/src/mhmake.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -120,17 +120,17 @@ int __CDECL main(int argc, char* argv[])
{
g_Clean=true;
}
- refptr<fileinfo> pTarget=GetFileInfo(*It,pFirstMakefile->m_MakeDir);
+ fileinfo *pTarget=GetFileInfo(*It,pFirstMakefile->m_MakeDir);
pFirstMakefile->m_pParser->BuildTarget(pTarget);
It++;
}
}
else
{
- refptr<fileinfo> FirstTarget=pFirstMakefile->m_pParser->GetFirstTarget();
- if (FirstTarget)
+ fileinfo *pFirstTarget=pFirstMakefile->m_pParser->GetFirstTarget();
+ if (pFirstTarget)
{
- pFirstMakefile->m_pParser->BuildTarget(FirstTarget);
+ pFirstMakefile->m_pParser->BuildTarget(pFirstTarget);
}
else
cout << "Warning: no targets in makefile. Nothing to be build.\nMHMAKECONF defined?\n";
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index 8c75f78f7..3d074e801 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ void mhmakefileparser::yyerror(const char *m)
}
///////////////////////////////////////////////////////////////////////////////
-int mhmakefileparser::ParseFile(const refptr<fileinfo> &FileInfo, refptr<fileinfo> &pMakeDir)
+int mhmakefileparser::ParseFile(const fileinfo *pFileInfo, const fileinfo *pMakeDir)
{
mhmakelexer theLexer;
m_ptheLexer=&theLexer;
@@ -51,12 +51,12 @@ int mhmakefileparser::ParseFile(const refptr<fileinfo> &FileInfo, refptr<fileinf
m_MakeDir=pMakeDir;
m_Variables[CURDIR]=m_MakeDir->GetQuotedFullFileName();
}
- theLexer.m_InputFileName=FileInfo->GetFullFileName();
+ theLexer.m_InputFileName=pFileInfo->GetFullFileName();
theLexer.m_pParser=(mhmakeparser*)this;
- theLexer.yyin=::fopen(FileInfo->GetFullFileName().c_str(),"r");
+ theLexer.yyin=::fopen(pFileInfo->GetFullFileName().c_str(),"r");
if (!theLexer.yyin)
{
- cerr << "Error opening makefile: "<<FileInfo->GetQuotedFullFileName()<<endl;
+ cerr << "Error opening makefile: "<<pFileInfo->GetQuotedFullFileName()<<endl;
return 1;
}
int Ret=yyparse();
@@ -371,7 +371,7 @@ string mhmakefileparser::ExpandVar(const string &Var) const
}
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::SplitToItems(const string &String,vector< refptr<fileinfo> > &Items) const
+void mhmakefileparser::SplitToItems(const string &String,vector<fileinfo*> &Items) const
{
const char *pTmp=String.c_str();
while (*pTmp)
@@ -453,7 +453,7 @@ void mhmakefileparser::PrintVariables(bool Expand) const
///////////////////////////////////////////////////////////////////////////////
void mhmakefileparser::AddRule()
{
- vector< refptr<fileinfo> >::iterator pIt=m_pCurrentItems->begin();
+ fileinfoarray::iterator pIt=m_pCurrentItems->begin();
while (pIt!=m_pCurrentItems->end())
{
if ((*pIt)->GetFullFileName().find('%')!=string::npos)
@@ -484,10 +484,10 @@ void mhmakefileparser::AddRule()
}
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Autodeps)
+void mhmakefileparser::GetAutoDeps(const fileinfo *pFirstDep, deps_t &Autodeps)
{
/* Here we have to scan only c/c++ headers so skip certain extensions */
- const char *pFullName=FirstDep->GetFullFileName().c_str();
+ const char *pFullName=pFirstDep->GetFullFileName().c_str();
const char *pExt=strrchr(pFullName,'.');
bool bPython=false;
if (pExt)
@@ -574,7 +574,7 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Aut
#endif
if (Type[0]=='"')
{
- refptr<fileinfo> pInclude=GetFileInfo(IncludeFile,FirstDep->GetDir());
+ fileinfo *pInclude=GetFileInfo(IncludeFile,pFirstDep->GetDir());
/* Add the dependency when the file alrady exist or there is a rule available to be build */
mh_time_t Date=BuildTarget(pInclude);
if (Date.DoesExist()) // Try to build the target, and add it if it exists after building
@@ -588,10 +588,10 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Aut
}
}
const refptr<fileinfoarray> IncludeDirs=GetIncludeDirs();
- vector< refptr<fileinfo> >::const_iterator It=IncludeDirs->begin();
+ fileinfoarray::const_iterator It=IncludeDirs->begin();
while (It<IncludeDirs->end())
{
- refptr<fileinfo> pInclude=GetFileInfo(IncludeFile,*It);
+ fileinfo *pInclude=GetFileInfo(IncludeFile,*It);
mh_time_t Date=BuildTarget(pInclude);
if (Date.DoesExist()) // Try to build the target, and add it if it exists after building
{
@@ -618,20 +618,20 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Aut
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::GetAutoDepsIfNeeded(const refptr<fileinfo> &Target, const refptr<fileinfo>&FirstDep)
+void mhmakefileparser::GetAutoDepsIfNeeded(fileinfo *pTarget, const fileinfo *pFirstDep)
{
- autodeps_entry_t &Autodeps=m_AutoDeps[Target];
+ autodeps_entry_t &Autodeps=m_AutoDeps[pTarget];
if (!Autodeps.first)
{
Autodeps.first=true;
/* We are going to rescan, so throw away the old. */
Autodeps.second.clear();
- GetAutoDeps(FirstDep,Autodeps.second);
+ GetAutoDeps(pFirstDep,Autodeps.second);
// Now add these dependencies also to the rules
deps_t::iterator It=Autodeps.second.begin();
while (It!=Autodeps.second.end())
{
- Target->AddDep(*It);
+ pTarget->AddDep(*It);
It++;
}
}
@@ -639,31 +639,31 @@ void mhmakefileparser::GetAutoDepsIfNeeded(const refptr<fileinfo> &Target, const
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::UpdateAutomaticDependencies(const refptr<fileinfo> &Target)
+void mhmakefileparser::UpdateAutomaticDependencies(fileinfo *pTarget)
{
- if (Target->IsAutoDepExtention())
+ if (pTarget->IsAutoDepExtention())
{
// we have to search for the include files in the first dependency of Target
- vector< refptr<fileinfo> > &Deps=Target->GetDeps();
+ vector<fileinfo*> &Deps=pTarget->GetDeps();
if (!Deps.size())
return; // There is no first dep
- refptr<fileinfo> FirstDep=Deps[0];
- GetAutoDepsIfNeeded(Target,FirstDep);
+ fileinfo *pFirstDep=Deps[0];
+ GetAutoDepsIfNeeded(pTarget,pFirstDep);
SetAutoDepsDirty();
}
}
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::UpdateNoRuleAutomaticDependencies(const refptr<fileinfo> &Target)
+void mhmakefileparser::UpdateNoRuleAutomaticDependencies(fileinfo *pTarget)
{
// we have to search for the include files in the Target
- set< refptr<fileinfo> > Autodeps;
- GetAutoDeps(Target,Autodeps);
+ deps_t Autodeps;
+ GetAutoDeps(pTarget,Autodeps);
// Now add these dependencies also to the rules
- set< refptr<fileinfo> >::iterator It=Autodeps.begin();
+ deps_t::iterator It=Autodeps.begin();
while (It!=Autodeps.end())
{
- Target->AddDep(*It);
+ pTarget->AddDep(*It);
It++;
}
}
@@ -683,7 +683,7 @@ const refptr<fileinfoarray> mhmakefileparser::GetIncludeDirs() const
{
string Item;
pTmp=NextItem(pTmp,Item);
- refptr<fileinfo> pIncDir=GetFileInfo(Item,m_MakeDir);
+ fileinfo *pIncDir=GetFileInfo(Item,m_MakeDir);
if (pIncDir->Exists() || pIncDir->GetRule())
((mhmakefileparser*)this)->m_pIncludeDirs->push_back(pIncDir);
}
@@ -712,25 +712,25 @@ static void ReadStr(FILE *pFile,char *Str)
Str[i]='\0';
}
-void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
+void mhmakefileparser::LoadAutoDepsFile(fileinfo *pDepFile)
{
- if (m_AutoDepFileLoaded && m_AutoDepFileLoaded==DepFile)
+ if (m_AutoDepFileLoaded && m_AutoDepFileLoaded==pDepFile)
return; /* This autodep file is already loaded. */
- m_AutoDepFileLoaded=DepFile;
+ m_AutoDepFileLoaded=pDepFile;
- FILE *pIn=fopen(DepFile->GetFullFileName().c_str(),"rb");
+ FILE *pIn=fopen(pDepFile->GetFullFileName().c_str(),"rb");
#ifdef _DEBUG
if (!pIn)
{
- cerr << "Error opening autodep file "<<DepFile->GetQuotedFullFileName()<<endl;
+ cerr << "Error opening autodep file "<<pDepFile->GetQuotedFullFileName()<<endl;
return;
}
#endif
fread(&m_EnvMd5_32,sizeof(m_EnvMd5_32),1,pIn);
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Reading Env Md5 from "<<DepFile->GetQuotedFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl;
+ cout << "Reading Env Md5 from "<<pDepFile->GetQuotedFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl;
#endif
char UsedEnvVars[1024];
ReadStr(pIn,UsedEnvVars);
@@ -740,16 +740,16 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
ReadStr(pIn,FileName);
while (FileName[0])
{
- refptr<fileinfo> Target=GetFileInfo(FileName,m_MakeDir);
- autodeps_entry_t &Autodeps=m_AutoDeps[Target];
+ fileinfo *pTarget=GetFileInfo(FileName,m_MakeDir);
+ autodeps_entry_t &Autodeps=m_AutoDeps[pTarget];
ReadStr(pIn,FileName);
while (FileName[0])
{
if (!g_ForceAutoDepRescan) /* If we are forcing the autodepscan we do not have to load the dependencies. */
{
- refptr<fileinfo> Dep=GetFileInfo(FileName,m_MakeDir);
- Autodeps.second.insert(Dep);
- Target->AddDep(Dep);
+ fileinfo *pDep=GetFileInfo(FileName,m_MakeDir);
+ Autodeps.second.insert(pDep);
+ pTarget->AddDep(pDep);
}
ReadStr(pIn,FileName);
}
@@ -761,20 +761,23 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
while (fread(&Md5_32,sizeof(Md5_32),1,pIn))
{
ReadStr(pIn,FileName);
- pair <set<refptr<fileinfo>,less_refptrfileinfo >::iterator, bool> pPair=g_FileInfos.insert(new fileinfo(FileName,Md5_32));
- if (!pPair.second)
+
+ fileinfo *pTarget=GetAbsFileInfo(FileName);
+
+ if (!pTarget->CompareMd5_32(0) && !pTarget->CompareMd5_32(Md5_32))
{
- if (!(*pPair.first)->CompareMd5_32(Md5_32) && !(*pPair.first)->CompareMd5_32(0))
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
- if (!(*pPair.first)->CompareMd5_32(Md5_32) && !(*pPair.first)->CompareMd5_32(0))
- cout << "Warning: trying to set to different md5's for Target "<<(*pPair.first)->GetQuotedFullFileName()<<" Old: "<<hex<<(*pPair.first)->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl;
- if (g_PrintAdditionalInfo)
- cout << "Setting Md5 for Target "<<(*pPair.first)->GetQuotedFullFileName()<<" to "<<hex<<Md5_32<<endl;
+ cout << "Warning: trying to set to different md5's for Target "<<pTarget->GetQuotedFullFileName()<<" Old: "<<hex<<pTarget->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl;
#endif
- (*pPair.first)->SetCommandsMd5_32(Md5_32); // If it was already there, just update the md5 value
}
- AddTarget(*pPair.first);
+ #ifdef _DEBUG
+ if (g_PrintAdditionalInfo)
+ cout << "Setting Md5 for Target "<<pTarget->GetQuotedFullFileName()<<" to "<<hex<<Md5_32<<endl;
+ #endif
+ pTarget->SetCommandsMd5_32(Md5_32); // If it was already there, just update the md5 value
+
+ AddTarget(pTarget);
}
if (MakeNotDirty)
ClearAutoDepsDirty();
@@ -782,16 +785,16 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
fclose(pIn);
}
-static void MakeDirs(const refptr<fileinfo> & Dir)
+static void MakeDirs(const fileinfo *pDir)
{
- refptr<fileinfo> ParentDir=Dir->GetDir();
- if (!ParentDir->GetDate().DoesExist())
+ fileinfo *pParentDir=pDir->GetDir();
+ if (!pParentDir->GetDate().DoesExist())
{ /* First make parent dirs */
- MakeDirs(ParentDir);
+ MakeDirs(pParentDir);
}
- if (!Dir->GetDate().DoesExist())
+ if (!pDir->GetDate().DoesExist())
{ /* Create directory */
- mkdir(Dir->GetFullFileName().c_str(),S_IRWXU);
+ mkdir(pDir->GetFullFileName().c_str(),S_IRWXU);
}
}
@@ -812,7 +815,7 @@ void mhmakefileparser::SaveAutoDepsFile()
{
return;
}
- refptr<fileinfo> pDepFile=GetFileInfo(DepFile,m_MakeDir);
+ fileinfo *pDepFile=GetFileInfo(DepFile,m_MakeDir);
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
@@ -860,7 +863,7 @@ void mhmakefileparser::SaveAutoDepsFile()
/* Now save the Md5 strings */
fprintf(pOut,"\n");
- set< const fileinfo * , less_fileinfo>::iterator pIt=m_Targets.begin();
+ set<const fileinfo *>::iterator pIt=m_Targets.begin();
while (pIt!=m_Targets.end())
{
if (!(*pIt)->CompareMd5_32(0))
@@ -1033,6 +1036,85 @@ void mhmakefileparser::SetExport(const string &Var, const string &Val)
}
///////////////////////////////////////////////////////////////////////////////
+void mhmakefileparser::SetvPath(const string &Pattern, const string &Path)
+{
+ // First create the array of directory from the Path parameter. For now all entries need to
+ // be valid directories (extra checking). This could be improved by checking if there
+ // is a rule for creating the directory entry, but like first said, not for now.
+ refptr<fileinfoarray> pDirArray=new fileinfoarray;
+
+ const char *pTmp=Path.c_str();
+ while (*pTmp)
+ {
+ string Item;
+ pTmp=NextItem(pTmp,Item," \t:;");
+ if (!Item.empty())
+ {
+ fileinfo *pDir=GetFileInfo(Item,m_MakeDir);
+ if (!pDir->IsDir())
+ {
+ #ifdef WIN32
+ // On windows this could happen if a full pathname was specified, so we try together
+ // with the next item to check if this is not a valid directories
+ // but only if the the length of the item was 1 namely the driver letter
+ if (Item.length()==1)
+ {
+ string Rest;
+ pTmp=NextItem(pTmp,Rest," \t:;");
+ pDir=GetFileInfo(Item+":"+Rest,m_MakeDir);
+ #ifdef _DEBUG
+ if (g_PrintAdditionalInfo && !pDir->IsDir())
+ throw(pDir->GetFullFileName()+" is not a valid directory.");
+ #endif
+ }
+ #ifdef _DEBUG
+ else if (g_PrintAdditionalInfo)
+ cout << pDir->GetFullFileName() << " is not a valid directory.\n";
+ #endif
+ #else
+ #ifdef _DEBUG
+ if (g_PrintAdditionalInfo)
+ cout << pDir->GetFullFileName() << " is not a valid directory.\n";
+ #endif
+ #endif
+ }
+ pDirArray->push_back(pDir);
+ }
+ }
+ m_vPath.push_back(pair<string, refptr<fileinfoarray> >(Pattern,pDirArray));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Search for the target using the vPath
+fileinfo* mhmakefileparser::SearchvPath(const fileinfo* pTarget)
+{
+ string TargetName=pTarget->GetName();
+ vector< pair< string, refptr<fileinfoarray> > >::iterator vPathIt=m_vPath.begin();
+ while (vPathIt!=m_vPath.end())
+ {
+ matchres Res;
+
+ if (PercentMatch(TargetName,vPathIt->first,&Res))
+ {
+ fileinfoarray::iterator pIt=vPathIt->second->begin();
+ while (pIt!=vPathIt->second->end())
+ {
+ fileinfo* pNewTarget=GetFileInfo(TargetName,*pIt);
+ mh_time_t TargetDate=StartBuildTarget(pNewTarget,false);
+ if (!TargetDate.IsDateValid())
+ TargetDate=WaitBuildTarget(pNewTarget);
+ if (pNewTarget->GetDate().DoesExist())
+ return pNewTarget;
+ pIt++;
+ }
+ }
+ vPathIt++;
+ }
+ return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
//
//Checks if the variables retreived from the environment or command-line have been
//changed. Do this at late as possible because they can also be changed in theLexer
diff --git a/tools/mhmake/src/mhmakefileparser.h b/tools/mhmake/src/mhmakefileparser.h
index 6ae19bf62..8bc0adbe9 100644
--- a/tools/mhmake/src/mhmakefileparser.h
+++ b/tools/mhmake/src/mhmakefileparser.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,13 +44,13 @@ struct funcdef
function_f pFunc;
};
-class fileinfoarray : public refbase,public vector<refptr<fileinfo> >
+class fileinfoarray : public refbase,public vector<fileinfo*>
{
};
-typedef set< refptr<fileinfo> > deps_t;
+typedef set<fileinfo*> deps_t;
typedef pair< bool, deps_t > autodeps_entry_t;
-typedef map< refptr<fileinfo>, autodeps_entry_t > autodeps_t;
+typedef map<fileinfo*, autodeps_entry_t > autodeps_t;
class mhmakefileparser : public refbase
{
@@ -60,10 +60,10 @@ private:
mhmakelexer *m_ptheLexer;
int m_yyloc;
- refptr<fileinfo> m_RuleThatIsBuild;
+ fileinfo *m_RuleThatIsBuild;
vector<string> m_ToBeIncludeAfterBuild;
vector<string> m_MakefilesToLoad;
- refptr<fileinfo> m_AutoDepFileLoaded;
+ fileinfo* m_AutoDepFileLoaded;
int m_InExpandExpression;
mh_time_t m_Date;
uint32 m_EnvMd5_32; /* Cached Md5_32 value of the userd environment variables */
@@ -76,11 +76,11 @@ protected:
map<string,string> m_Variables;
map<string,string> m_CommandLineVars;
TOKENVALUE m_theTokenValue;
- refptr<fileinfo> m_MakeDir;
+ const fileinfo *m_MakeDir;
refptr<rule> m_pCurrentRule;
refptr<fileinfoarray> m_pCurrentItems;
refptr<fileinfoarray> m_pCurrentDeps;
- refptr<fileinfo> m_FirstTarget;
+ fileinfo* m_FirstTarget;
fileinfoarray m_IncludedMakefiles;
refptr<fileinfoarray> m_pIncludeDirs;
string m_IncludeDirs;
@@ -96,6 +96,7 @@ protected:
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_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
char *m_pEnv; // New environment in case the makefile exports variables
#else
@@ -104,7 +105,7 @@ protected:
size_t m_EnvLen; // Current length of m_pEnv
autodeps_t m_AutoDeps;
- set< const fileinfo* , less_fileinfo > m_Targets; // List of targets that are build by this makefile
+ set< const fileinfo* > m_Targets; // List of targets that are build by this makefile
static mh_time_t m_sBuildTime;
private:
@@ -112,7 +113,7 @@ private:
public:
#ifdef _DEBUG
- deque< refptr<fileinfo> > m_TargetStack; /* Used to detect circular dependencies */
+ deque<fileinfo*> m_TargetStack; /* Used to detect circular dependencies */
#endif
mhmakefileparser(const map<string,string> &CommandLineVars)
@@ -124,6 +125,7 @@ public:
,m_RebuildAll(false)
,m_EnvMd5_32(0)
,m_pEnv(NULL)
+ ,m_FirstTarget(NULL)
#ifdef _DEBUG
,m_ImplicitSearch(0)
#endif
@@ -135,7 +137,7 @@ public:
}
/* Needed if you only want to use the searchcommand and execommand functions */
- mhmakefileparser(const refptr<fileinfo> &pMakeDir) :
+ mhmakefileparser(const fileinfo *pMakeDir) :
m_MakeDir(pMakeDir)
, m_AutoDepsDirty(false)
, m_pEnv(NULL)
@@ -152,6 +154,7 @@ public:
void CreateUSED_ENVVARS();
void SetExport(const string & Var, const string & Val);
+ void SetvPath(const string & Pattern, const string & Path);
void CheckEnv(void);
@@ -195,21 +198,21 @@ public:
{
return m_ForceAutoDepRescan;
}
- void SetRuleThatIsBuild(const refptr<fileinfo> &Target)
+ void SetRuleThatIsBuild(fileinfo *pTarget)
{
- m_RuleThatIsBuild=Target;
+ m_RuleThatIsBuild=pTarget;
}
void ClearRuleThatIsBuild()
{
m_RuleThatIsBuild=NULL;
}
- void GetAutoDepsIfNeeded(const refptr<fileinfo> &Target, const refptr<fileinfo>&FirstDep);
- void UpdateAutomaticDependencies(const refptr<fileinfo> &Target);
- void UpdateNoRuleAutomaticDependencies(const refptr<fileinfo> &Target);
+ void GetAutoDepsIfNeeded(fileinfo *pTarget, const fileinfo *pFirstDep);
+ void UpdateAutomaticDependencies(fileinfo *pTarget);
+ void UpdateNoRuleAutomaticDependencies(fileinfo *pTarget);
const refptr<fileinfoarray> GetIncludeDirs() const;
- void GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Autodeps);
+ void GetAutoDeps(const fileinfo *pFirstDep, deps_t &Autodeps);
void SaveAutoDepsFile();
- void LoadAutoDepsFile(refptr<fileinfo> &DepFile);
+ void LoadAutoDepsFile(fileinfo *pDepFile);
bool SkipHeaderFile(const string &FileName);
void InitEnv() const;
@@ -230,7 +233,7 @@ public:
throw("Please derive if you want to execute yyparse.");
}
- int ParseFile(const refptr<fileinfo> &FileInfo,refptr<fileinfo> &pMakeDir=NullFileInfo);
+ int ParseFile(const fileinfo *pFileInfo,const fileinfo *pMakeDir=NULL);
/* Functions to handle variables */
bool IsDefined(const string &Var) const;
@@ -274,12 +277,12 @@ public:
string f_strip(const string & Arg) const;
string f_which(const string & Arg) const;
- const refptr<fileinfo> GetFirstTarget() const
+ fileinfo* GetFirstTarget() const
{
return m_FirstTarget;
}
- const refptr<fileinfo> GetMakeDir() const
+ const fileinfo *GetMakeDir() const
{
return m_MakeDir;
}
@@ -302,28 +305,29 @@ public:
/* Starts building the target,
returns 0 when target build is not finished,
returns the date of the target when target is build, especially important for phony rules, since this will be the youngest date of all dependencies */
- mh_time_t StartBuildTarget(const refptr<fileinfo> &Target, bool bCheckTargetDir=true);
+ mh_time_t StartBuildTarget(fileinfo* pTarget, bool bCheckTargetDir=true);
/* Waits for the target being build, returns the date of the target. Not needed to be cald when StartBuildTarget returned a value different from zero */
- mh_time_t WaitBuildTarget(const refptr<fileinfo> &Target);
+ mh_time_t WaitBuildTarget(fileinfo* pTarget);
+
+ fileinfo* SearchvPath(const fileinfo* pTarget); /* Search for the target using the vPath */
/* Use the following command when you want to wait for the target is built */
- mh_time_t BuildTarget(const refptr<fileinfo> &Target, bool bCheckTargetDir=true)
+ mh_time_t BuildTarget(fileinfo* pTarget, bool bCheckTargetDir=true)
{
- mh_time_t TargetDate=StartBuildTarget(Target,bCheckTargetDir);
+ mh_time_t TargetDate=StartBuildTarget(pTarget,bCheckTargetDir);
if (!TargetDate.IsDateValid())
- return WaitBuildTarget(Target);
- else
+ TargetDate=WaitBuildTarget(pTarget);
return TargetDate;
}
- void BuildDependencies(const refptr<rule> &pRule, const refptr<fileinfo> &Target, mh_time_t TargetDate, mh_time_t &YoungestDate, bool &MakeTarget);
+ void BuildDependencies(const refptr<rule> &pRule, fileinfo* pTarget, mh_time_t TargetDate, mh_time_t &YoungestDate, bool &MakeTarget);
void BuildIncludedMakefiles();
- void AddIncludedMakefile(refptr<fileinfo> &MakeInfo)
+ void AddIncludedMakefile(fileinfo* pMakeInfo)
{
- UpdateDate(MakeInfo->GetDate());
- m_IncludedMakefiles.push_back(MakeInfo);
+ UpdateDate(pMakeInfo->GetDate());
+ m_IncludedMakefiles.push_back(pMakeInfo);
}
fileinfoarray &GetIncludedMakefiles()
{
@@ -357,7 +361,7 @@ public:
static void InitBuildTime();
- void SplitToItems(const string &String, vector< refptr<fileinfo> > &Items) const;
+ void SplitToItems(const string &String, vector<fileinfo*> &Items) const;
mh_pid_t DeleteFiles(const string &Params) const;
mh_pid_t CopyFiles(const string &Params) const;
mh_pid_t TouchFiles(const string &Params) const;
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l
index 8796e70c4..62df687e1 100644
--- a/tools/mhmake/src/mhmakelexer.l
+++ b/tools/mhmake/src/mhmakelexer.l
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,9 +26,9 @@
#include "rule.h"
#include "util.h"
-static uint32 LoadMakMd5(refptr<fileinfo> &Target)
+static uint32 LoadMakMd5(fileinfo *pTarget)
{
- string FileName=Target->GetFullFileName();
+ string FileName=pTarget->GetFullFileName();
FileName+=".md5_32";
FILE *pFile=fopen(FileName.c_str(),"rb");
if (!pFile)
@@ -36,20 +36,20 @@ static uint32 LoadMakMd5(refptr<fileinfo> &Target)
uint32 Md5_32=0;
fread(&Md5_32,sizeof(Md5_32),1,pFile);
fclose(pFile);
- Target->SetCommandsMd5_32(Md5_32);
+ pTarget->SetCommandsMd5_32(Md5_32);
return Md5_32;
}
-static void SaveMakMd5(refptr<fileinfo> &Target)
+static void SaveMakMd5(fileinfo *pTarget)
{
- string FileName=Target->GetFullFileName();
+ string FileName=pTarget->GetFullFileName();
FileName+=".md5_32";
FILE *pFile=fopen(FileName.c_str(),"wb");
if (!pFile)
{
throw string("Error creating file ")+FileName;
}
- Target->WriteMd5_32(pFile);
+ pTarget->WriteMd5_32(pFile);
fclose(pFile);
}
@@ -83,12 +83,12 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
/* -------------- rules section -------------- */
%x INCLUDE IFDEF IF IFNDEF SKIPUNTILELSEORENDIF QUOTE MAKEEXPRES SINGLEQUOTE COMMANDPARSE
-%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO REPARSEMACRO LOAD_MAKEFILE
+%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO MESSAGEINFO MESSAGEERROR REPARSEMACRO LOAD_MAKEFILE
%%
/*---------------------------------------------------------------------------*/
-[ \t\r]*\n[ ][ \t]* |
+[ \t\r]*\n/[ ][ \t]* |
[ \t\r]*\n {
PRINTF(("%s %d: NEWLINE:\n",m_InputFileName.c_str(),m_Line));
m_Line++;
@@ -96,10 +96,12 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
}
/*---------------------------------------------------------------------------*/
-^[s\-]?include {
+^[ \t]*[s\-]?include {
PRINTF(("%s %d: INCLUDE: ",m_InputFileName.c_str(),m_Line));
BEGIN(INCLUDE);
- if (yytext[0]=='-' || yytext[0]=='s')
+ unsigned i=0;
+ while (strchr(" \t",yytext[i])) i++;
+ if (strchr("-s",yytext[i]))
m_IgnoreIncludeError=true;
else
m_IgnoreIncludeError=false;
@@ -123,7 +125,7 @@ static void SaveMakMd5(refptr<fileinfo> &Target)
if (!IncludeFileName.empty())
{
PRINTF(("%s -> %s\n",yytext,IncludeFileName.c_str()));
- refptr<fileinfo> pInclude=GetFileInfo(IncludeFileName,pParser->GetMakeDir());
+ fileinfo *pInclude=GetFileInfo(IncludeFileName,pParser->GetMakeDir());
/* Already build the include file, in case we already have a rule for it. */
if (pInclude->GetRule())
{
@@ -595,6 +597,11 @@ export {
return mhmakeparser::EXPORT;
}
+ /*---------------------------------------------------------------------------*/
+^[ \t]*vpath {
+ PRINTF(("%s %d: vpath\n",m_InputFileName.c_str(),m_Line));
+ return mhmakeparser::VPATH;
+}
/*---------------------------------------------------------------------------*/
[a-zA-Z]:[a-zA-Z0-9\\\._\~\-%\@<&/]+\\[ \t\r]*\n {
@@ -676,6 +683,20 @@ export {
}
/*---------------------------------------------------------------------------*/
+[ \t]*\$\{[ \t]*info[ \t]+ {
+ PRINTF(("%s %d: BEGIN INFO MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ BEGIN(MESSAGEINFO);
+ m_curtoken=g_EmptyString;
+}
+
+ /*---------------------------------------------------------------------------*/
+[ \t]*\$\{[ \t]*error[ \t]+ {
+ PRINTF(("%s %d: BEGIN ERROR MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ BEGIN(MESSAGEERROR);
+ m_curtoken=g_EmptyString;
+}
+
+ /*---------------------------------------------------------------------------*/
\$\([ \t]*reparse[ \t]+ {
m_BraceIndent++;
PRINTF(("%s %d: BEGIN REPARSE MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
@@ -826,6 +847,22 @@ export {
}
/*****************************************************************************/
+<MESSAGEERROR>[^\}]+ {
+ throw(GetParser()->ExpandExpression((const char*)yytext));
+}
+
+ /*****************************************************************************/
+<MESSAGEINFO>[^\}]+ {
+ cerr<<GetParser()->ExpandExpression((const char*)yytext)<<endl;
+}
+
+ /*****************************************************************************/
+<MESSAGEINFO>\} {
+ PRINTF(("%s %d: MESSAGEINFO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ BEGIN(INITIAL);
+}
+
+ /*****************************************************************************/
<MESSAGEMACRO>\) {
m_BraceIndent--;
PRINTF(("%s %d: CLOSE BRACE MESSAGE MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y
index 107194d70..e2312b50e 100644
--- a/tools/mhmake/src/mhmakeparser.y
+++ b/tools/mhmake/src/mhmakeparser.y
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@
%token <theString> COMMAND
%token <theString> COMMA OPENBRACE CLOSEBRACE
%token <theString> STRING DOLLAREXPR EQUAL COLON DOUBLECOLON
-%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE
+%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE VPATH
%type <theString> expression nonspaceexpression simpleexpression
%type <theString> maybeemptyexpression
@@ -69,6 +69,7 @@ statements :
;
statement: NEWLINE |
+ SPACE |
includemak |
ruledef |
phonyrule |
@@ -78,6 +79,7 @@ statement: NEWLINE |
pvarassignment |
optvarassignment |
exportrule |
+ vpathrule |
COMMAND
{
if (!m_pCurrentRule)
@@ -129,9 +131,9 @@ rulecolon: COLON {$$=0;} |
phonyrule: PHONY COLON expression
{
- vector< refptr<fileinfo> > Items;
+ vector<fileinfo*> Items;
SplitToItems(ExpandExpression($3),Items);
- vector< refptr<fileinfo> >::iterator pIt=Items.begin();
+ vector<fileinfo*>::iterator pIt=Items.begin();
while (pIt!=Items.end())
{
(*pIt)->SetPhony();
@@ -145,9 +147,9 @@ phonyrule: PHONY COLON expression
autodepsrule: AUTODEPS COLON expression
{
- vector< refptr<fileinfo> > Items;
+ vector<fileinfo*> Items;
SplitToItems(ExpandExpression($3),Items);
- vector< refptr<fileinfo> >::iterator pIt=Items.begin();
+ vector<fileinfo*>::iterator pIt=Items.begin();
while (pIt!=Items.end())
{
(*pIt)->SetAutoDepsScan(this);
@@ -173,6 +175,13 @@ exportstring : STRING
}
;
+vpathrule: VPATH SPACE nonspaceexpression SPACE expression NEWLINE
+ {
+ SetvPath(ExpandExpression($3),ExpandExpression($5));
+ PRINTF(("Setting vpath %s to %s\n",$3.c_str(),ExpandExpression($5).c_str()));
+ }
+;
+
varassignment: STRING EQUAL maybeemptyexpression
{
m_Variables[$1]=$3;
diff --git a/tools/mhmake/src/refptr.h b/tools/mhmake/src/refptr.h
index 38b62b4ca..7223090f9 100644
--- a/tools/mhmake/src/refptr.h
+++ b/tools/mhmake/src/refptr.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/rule.cpp b/tools/mhmake/src/rule.cpp
index aa2ce1a13..dc8ab3b00 100644
--- a/tools/mhmake/src/rule.cpp
+++ b/tools/mhmake/src/rule.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,19 +27,19 @@
refptr<rule> NullRule;
-map< string, vector<pair<string,refptr<rule> > > > IMPLICITRULE::m_ImplicitRules;
+vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > > 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(const string &DepName,vector<pair<string,refptr<rule> > >&ImplicitRule,refptr<rule> &Rule)
+static bool FindDep(fileinfo *pDep, vector<pair<fileinfo*,refptr<rule> > >*pImplicitRule,refptr<rule> &Rule)
{
- vector<pair<string,refptr<rule> > >::iterator SecIt=ImplicitRule.begin();
- while (SecIt!=ImplicitRule.end())
+ vector<pair<fileinfo*,refptr<rule> > >::iterator SecIt=pImplicitRule->begin();
+ while (SecIt!=pImplicitRule->end())
{
- if (SecIt->first==DepName)
+ if (SecIt->first==pDep)
{
#ifdef _DEBUG
// Check if the rule has the same commands
@@ -51,9 +51,9 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
{
string ErrorMessage;
if (bCommandsDifferent)
- ErrorMessage += "Implicit Rule '"+ DepName + "' defined twice with different commands\n";
+ ErrorMessage += "Implicit Rule '"+ pDep->GetFullFileName() + "' defined twice with different commands\n";
else
- ErrorMessage += "Implicit Rule '"+ DepName + "' defined twice with same commands\n";
+ ErrorMessage += "Implicit Rule '"+ pDep->GetFullFileName() + "' defined twice with same commands\n";
ErrorMessage += "Command 1: makedir = " + SecIt->second->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()+ "\n";
vector<string>::const_iterator It;
@@ -86,7 +86,7 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
{
if (pOldMakefile->ExpandExpression(*OldIt)!=pNewMakefile->ExpandExpression(*NewIt))
{
- string ErrorMessage = string("Implicit Rule '") + DepName + "' defined twice with different commands\n";
+ string ErrorMessage = string("Implicit Rule '") + pDep->GetFullFileName() + "' defined twice with different commands\n";
ErrorMessage += "Command 1: makedir = " + pOldMakefile->GetMakeDir()->GetQuotedFullFileName()+ "\n";
ErrorMessage += " " + pOldMakefile->ExpandExpression(*OldIt) + "\n";
ErrorMessage += "Command 2: makedir = " + pNewMakefile->GetMakeDir()->GetQuotedFullFileName()+ "\n";
@@ -105,56 +105,76 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
}
///////////////////////////////////////////////////////////////////////////////
-void IMPLICITRULE::AddImplicitRule(const refptr<fileinfo> &Target,const vector< refptr<fileinfo> > &Deps,refptr<rule> Rule)
+void IMPLICITRULE::AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps,refptr<rule> Rule)
{
- vector<pair<string,refptr<rule> > >& ImplicitRule=m_ImplicitRules[Target->GetFullFileName()];
+ // first search if there is already the same target in the current list of implicit rules
+ vector<pair<fileinfo*,refptr<rule> > >* pImplicitRule=NULL;
+ vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > >::iterator RuleIt=m_ImplicitRules.begin();
+ while (RuleIt!=m_ImplicitRules.end())
+ {
+ if (pTarget==RuleIt->first)
+ {
+ pImplicitRule=&(RuleIt->second);
+ }
+ RuleIt++;
+ }
+ if (!pImplicitRule)
+{
+ // Add a new entry
+ m_ImplicitRules.push_back(pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > >(pTarget,vector<pair<fileinfo*,refptr<rule> > >()));
+ pImplicitRule=&((m_ImplicitRules.end()-1)->second);
+ }
+
if (Deps.size())
{
- vector< refptr<fileinfo> >::const_iterator DepIt=Deps.begin();
+ vector<fileinfo*>::const_iterator DepIt=Deps.begin();
while (DepIt!=Deps.end())
{
- const string &DepName=(*DepIt)->GetFullFileName();
- if (!FindDep(DepName,ImplicitRule,Rule))
- ImplicitRule.push_back(pair<string,refptr<rule> >(DepName,Rule));
+ #ifdef _DEBUG
+ if (*DepIt==pTarget)
+ throw(string("Implicit rule : ")+pTarget->GetFullFileName()+" is directly dependent on itself. This is not allowed.");
+ #endif
+ if (!FindDep(*DepIt,pImplicitRule,Rule))
+ pImplicitRule->push_back(pair<fileinfo*,refptr<rule> >(*DepIt,Rule));
DepIt++;
}
}
else
{
- if (!FindDep(g_EmptyString,ImplicitRule,Rule))
- ImplicitRule.push_back(pair<string,refptr<rule> >(g_EmptyString,Rule));
+ if (!FindDep(NULL,pImplicitRule,Rule))
+ pImplicitRule->push_back(pair<fileinfo*,refptr<rule> >((fileinfo*)NULL,Rule));
}
}
///////////////////////////////////////////////////////////////////////////////
-void IMPLICITRULE::SearchImplicitRule(const refptr<fileinfo> &Target,vector< pair<refptr<fileinfo>,refptr<rule> > >&Result)
+void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget,vector< pair<fileinfo*,refptr<rule> > >&Result)
{
- string TargetFileName=Target->GetFullFileName();
+ string TargetFileName=pTarget->GetFullFileName();
- map< string, vector<pair<string,refptr<rule> > > >::iterator ImpRegExIt=m_ImplicitRules.begin();
+ vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > >::iterator ImpRegExIt=m_ImplicitRules.begin();
while (ImpRegExIt!=m_ImplicitRules.end())
{
matchres Res;
- if (PercentMatch(TargetFileName,ImpRegExIt->first,&Res))
+ if (PercentMatch(TargetFileName,ImpRegExIt->first->GetFullFileName(),&Res))
{
- vector<pair<string,refptr<rule> > >::iterator ResIt=ImpRegExIt->second.begin();
+ vector<pair<fileinfo*,refptr<rule> > >::iterator ResIt=ImpRegExIt->second.begin();
while (ResIt!=ImpRegExIt->second.end())
{
#ifdef _DEBUG
if (!ResIt->second)
{
- throw string("No rhs for implicit rule : ") + ImpRegExIt->first;
+ throw string("No rhs for implicit rule : ") + ImpRegExIt->first->GetFullFileName();
}
#endif
ResIt->second->SetStem(Res.m_Stem);
- if (!ResIt->first.empty())
+ if (ResIt->first!=NULL)
{
- string Dependent=ReplaceWithStem(ResIt->first,Res.m_Stem);
- Result.push_back(pair<refptr<fileinfo>,refptr<rule> >(GetFileInfo(Dependent,ResIt->second->GetMakefile()->GetMakeDir()),ResIt->second));
+ string Dependent=ReplaceWithStem(ResIt->first->GetFullFileName(),Res.m_Stem);
+ Result.push_back(pair<fileinfo*,refptr<rule> >(GetFileInfo(Dependent,ResIt->second->GetMakefile()->GetMakeDir()),ResIt->second));
}
else
- Result.push_back(pair<refptr<fileinfo>,refptr<rule> >(NullFileInfo,ResIt->second));
+ Result.push_back(pair<fileinfo*,refptr<rule> >((fileinfo*)NULL,ResIt->second));
ResIt++;
}
}
@@ -210,11 +230,11 @@ void rule::SetTargetsIsBuilding(const fileinfo *pSrc)
///////////////////////////////////////////////////////////////////////////////
void IMPLICITRULE::PrintImplicitRules()
{
- map< string, vector<pair<string,refptr<rule> > > >::iterator ImpRegExIt=m_ImplicitRules.begin();
+ vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > >::iterator ImpRegExIt=m_ImplicitRules.begin();
while (ImpRegExIt!=m_ImplicitRules.end())
{
- vector<pair<string,refptr<rule> > >::iterator SecIt=ImpRegExIt->second.begin();
- cout << ImpRegExIt->first << " :\n";
+ vector<pair<fileinfo*,refptr<rule> > >::iterator SecIt=ImpRegExIt->second.begin();
+ cout << ImpRegExIt->first->GetFullFileName() << " :\n";
while (SecIt!=ImpRegExIt->second.end())
{
cout << " : " << SecIt->first <<endl;
@@ -234,16 +254,16 @@ void IMPLICITRULE::PrintImplicitRules()
}
///////////////////////////////////////////////////////////////////////////////
-void rule::PrintCommands(refptr<fileinfo> Target) const
+void rule::PrintCommands(fileinfo *pTarget) const
{
- if (Target)
- m_pMakefile->SetRuleThatIsBuild(Target);
+ if (pTarget)
+ m_pMakefile->SetRuleThatIsBuild(pTarget);
vector<string>::const_iterator pCommandIt=m_Commands.begin();
while (pCommandIt!=m_Commands.end())
{
cout<<g_SpaceString<<*pCommandIt<<endl;
- if (Target)
+ if (pTarget)
{
cout<<" ("<<m_pMakefile->ExpandExpression(*pCommandIt)<<")\n";
}
diff --git a/tools/mhmake/src/rule.h b/tools/mhmake/src/rule.h
index bfc00bb15..1ec944f96 100644
--- a/tools/mhmake/src/rule.h
+++ b/tools/mhmake/src/rule.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
#include "md5.h"
class mhmakeparser;
class fileinfo;
-extern refptr<fileinfo> NullFileInfo;
class rule: public refbase
{
@@ -47,7 +46,7 @@ public:
{
return m_Commands;
}
- void PrintCommands(refptr<fileinfo> Target=NullFileInfo) const;
+ void PrintCommands(fileinfo *pTarget=NULL) const;
void SetStem(const string &Stem)
{
@@ -77,10 +76,10 @@ public:
class IMPLICITRULE
{
- static map< string, vector<pair<string,refptr<rule> > > > m_ImplicitRules;
+ static vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > > m_ImplicitRules; // Use a vector and not a map because the order of the implicit rules is important
public:
- static void AddImplicitRule(const refptr<fileinfo> &Target,const vector< refptr<fileinfo> >&Deps,refptr<rule> pRule);
- static void SearchImplicitRule(const refptr<fileinfo> &Target,vector< pair<refptr<fileinfo>,refptr<rule> > >&Result);
+ static void AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps,refptr<rule> pRule);
+ static void SearchImplicitRule(const fileinfo *pTarget,vector< pair<fileinfo*,refptr<rule> > >&Result);
static void PrintImplicitRules();
};
diff --git a/tools/mhmake/src/stdafx.cpp b/tools/mhmake/src/stdafx.cpp
index feb841fea..b2168250b 100644
--- a/tools/mhmake/src/stdafx.cpp
+++ b/tools/mhmake/src/stdafx.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/stdafx.h b/tools/mhmake/src/stdafx.h
index b8eca6204..3a6bbb946 100644
--- a/tools/mhmake/src/stdafx.h
+++ b/tools/mhmake/src/stdafx.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index f16134551..2e26cf2e7 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -235,6 +235,64 @@ bool PercentMatch(const string &String,const string &Expr,matchres *pRes,const c
return true;
}
///////////////////////////////////////////////////////////////////////////////
+bool PercentMatchNoCase(const string &String,const string &Expr,matchres *pRes,const char Char)
+{
+ const char *pFirst=String.c_str();
+ const char *pFirstExpr=Expr.c_str();
+ while (*pFirstExpr && *pFirstExpr!=Char)
+ {
+ if (tolower(*pFirst)!=tolower(*pFirstExpr))
+ return false;
+ pFirst++;
+ pFirstExpr++;
+ }
+
+ if (!*pFirstExpr)
+ {
+ if (!*pFirst)
+ {
+ if (pRes)
+ {
+ pRes->m_First=String;
+ pRes->m_Stem=pRes->m_Last=g_EmptyString;
+ }
+ return true;
+ } else
+ return false;
+ }
+ else if (!*pFirst)
+ return false;
+
+ const char *pEnd=pFirst+strlen(pFirst);
+
+ const char *pLast=pEnd;
+ const char *pLastExpr=pFirstExpr+strlen(pFirstExpr)-1;
+ if (pLastExpr!=pFirstExpr)
+ {
+ pLast--;
+
+ while (pLastExpr>pFirstExpr)
+ {
+ if (tolower(*pLastExpr)!=tolower(*pLast))
+ return false;
+ pLastExpr--;
+ pLast--;
+ }
+ pLast++;
+ }
+ string Stem=string(pFirst,pLast-pFirst);
+
+ if (pRes)
+ {
+ pRes->m_First=string(String.c_str(),pFirst-String.c_str());
+
+ pRes->m_Stem=Stem;
+
+ pRes->m_Last=string(pLast,pEnd-pLast);
+ }
+ return true;
+}
+///////////////////////////////////////////////////////////////////////////////
bool PercentMatchList(const string &String,const string &ExprList,matchres *pRes)
{
const char *pTmp=ExprList.c_str();
@@ -365,11 +423,12 @@ loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
}
///////////////////////////////////////////////////////////////////////////////
-loadedmakefile::loadedmakefile(const refptr<fileinfo> &pDir, vector<string> &Args,const string&Makefile)
+loadedmakefile::loadedmakefile(const fileinfo *pDir, vector<string> &Args,const string&Makefile)
{
+ m_Makefile=NULL;
m_CommandLineVars=sm_Statics.m_GlobalCommandLineVars;
- m_MakeDir=NullFileInfo;
+ m_MakeDir=NULL;
vector<string>::iterator ArgIt=Args.begin();
while (ArgIt!=Args.end())
{
@@ -554,7 +613,7 @@ void loadedmakefile::LoadMakefile()
string BaseAutoMak;
// First parse the makefile.before makefile which is in the directory $(MHMAKECONF) environment variable
- refptr<fileinfo> DepFile;
+ fileinfo *pDepFile;
if (sm_Statics.m_MhMakeConf)
{
BaseAutoMak=m_pParser->ExpandVar(BASEAUTOMAK);
@@ -563,14 +622,14 @@ void loadedmakefile::LoadMakefile()
BaseAutoMak="makefile";
m_pParser->SetVariable(BASEAUTOMAK,BaseAutoMak);
}
- refptr<fileinfo> BeforeMakefile=GetFileInfo(BaseAutoMak+".before",sm_Statics.m_MhMakeConf);
+ const fileinfo *pBeforeMakefile=GetFileInfo(BaseAutoMak+".before",sm_Statics.m_MhMakeConf);
- int result=m_pParser->ParseFile(BeforeMakefile,m_MakeDir);
+ int result=m_pParser->ParseFile(pBeforeMakefile,m_MakeDir);
if (result)
{
- throw string("Error parsing ")+BeforeMakefile->GetQuotedFullFileName();
+ throw string("Error parsing ")+pBeforeMakefile->GetQuotedFullFileName();
}
- m_pParser->UpdateDate(BeforeMakefile->GetDate());
+ m_pParser->UpdateDate(pBeforeMakefile->GetDate());
// Now parse the automaticly generated dependency file, which needs to be in the objdir directory
string ObjDirName=m_pParser->ExpandExpression("$(OBJDIR)");
@@ -578,8 +637,8 @@ void loadedmakefile::LoadMakefile()
{
throw string("When making use of MHMAKECONF, you have to define OBJDIR in makefile.before");
}
- DepFile=GetFileInfo(ObjDirName+OSPATHSEPSTR "." + m_Makefile->GetName()+ ".dep",m_MakeDir);
- m_pParser->SetVariable(AUTODEPFILE,DepFile->GetQuotedFullFileName());
+ pDepFile=GetFileInfo(ObjDirName+OSPATHSEPSTR "." + m_Makefile->GetName()+ ".dep",m_MakeDir);
+ m_pParser->SetVariable(AUTODEPFILE,pDepFile->GetQuotedFullFileName());
}
else
{
@@ -603,12 +662,12 @@ void loadedmakefile::LoadMakefile()
char ID[10];
sprintf(ID,"_%x",md5_finish32( &ctx));
- DepFile=GetFileInfo(string(".") + m_Makefile->GetName()+ ".dep"+ID,m_MakeDir);
- m_pParser->SetVariable(AUTODEPFILE,DepFile->GetQuotedFullFileName());
+ pDepFile=GetFileInfo(string(".") + m_Makefile->GetName()+ ".dep"+ID,m_MakeDir);
+ m_pParser->SetVariable(AUTODEPFILE,pDepFile->GetQuotedFullFileName());
}
- if (DepFile->Exists())
- m_pParser->LoadAutoDepsFile(DepFile); /* Already load this autodep file before parsing of the makefile to avoid needless rebuilds. */
+ if (pDepFile->Exists())
+ m_pParser->LoadAutoDepsFile(pDepFile); /* Already load this autodep file before parsing of the makefile to avoid needless rebuilds. */
//m_pParser->yydebug=1;
int result=m_pParser->ParseFile(m_Makefile,m_MakeDir);
@@ -619,9 +678,9 @@ void loadedmakefile::LoadMakefile()
#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_pParser->ExpandVar(AUTODEPFILE)!=DepFile->GetQuotedFullFileName())
+ if (m_pParser->ExpandVar(AUTODEPFILE)!=pDepFile->GetQuotedFullFileName())
{
- cout << "\n\nWARNING:\n makefile '"<< m_Makefile->GetQuotedFullFileName() <<"' re-defines AUTODEPFILE\n from '"<< DepFile->GetQuotedFullFileName() <<"'\n to '"<<
+ cout << "\n\nWARNING:\n makefile '"<< m_Makefile->GetQuotedFullFileName() <<"' re-defines AUTODEPFILE\n from '"<< pDepFile->GetQuotedFullFileName() <<"'\n to '"<<
m_pParser->ExpandVar(AUTODEPFILE) << "'\n (may cause needless rebuilds when having rules for included makefiles!!!!!)\n\n\n";
}
@@ -637,16 +696,16 @@ void loadedmakefile::LoadMakefile()
if (sm_Statics.m_MhMakeConf)
{
- refptr<fileinfo> AfterMakefile=GetFileInfo(BaseAutoMak+".after",sm_Statics.m_MhMakeConf);
- int result=m_pParser->ParseFile(AfterMakefile);
+ fileinfo *pAfterMakefile=GetFileInfo(BaseAutoMak+".after",sm_Statics.m_MhMakeConf);
+ int result=m_pParser->ParseFile(pAfterMakefile);
if (result) {
- throw string("Error parsing ")+AfterMakefile->GetQuotedFullFileName();
+ throw string("Error parsing ")+pAfterMakefile->GetQuotedFullFileName();
}
- m_pParser->UpdateDate(AfterMakefile->GetDate());
+ m_pParser->UpdateDate(pAfterMakefile->GetDate());
}
bool ForceAutoDepRescan=g_ForceAutoDepRescan;
- if (DepFile->Exists())
- m_pParser->LoadAutoDepsFile(DepFile);
+ if (pDepFile->Exists())
+ m_pParser->LoadAutoDepsFile(pDepFile);
else
ForceAutoDepRescan=true;
if (ForceAutoDepRescan)
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index 9b49cf489..ff1fac9aa 100644
--- a/tools/mhmake/src/util.h
+++ b/tools/mhmake/src/util.h
@@ -1,6 +1,6 @@
/* This file is part of mhmake.
*
- * Copyright (C) 2001-2009 Marc Haesen
+ * Copyright (C) 2001-2010 marha@sourceforge.net
*
* Mhmake is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@
#define PLATFORM "linux"
#endif
-#define MHMAKEVER "2.2.5"
+#define MHMAKEVER "2.2.9"
class makecommand
{
@@ -150,6 +150,7 @@ struct matchres
};
bool PercentMatch(const string &String,const string &Expr,matchres *pRes=NULL,const char Char='%');
+bool PercentMatchNoCase(const string &String,const string &Expr,matchres *pRes=NULL,const char Char='%');
bool PercentMatchList(const string &String,const string &ExprList,matchres *pRes=NULL);
string ReplaceWithStem(const string &String,const string &Stem);
@@ -158,20 +159,20 @@ struct loadedmakefile : public refbase
struct loadedmakefile_statics
{
map<string,string> m_GlobalCommandLineVars;
- refptr<fileinfo> m_MhMakeConf;
+ fileinfo *m_MhMakeConf;
loadedmakefile_statics();
};
static loadedmakefile_statics sm_Statics;
- refptr<fileinfo> m_Makefile;
- refptr<fileinfo> m_MakeDir;
+ fileinfo *m_Makefile;
+ const fileinfo *m_MakeDir;
map<string,string> m_CommandLineVars;
vector<string> m_CommandLineTargets;
refptr<mhmakeparser> m_pParser;
- loadedmakefile(const refptr<fileinfo> &pDir, vector<string> &Args,const string &Makefile=g_EmptyString);
+ loadedmakefile(const fileinfo *pDir, vector<string> &Args,const string &Makefile=g_EmptyString);
void LoadMakefile();
void AddCommandLineVarsToEnvironment()