⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genemake.cpp

📁 make文件自动生成器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      cout << endl;   }   return 0;}// *************** function bodies ******************bool Contains(const StringList& LS, const String& S){   for (SLCI i = LS.begin(); i != LS.end(); ++i) { if (*i == S) return true; }   return false;}bool SearchHB(const String& SourceFile, StringList& Headers, StringList& Bodies){   StringList NewHeaders;   StringList NewBodies;   {      ifstream is(SourceFile.c_str());      if (!(is))      {         cerr << "File " << SourceFile << " not found" << endl;         return false;      }      StringList Source;                // to hold source of a file      is >> Source;                     // get the source      for (SLI i = Source.begin(); i != Source.end(); ++i)      {         AnyString AS;         if (( OWS+"#include" > OWS+"\""+AS+"\""+DOTS ).Matches(*i)           && !Contains(Headers,AS.Value()))         {            Headers.push_back(AS.Value());            NewHeaders.push_back(AS.Value());         }         if (( OWS+"// body file:" > OWS+AS+OWS ).Matches(*i)           && !Contains(Bodies,AS.Value()))         {            Bodies.push_back(AS.Value());            NewBodies.push_back(AS.Value());         }      }   }   SLI i; bool found = true;   for (i = NewHeaders.begin(); i != NewHeaders.end(); ++i)      found = SearchHB(*i, Headers, Bodies) && found;   for (i = NewBodies.begin(); i != NewBodies.end(); ++i)      found = SearchHB(*i, Headers, Bodies) && found;   return found;}bool SearchH(const String& SourceFile, StringList& Headers){   StringList NewHeaders;   StringList NewBodies;   {      ifstream is(SourceFile.c_str());      if (!(is))      {         cerr << "File " << SourceFile << " not found" << endl;         return false;      }      StringList Source;                // to hold source of a file      is >> Source;                     // get the source      for (SLI i = Source.begin(); i != Source.end(); ++i)      {         AnyString AS;         if (( OWS+"#include" > OWS+"\""+AS+"\""+DOTS ).Matches(*i)           && !Contains(Headers,AS.Value()))         {            Headers.push_back(AS.Value());            NewHeaders.push_back(AS.Value());         }      }   }   bool found = true;   for (SLI i = NewHeaders.begin(); i != NewHeaders.end(); ++i)      found = SearchH(*i, Headers) && found;   return found;}bool SearchL(const String& SourceFile, StringList& Headers,   StringList& NewHeaders, StringList& Bodies){   {      ifstream is(SourceFile.c_str());      if (!(is))      {         cerr << "File " << SourceFile << " not found" << endl;         return false;      }      StringList Source;                // to hold source of a file      is >> Source;                     // get the source      for (SLI i = Source.begin(); i != Source.end(); ++i)      {         if (i->find(".h") != String::npos && !Contains(NewHeaders,*i))            { Headers.push_back(*i); NewHeaders.push_back(*i); }      }   }   bool found = true;   for (SLI i = NewHeaders.begin(); i != NewHeaders.end(); ++i)      found = SearchHB(*i, Headers, Bodies) && found;   return found;}bool IdentifyLibraries(const StringList& Headers,   const StringList& Libraries,   const StringList& LibraryFiles,   const StringList& LibraryFiles1,   StringList& LibrariesWanted,   StringList& PurgedHeaders){   SLCI j;   String LFA;                                // Header files available   bool found = false;   // see what libraries we want   for (j = Headers.begin(); j != Headers.end(); ++j)   {      for ( SLCI L = Libraries.begin(), LF = LibraryFiles.begin(),         LF1 = LibraryFiles1.begin(); L != Libraries.end();         ++L, ++LF, ++LF1)      {         if (LF1->find(' ' + *j + ' ') != String::npos)         {            if (!Contains(LibrariesWanted, *L))               { LibrariesWanted.push_back(*L); LFA += *LF; }            found = true; break;         }      }   }   if (!found)                                 // no libraries   {      for (SLCI j = Headers.begin(); j != Headers.end(); ++j)         PurgedHeaders.push_back(*j);      return false;   }   // see what headers are left   for (j = Headers.begin(); j != Headers.end(); ++j)   {      if (LFA.find(' ' + *j + ' ') == String::npos)         PurgedHeaders.push_back(*j);   }   return true;}void GetBodies(const StringList& Headers, StringList& Bodies){   for (SLCI i = Headers.begin(); i != Headers.end(); ++i)   {      ifstream is(i->c_str());      if (!(is))         { cerr << "File " << *i << " not found" << endl; break; }      StringList Source;                // to hold source of a file      is >> Source;                     // get the source      for (SLI j = Source.begin(); j != Source.end(); ++j)      {         AnyString AS;         if (( OWS+"// body file:" > OWS+AS+OWS ).Matches(*j)            && !Contains(Bodies,AS.Value()))            Bodies.push_back(AS.Value());      }   }}// **************** Compiler properties *****************void CompilerProperties::Preamble() const{   StringList SL;   ifstream is(code.c_str());   if (!(is)) { cerr << "File " << code << " not found" << endl; return; }   is >> SL; cout << SL;}// print a list of librariesvoid CompilerProperties::LibraryList(char* prefix, const StringList& Libraries,   char* suffix) const{   for (SLCI j = Libraries.begin(); j != Libraries.end(); ++j)      cout << prefix << *j << suffix;}// *************** Gnu G++ compiler **********************void GnuCompiler::LinkStatement(const String& Name, const String&) const{   cout << Name << ":";   Spaces(14 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;	cout << "\t\t$(CXX) -o $@ $(" << Name << "_obj) -L. -lm" << endl;   cout << endl;}void GnuCompiler::LinkStatement(const String& Name,   const StringList& Libraries) const{   cout << Name << ":";   Spaces(14 - Name.size());   cout << "\t$(" << Name << "_obj)";   LibraryList(" lib", Libraries, ".a");   cout << endl;	cout << "\t\t$(CXX) -o $@ $(" << Name << "_obj) -L.";   LibraryList(" -l", Libraries, "");   cout << " -lm" << endl;   cout << endl;}void GnuCompiler::LibStatement(const String& Name) const{   cout << "lib" << Name << ".a:";   Spaces(9 - Name.size());   cout << "\t$(" << Name << "_lobj)" << endl;	cout << "\t\t$(AR) cr $@ $(" << Name << "_lobj)" << endl;   cout << "\t\tranlib $@" << endl;   cout << endl;}// ****************** Borland 5.0 **********************void Borland50dCompiler::LinkStatement(const String& Name, const String& FN)   const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;	cout << "   $(TLINK) /x/L$(LIBPATH) -c -Tde @&&|" << endl;   cout << "c0l.obj";   for (unsigned int i = 0; i < FN.size(); ++i)      { if (FN[i]==' ') cout << '+' << endl; else cout << FN[i]; }   cout << endl << "$<,$*" << endl;   cout << "bidsl.lib+emu.lib+mathl.lib+cl.lib" << endl;   cout << endl;   cout << "|" << endl << endl;}void Borland50Compiler::LinkStatement(const String& Name, const String& FN)   const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;	cout << "   $(TLINK) /x/L$(LIBPATH) -Tpe -ap -c @&&|" << endl;   cout << "c0x32.obj";   // Borland requires separate lines   for (unsigned int i = 0; i < FN.size(); ++i)      { if (FN[i]==' ') cout << '+' << endl; else cout << FN[i]; }   cout << endl << "$<,$*" << endl;   cout << "bidsf.lib+" << endl;   cout << "import32.lib+" << endl;   cout << "cw32.lib" << endl;   cout << endl;   cout << "|" << endl << endl;}// ****************** Borland 5.5 **********************void Borland55Compiler::LinkStatement(const String& Name, const String&)   const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;	cout << "   $(TLINK) /x/L$(LIBPATH)/Gn -Tpe -ap -c @&&|" << endl;   cout << "c0x32.obj $(" << Name << "_obj),$@,,import32.lib cw32.lib" << endl;   cout << "|" << endl << endl;}void Borland55Compiler::LinkStatement(const String& Name,   const StringList& Libraries) const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)";   LibraryList(" ", Libraries, ".lib");   cout << endl;	cout << "   $(TLINK) /x/L$(LIBPATH)/Gn -Tpe -ap -c @&&|" << endl;   cout << "c0x32.obj $(" << Name << "_obj),$@,,";   LibraryList(" ", Libraries, ".lib");   cout << " import32.lib cw32.lib" << endl;   cout << "|" << endl << endl;}void Borland55Compiler::LibStatement(const String& Name) const{   cout << Name << ".lib:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_lobj)" << endl;	cout << "   $(TLIB) $@ /P32 /u $(" << Name << "_lobj)" << endl;   cout << endl;}// *************** Microsoft 6 **********************void Microsoft6Compiler::LinkStatement(const String& Name, const String&)   const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;	cout << "\t\tlink -Out:$@ $(conlibs) $(" << Name << "_obj)" << endl;   cout << endl;}void Microsoft6Compiler::LinkStatement(const String& Name,   const StringList& Libraries) const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)";   LibraryList(" ", Libraries, ".lib");   cout << endl;	cout << "\t\tlink -Out:$@ $(conlibs) $(" << Name << "_obj)";   LibraryList(" ", Libraries, ".lib");   cout << endl << endl;}void Microsoft6Compiler::LibStatement(const String& Name) const{   cout << Name << ".lib:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_lobj)" << endl;	cout << "\t\tlib -Out:$@ $(" << Name << "_lobj)" << endl;   cout << endl;}// *************** Watcom 10 **********************void Watcom10Compiler::LinkStatement(const String& Name, const String& FN)   const{   cout << Name << ".exe:";   Spaces(10 - Name.size());   cout << "\t$(" << Name << "_obj)" << endl;   int k = 0;   for (unsigned int i = 0; i < FN.size(); ++i)   {      if (FN[i]==' ')      {         if (k == 1) cout << " > link.tmp" << endl;         else if (k >= 2) cout << " >> link.tmp" << endl;         ++k;         cout << "\t\techo file ";      }      else cout << FN[i];   }   if (k == 1) cout << " > link.tmp" << endl;   else if (k >= 2) cout << " >> link.tmp" << endl;   cout << "\t\techo name " << Name << ".exe >> link.tmp" << endl;   cout << "\t\techo $(link_option) >> link.tmp" << endl;   cout << "\t\t$(LINK) @link.tmp" << endl;   cout << endl;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -