better If checks

This commit is contained in:
Ken Martin 2001-05-04 08:46:05 -04:00
parent dd2876adb0
commit faaadc4a08
5 changed files with 49 additions and 14 deletions

View File

@ -59,11 +59,19 @@ public:
const cmMakefile &mf) const = 0; const cmMakefile &mf) const = 0;
/** /**
* should this function blocker be removed, useful when one function adds a blocker * should this function blocker be removed, useful when one function adds a
* and another must remove it * blocker and another must remove it
*/ */
virtual bool ShouldRemove(const char *name, const std::vector<std::string> &args, virtual bool ShouldRemove(const char *name,
const std::vector<std::string> &args,
const cmMakefile &mf) const {return false;} const cmMakefile &mf) const {return false;}
/**
* When the end of a CMakeList file is reached this method is called. It
* is not called on the end of an INCLUDE cmake file, just at the end of a
* regular CMakeList file
*/
virtual void ScopeEnded(const cmMakefile &mf) const {}
}; };
#endif #endif

View File

@ -68,6 +68,15 @@ ShouldRemove(const char *name, const std::vector<std::string> &args,
return !this->IsFunctionBlocked(name,args,mf); return !this->IsFunctionBlocked(name,args,mf);
} }
void cmIfFunctionBlocker::
ScopeEnded(const cmMakefile &mf) const
{
cmSystemTools::Error("The end of a CMakeLists file was reached with an IF statement that was not closed properly. Within the directory: ",
mf.GetCurrentDirectory(),
(m_Not ? " The arguments to the if were: NOT " : " The arguments to the if were: "),
m_Define.c_str());
}
bool cmIfCommand::Invoke(std::vector<std::string>& args) bool cmIfCommand::Invoke(std::vector<std::string>& args)
{ {
if(args.size() < 1 ) if(args.size() < 1 )

View File

@ -55,10 +55,14 @@ class cmIfFunctionBlocker : public cmFunctionBlocker
public: public:
cmIfFunctionBlocker() {m_Not = false;} cmIfFunctionBlocker() {m_Not = false;}
virtual ~cmIfFunctionBlocker() {} virtual ~cmIfFunctionBlocker() {}
virtual bool IsFunctionBlocked(const char *name, const std::vector<std::string> &args, virtual bool IsFunctionBlocked(const char *name,
const std::vector<std::string> &args,
const cmMakefile &mf) const; const cmMakefile &mf) const;
virtual bool ShouldRemove(const char *name, const std::vector<std::string> &args, virtual bool ShouldRemove(const char *name,
const std::vector<std::string> &args,
const cmMakefile &mf) const; const cmMakefile &mf) const;
virtual void ScopeEnded(const cmMakefile &mf) const;
std::string m_Define; std::string m_Define;
bool m_Not; bool m_Not;
}; };

View File

@ -290,6 +290,19 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
} }
} }
} }
// send scope ended to and funciton blockers
if (filename)
{
// loop over all function blockers to see if any block this command
std::set<cmFunctionBlocker *>::const_iterator pos;
for (pos = m_FunctionBlockers.begin();
pos != m_FunctionBlockers.end(); ++pos)
{
(*pos)->ScopeEnded(*this);
}
}
return true; return true;
} }

View File

@ -58,6 +58,7 @@ bool cmVTKWrapJavaCommand::Invoke(std::vector<std::string>& args)
// add in a depend in the vtkVTKWrapJava executable // add in a depend in the vtkVTKWrapJava executable
m_Makefile->AddUtility("vtkWrapJava"); m_Makefile->AddUtility("vtkWrapJava");
m_Makefile->AddUtility("vtkParseJava");
// what is the current source dir // what is the current source dir
std::string cdir = m_Makefile->GetCurrentDirectory(); std::string cdir = m_Makefile->GetCurrentDirectory();
@ -108,25 +109,25 @@ void cmVTKWrapJavaCommand::FinalPass()
// wrap all the .h files // wrap all the .h files
depends.push_back(wjava); depends.push_back(wjava);
depends.push_back(pjava);
for(int classNum = 0; classNum < lastClass; classNum++) for(int classNum = 0; classNum < lastClass; classNum++)
{ {
m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str()); m_Makefile->AddSource(m_WrapClasses[classNum],m_SourceList.c_str());
// wrap java // wrap java
std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx"; std::string res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
std::string res2 = m_OriginalNames[classNum] + ".java";
std::vector<std::string> resvec;
resvec.push_back(res);
resvec.push_back(res2);
std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " " std::string cmd = wjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx"; + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].GetSourceName() + ".cxx\\\n\t" +
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), pjava + " " + m_WrapHeaders[classNum] + " "
cmd.c_str(), depends,
res.c_str(), m_LibraryName.c_str());
// parse java
res = m_WrapClasses[classNum].GetSourceName() + ".cxx";
cmd = pjava + " " + m_WrapHeaders[classNum] + " "
+ hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_OriginalNames[classNum] + ".java"; + hints + (m_WrapClasses[classNum].IsAnAbstractClass() ? " 0 " : " 1 ") + " > " + m_OriginalNames[classNum] + ".java";
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(), m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
cmd.c_str(), depends, cmd.c_str(), depends,
res.c_str(), m_LibraryName.c_str()); resvec, m_LibraryName.c_str());
} }
} }