From f19a1f2d41337986c94cecfd348aca32a5445993 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 4 Aug 2010 09:37:27 +0000 Subject: Added possibility to force a dependency scan on a target with .AUTODEPS --- tools/mhmake/src/build.cpp | 2 ++ tools/mhmake/src/fileinfo.h | 14 ++++++++++++++ tools/mhmake/src/mhmakefileparser.cpp | 15 +++++++++++++++ tools/mhmake/src/mhmakefileparser.h | 1 + tools/mhmake/src/mhmakelexer.l | 6 ++++++ tools/mhmake/src/mhmakeparser.y | 21 +++++++++++++++++++-- tools/mhmake/src/util.h | 2 +- 7 files changed, 58 insertions(+), 3 deletions(-) diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp index 57cd94b79..ed02266b3 100644 --- a/tools/mhmake/src/build.cpp +++ b/tools/mhmake/src/build.cpp @@ -1627,6 +1627,8 @@ mh_time_t mhmakefileparser::StartBuildTarget(const refptr &Target,bool if (pMakefile->ForceAutoDepRescan()||MakeTarget==true) pMakefile->UpdateAutomaticDependencies(Target); } + else if (Target->GetAutoDepsMakefile()) + Target->GetAutoDepsMakefile()->UpdateNoRuleAutomaticDependencies(Target); BuildDependencies(pRule,Target,TargetDate,YoungestDate,MakeTarget); diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h index 6c9800f38..e221293e6 100644 --- a/tools/mhmake/src/fileinfo.h +++ b/tools/mhmake/src/fileinfo.h @@ -136,6 +136,7 @@ class fileinfo : public refbase bool m_IsPhony; int m_BuildStatus; /* Bit 0 means the target built is started, Bit 1 means the target is still building */ refptr m_pRule; + mhmakeparser *m_pAutoDepsMakefile; vector< refptr > m_Deps; mh_time_t m_Date; uint32 m_CommandsMd5_32; // 32-bit Md5 checksum of commands to build this target @@ -147,6 +148,7 @@ public: fileinfo(const string &AbsFileName,uint32 Md5_32) { m_IsPhony=false; + m_pAutoDepsMakefile=NULL; m_BuildStatus=0; m_AbsFileName=UnquoteFileName(AbsFileName); InvalidateDate(); @@ -292,6 +294,18 @@ public: return m_Deps; } string GetPrerequisits(void) const; + void SetAutoDepsScan(mhmakeparser *pMakefile) + { + #ifdef _DEBUG + if (m_pAutoDepsMakefile) + throw(string(".AUTODEPS can only defined ones for rule ")+GetFullFileName()); + #endif + m_pAutoDepsMakefile=pMakefile; + } + mhmakeparser *GetAutoDepsMakefile(void) const + { + return m_pAutoDepsMakefile; + } void SetPhony(void) { m_IsPhony=true; diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp index 30916878e..35d379cd0 100644 --- a/tools/mhmake/src/mhmakefileparser.cpp +++ b/tools/mhmake/src/mhmakefileparser.cpp @@ -641,6 +641,21 @@ void mhmakefileparser::UpdateAutomaticDependencies(const refptr &Targe } } +/////////////////////////////////////////////////////////////////////////////// +void mhmakefileparser::UpdateNoRuleAutomaticDependencies(const refptr &Target) +{ + // we have to search for the include files in the Target + set< refptr > Autodeps; + GetAutoDeps(Target,Autodeps); + // Now add these dependencies also to the rules + set< refptr >::iterator It=Autodeps.begin(); + while (It!=Autodeps.end()) + { + Target->AddDep(*It); + It++; + } +} + /////////////////////////////////////////////////////////////////////////////// const refptr mhmakefileparser::GetIncludeDirs() const { diff --git a/tools/mhmake/src/mhmakefileparser.h b/tools/mhmake/src/mhmakefileparser.h index b37e96466..048435f34 100644 --- a/tools/mhmake/src/mhmakefileparser.h +++ b/tools/mhmake/src/mhmakefileparser.h @@ -198,6 +198,7 @@ public: m_RuleThatIsBuild=NULL; } void UpdateAutomaticDependencies(const refptr &Target); + void UpdateNoRuleAutomaticDependencies(const refptr &Target); const refptr GetIncludeDirs() const; void GetAutoDeps(const refptr &FirstDep,set< refptr > &Autodeps); void SaveAutoDepsFile(); diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l index 5e73dd812..d64d7cc5c 100644 --- a/tools/mhmake/src/mhmakelexer.l +++ b/tools/mhmake/src/mhmakelexer.l @@ -558,6 +558,12 @@ load_makefile { return mhmakeparser::PHONY; } + /*---------------------------------------------------------------------------*/ +\.AUTODEPS { + PRINTF(("%s %d: .AUTODEPS: %s\n",m_InputFileName.c_str(),m_Line,yytext)); + return mhmakeparser::AUTODEPS; +} + /*---------------------------------------------------------------------------*/ export { PRINTF(("%s %d: export: %s\n",m_InputFileName.c_str(),m_Line,yytext)); diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y index 2b2e11411..c11c84319 100644 --- a/tools/mhmake/src/mhmakeparser.y +++ b/tools/mhmake/src/mhmakeparser.y @@ -42,7 +42,7 @@ %token COMMAND %token COMMA OPENBRACE CLOSEBRACE %token STRING DOLLAREXPR EQUAL COLON DOUBLECOLON -%token IMEQUAL PEQUAL OPTEQUAL PHONY EXPORT NEWLINE INCLUDEMAK SPACE +%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE %type expression nonspaceexpression simpleexpression %type maybeemptyexpression @@ -72,6 +72,7 @@ statement: NEWLINE | includemak | ruledef | phonyrule | + autodepsrule | varassignment | imvarassignment | pvarassignment | @@ -142,6 +143,22 @@ phonyrule: PHONY COLON expression NEWLINE ; +autodepsrule: AUTODEPS COLON expression + { + vector< refptr > Items; + SplitToItems(ExpandExpression($3),Items); + vector< refptr >::iterator pIt=Items.begin(); + while (pIt!=Items.end()) + { + (*pIt)->SetAutoDepsScan(this); + pIt++; + } + PRINTF(("Defining autodeps rule : %s\n",$3.c_str())); + PRINTF((" Expanded to : %s\n",ExpandExpression($3).c_str())); + } + NEWLINE +; + exportrule: EXPORT SPACE exportstrings NEWLINE ; @@ -189,7 +206,7 @@ optvarassignment: STRING OPTEQUAL maybeemptyexpression maybeemptyexpression: NEWLINE {$$=g_EmptyString;} | expression NEWLINE | - expression SPACE NEWLINE + expression SPACE NEWLINE ; expression: nonspaceexpression | diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h index 9f8ab5b9b..ef874eb96 100644 --- a/tools/mhmake/src/util.h +++ b/tools/mhmake/src/util.h @@ -50,7 +50,7 @@ #define PLATFORM "linux" #endif -#define MHMAKEVER "2.0.6" +#define MHMAKEVER "2.1.0" class makecommand { -- cgit v1.2.3