aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mhmake/src')
-rw-r--r--tools/mhmake/src/build.cpp4
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp69
-rw-r--r--tools/mhmake/src/mhmakefileparser.h8
-rw-r--r--tools/mhmake/src/util.h2
4 files changed, 49 insertions, 34 deletions
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index ed02266b3..1d4a6ddc1 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -913,9 +913,9 @@ string mhmakefileparser::GetFullCommand(string Command)
}
if (!bBuild)
{
- set< refptr<fileinfo> > Autodeps;
+ deps_t Autodeps;
GetAutoDeps(pPyFile, Autodeps);
- set< refptr<fileinfo> >::iterator It=Autodeps.begin();
+ deps_t::iterator It=Autodeps.begin();
while (It!=Autodeps.end())
{
if (pExeFile->GetDate().IsOlder((*It)->GetDate()))
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index e87f46887..725312b61 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -484,7 +484,7 @@ void mhmakefileparser::AddRule()
}
///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep,set< refptr<fileinfo> > &Autodeps)
+void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Autodeps)
{
/* Here we have to scan only c/c++ headers so skip certain extensions */
const char *pFullName=FirstDep->GetFullFileName().c_str();
@@ -579,11 +579,11 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep,set< refptr<
mh_time_t Date=BuildTarget(pInclude);
if (Date.DoesExist()) // Try to build the target, and add it if it exists after building
{
- set< refptr<fileinfo> >::iterator pFind=Autodeps.find(pInclude);
+ deps_t::const_iterator pFind=Autodeps.find(pInclude);
if (pFind==Autodeps.end())
{
Autodeps.insert(pInclude);
- GetAutoDeps(pInclude,Autodeps);
+ GetAutoDepsIfNeeded(pInclude,pInclude);
}
}
}
@@ -595,11 +595,11 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep,set< refptr<
mh_time_t Date=BuildTarget(pInclude);
if (Date.DoesExist()) // Try to build the target, and add it if it exists after building
{
- set< refptr<fileinfo> >::iterator pFind=Autodeps.find(pInclude);
+ deps_t::const_iterator pFind=Autodeps.find(pInclude);
if (pFind==Autodeps.end())
{
Autodeps.insert(pInclude);
- GetAutoDeps(pInclude,Autodeps);
+ GetAutoDepsIfNeeded(pInclude,pInclude);
}
break;
}
@@ -617,12 +617,30 @@ void mhmakefileparser::GetAutoDeps(const refptr<fileinfo> &FirstDep,set< refptr<
}
///////////////////////////////////////////////////////////////////////////////
+
+void mhmakefileparser::GetAutoDepsIfNeeded(const refptr<fileinfo> &Target, const refptr<fileinfo>&FirstDep)
+{
+ autodeps_entry_t &Autodeps=m_AutoDeps[Target];
+ if (!Autodeps.first)
+ {
+ Autodeps.first=true;
+ /* We are going to rescan, so throw away the old. */
+ Autodeps.second.clear();
+ GetAutoDeps(FirstDep,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);
+ It++;
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void mhmakefileparser::UpdateAutomaticDependencies(const refptr<fileinfo> &Target)
{
- const char *pName=Target->GetFullFileName().c_str();
- const char *pExt=strrchr(pName,'.');
- if (!pExt)
- return;
if (Target->IsAutoDepExtention())
{
// we have to search for the include files in the first dependency of Target
@@ -630,17 +648,7 @@ void mhmakefileparser::UpdateAutomaticDependencies(const refptr<fileinfo> &Targe
if (!Deps.size())
return; // There is no first dep
refptr<fileinfo> FirstDep=Deps[0];
-
- set< refptr<fileinfo> > &Autodeps=m_AutoDeps[Target];
- Autodeps.clear(); // We are going to scan again, so clear the list
- GetAutoDeps(FirstDep,Autodeps);
- // Now add these dependencies also to the rules
- set< refptr<fileinfo> >::iterator It=Autodeps.begin();
- while (It!=Autodeps.end())
- {
- Target->AddDep(*It);
- It++;
- }
+ GetAutoDepsIfNeeded(Target,FirstDep);
SetAutoDepsDirty();
}
}
@@ -733,14 +741,14 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
while (FileName[0])
{
refptr<fileinfo> Target=GetFileInfo(FileName,m_MakeDir);
- set< refptr<fileinfo> > &Autodeps=m_AutoDeps[Target];
+ autodeps_entry_t &Autodeps=m_AutoDeps[Target];
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.insert(Dep);
+ Autodeps.second.insert(Dep);
Target->AddDep(Dep);
}
ReadStr(pIn,FileName);
@@ -833,17 +841,20 @@ void mhmakefileparser::SaveAutoDepsFile()
fwrite(&Md5_32,sizeof(Md5_32),1,pOut);
fprintf(pOut,"%s\n",m_Variables[USED_ENVVARS].c_str());
- map< refptr<fileinfo>, set< refptr<fileinfo> > >::const_iterator It=m_AutoDeps.begin();
+ autodeps_t::const_iterator It=m_AutoDeps.begin();
while (It!=m_AutoDeps.end())
{
- fprintf(pOut,"%s\n",It->first->GetFullFileName().c_str());
- set< refptr<fileinfo> >::const_iterator DepIt=It->second.begin();
- while (DepIt!=It->second.end())
+ if (!It->second.second.empty())
{
- fprintf(pOut,"%s\n",(*DepIt)->GetFullFileName().c_str());
- DepIt++;
+ fprintf(pOut,"%s\n",It->first->GetFullFileName().c_str());
+ deps_t::const_iterator DepIt=It->second.second.begin();
+ while (DepIt!=It->second.second.end())
+ {
+ fprintf(pOut,"%s\n",(*DepIt)->GetFullFileName().c_str());
+ DepIt++;
+ }
+ fprintf(pOut,"\n");
}
- fprintf(pOut,"\n");
It++;
}
/* Now save the Md5 strings */
diff --git a/tools/mhmake/src/mhmakefileparser.h b/tools/mhmake/src/mhmakefileparser.h
index 1efb37c39..9c75c8771 100644
--- a/tools/mhmake/src/mhmakefileparser.h
+++ b/tools/mhmake/src/mhmakefileparser.h
@@ -49,6 +49,9 @@ class fileinfoarray : public refbase,public vector<refptr<fileinfo> >
};
typedef set< refptr<fileinfo> > deps_t;
+typedef pair< bool, deps_t > autodeps_entry_t;
+typedef map< refptr<fileinfo>, autodeps_entry_t > autodeps_t;
+
class mhmakefileparser : public refbase
{
@@ -99,7 +102,7 @@ protected:
#endif
int m_EnvLen; // Current length of m_pEnv
- map< refptr<fileinfo>, set< refptr<fileinfo> > > m_AutoDeps;
+ autodeps_t m_AutoDeps;
set< const fileinfo* , less_fileinfo > m_Targets; // List of targets that are build by this makefile
static mh_time_t m_sBuildTime;
@@ -199,10 +202,11 @@ public:
{
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);
const refptr<fileinfoarray> GetIncludeDirs() const;
- void GetAutoDeps(const refptr<fileinfo> &FirstDep,set< refptr<fileinfo> > &Autodeps);
+ void GetAutoDeps(const refptr<fileinfo> &FirstDep, deps_t &Autodeps);
void SaveAutoDepsFile();
void LoadAutoDepsFile(refptr<fileinfo> &DepFile);
bool SkipHeaderFile(const string &FileName);
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index 62efbd245..aff7d642a 100644
--- a/tools/mhmake/src/util.h
+++ b/tools/mhmake/src/util.h
@@ -50,7 +50,7 @@
#define PLATFORM "linux"
#endif
-#define MHMAKEVER "2.2.0"
+#define MHMAKEVER "2.2.1"
class makecommand
{