瀏覽代碼

better If checks

Ken Martin 24 年之前
父節點
當前提交
faaadc4a08
共有 5 個文件被更改,包括 49 次插入14 次删除
  1. 11 3
      Source/cmFunctionBlocker.h
  2. 9 0
      Source/cmIfCommand.cxx
  3. 6 2
      Source/cmIfCommand.h
  4. 13 0
      Source/cmMakefile.cxx
  5. 10 9
      Source/cmVTKWrapJavaCommand.cxx

+ 11 - 3
Source/cmFunctionBlocker.h

@@ -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
-   * and another must remove it
+   * should this function blocker be removed, useful when one function adds a
+   * 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

+ 9 - 0
Source/cmIfCommand.cxx

@@ -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 )

+ 6 - 2
Source/cmIfCommand.h

@@ -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;
 };
 };

+ 13 - 0
Source/cmMakefile.cxx

@@ -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;
 }
 }
 
 

+ 10 - 9
Source/cmVTKWrapJavaCommand.cxx

@@ -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";
-    m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
-                                 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_WrapClasses[classNum].GetSourceName() + ".cxx\\\n\t" + 
+      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());
     }
     }
 }
 }