Uses Reference if compiler has no port
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@48 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
0b9d261d9b
commit
ad7e89ad22
31 changed files with 509 additions and 470 deletions
|
@ -1,9 +1,18 @@
|
|||
///////////////////////////////////////////////////////////////
|
||||
//Generates forwarding headers using the information
|
||||
//in the header.lst & vendor.lst files
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Generates forwarding headers using the information
|
||||
// in the header.lst & vendor.lst files
|
||||
//
|
||||
//To create a header list from an existing directory of headers
|
||||
//dir *.h /b > headers.lst
|
||||
// To create a header list from an existing directory of headers
|
||||
// dir *.h /b > headers.lst
|
||||
//
|
||||
// Copyright Shannon Barber 2002.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
@ -11,6 +20,7 @@
|
|||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct Compiler
|
||||
|
@ -23,62 +33,49 @@ struct Compiler
|
|||
string subdir;
|
||||
};
|
||||
|
||||
typedef vector<Compiler> cv_t;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc < 2)
|
||||
if(argc != 3)
|
||||
{
|
||||
cout <<"Usage: <Header List> [Version/Vendor List]"<<endl;
|
||||
cout <<"Usage: <Header List> <Version/Vendor List>"<<endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
typedef vector<Compiler> cv_type;
|
||||
|
||||
cv_t vendors;
|
||||
cv_type vendors;
|
||||
char buf[1024];
|
||||
string check;
|
||||
string subdir;
|
||||
fstream vendor_file;
|
||||
if(argc >= 3)
|
||||
|
||||
vendor_file.open(argv[2], ios::in);
|
||||
if(!vendor_file.is_open())
|
||||
{
|
||||
vendor_file.open(argv[2], ios::in);
|
||||
if(!vendor_file.is_open())
|
||||
cout << "Unable to open vendor file: " << argv[2] << endl;
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
vendors.reserve(10);
|
||||
while(!vendor_file.eof())
|
||||
{
|
||||
cout << "Unable to open vendor file: " << argv[2] << endl;
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
vendors.reserve(10);
|
||||
while(!vendor_file.eof())
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
check = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
subdir = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
if(!(check.empty() || subdir.empty()))
|
||||
vendors.push_back(Compiler(check, subdir));
|
||||
else
|
||||
{
|
||||
check = "";
|
||||
subdir = "";
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
check = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
subdir = buf;
|
||||
vendor_file.getline(buf, 1024, '\n');
|
||||
if(!(check.empty() || subdir.empty()))
|
||||
vendors.push_back(Compiler(check, subdir));
|
||||
else
|
||||
{
|
||||
cout << "Error parsing vendors, check:" << check << "\tsubdir:" << subdir << endl;
|
||||
}
|
||||
cout << "Error parsing vendors, check:" << check << "\tsubdir:" << subdir << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //if(vendors.empty())
|
||||
{
|
||||
cout << "No vendor file provided, using defaults\n";
|
||||
vendors.reserve(10);
|
||||
vendors.push_back(Compiler("(_MSC_VER >= 1300)", "MSVC\\1300"));
|
||||
vendors.push_back(Compiler("(__BORLANDC__)", "Borland"));
|
||||
vendors.push_back(Compiler("( (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 95)) )", "Reference"));
|
||||
}
|
||||
|
||||
fstream header_list(argv[1]);
|
||||
string header;
|
||||
stringstream ss;
|
||||
|
||||
if(!header_list.is_open())
|
||||
{
|
||||
|
@ -96,49 +93,47 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
ss.str("");
|
||||
ss << "//Generated header: " << header << endl;
|
||||
size_t n = ss.str().size();
|
||||
for(size_t i=0; i<n; ++i)
|
||||
header_file << "/";
|
||||
header_file << endl;
|
||||
header_file << ss.str();
|
||||
header_file << "//Forwards to the appropriate code\n";
|
||||
string start(string("// Generated header: ")+header+'\n');
|
||||
string line(start.size(),'/');
|
||||
|
||||
header_file << line << '\n';
|
||||
header_file << start;
|
||||
header_file << "// Forwards to the appropriate code\n";
|
||||
header_file << "// that works on the detected compiler\n";
|
||||
time_t rawtime; time(&rawtime);
|
||||
header_file << "//Generated on " << ctime(&rawtime);
|
||||
header_file << endl << endl;
|
||||
|
||||
cv_t::iterator it=vendors.begin(), itEnd = vendors.end();
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
header_file << "// Generated on " << ctime(&rawtime);
|
||||
header_file << line << "\n\n";
|
||||
|
||||
cv_type::iterator it=vendors.begin(), itEnd = vendors.end();
|
||||
|
||||
header_file << "#ifdef LOKI_USE_REFERENCE\n";
|
||||
header_file << "#\tinclude \"./Reference/" << header << "\"\n";
|
||||
//header_file << "#\tinclude \".\\Reference\\" << header << "\"\n";
|
||||
header_file << "#\tinclude \"Reference/" << header << "\"\n";
|
||||
header_file << "#else\n";
|
||||
|
||||
header_file << "#\tif " << it->version_test << endl;
|
||||
//header_file << "#\t\tinclude \".\\" << it->subdir;
|
||||
header_file << "#\t\tinclude \"./" << it->subdir;
|
||||
//header_file << "\\" << header << "\"\n";
|
||||
header_file << "/" << header << "\"\n";
|
||||
header_file << "#\t\tinclude \"" << it->subdir << "/" << header << "\"\n";
|
||||
++it;
|
||||
for(; it!=itEnd; ++it)
|
||||
{
|
||||
header_file << "#\telif " << it->version_test << endl;
|
||||
//header_file << "#\t\tinclude \".\\" << it->subdir;
|
||||
header_file << "#\t\tinclude \"./" << it->subdir;
|
||||
//header_file << "\\" << header << "\"\n";
|
||||
header_file << "#\t\tinclude \"" << it->subdir;
|
||||
header_file << "/" << header << "\"\n";
|
||||
}
|
||||
header_file << "#\telse\n";
|
||||
header_file << "\t\t//Define LOKI_USE_REFERENCE and get back to us on the results\n";
|
||||
header_file << "#\t\terror Compiler not tested with Loki, #define LOKI_USE_REFERENCE\n";
|
||||
header_file << "#\t\tinclude \"Reference/" << header << "\"\n";
|
||||
header_file << "#\tendif\n";
|
||||
header_file << "#endif\n";
|
||||
}
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
system("PAUSE");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Change log:
|
||||
// September 16, 2002: Changed it to only test for compilers where ports exist,
|
||||
// else use the Reference version. It used to give an error if used on a
|
||||
// compiler that wasn't tested for. Also removed "./".
|
||||
// It still needs to test for Intel and Metrowerks, as these define _MSC_VER,
|
||||
// too. T.S.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
(__INTEL_COMPILER)
|
||||
Reference
|
||||
|
||||
(__MWERKS__)
|
||||
Reference
|
||||
|
||||
(__BORLANDC__ >= 0x560)
|
||||
Borland
|
||||
|
||||
(_MSC_VER >= 1300)
|
||||
MSVC/1300
|
||||
|
||||
(_MSC_VER >= 1200)
|
||||
MSVC/1200
|
||||
|
||||
(__BORLANDC__)
|
||||
Borland
|
||||
|
||||
(__MWERKS__)
|
||||
Reference
|
||||
|
||||
( (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)) )
|
||||
Reference
|
|
@ -16,6 +16,7 @@
|
|||
#define ABSTRACTFACTORYTEST_H
|
||||
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
#include <loki/AbstractFactory.h>
|
||||
#include "UnitTest.h"
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
#include "TypelistTest.h"
|
||||
#include "TypeManipTest.h"
|
||||
#include "TypeTraitsTest.h"
|
||||
#include "SmallObjectTest.h"
|
||||
#include "SingletonTest.h"
|
||||
#include "SmartPtrTest.h"
|
||||
#include "FactoryTest.h"
|
||||
//#include "SmallObjectTest.h"
|
||||
//#include "SingletonTest.h"
|
||||
//#include "SmartPtrTest.h"
|
||||
//#include "FactoryTest.h"
|
||||
#include "AbstractFactoryTest.h"
|
||||
#include "AssocVectorTest.h"
|
||||
#include "FunctorTest.h"
|
||||
//#include "AssocVectorTest.h"
|
||||
//#include "FunctorTest.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LokiTest
|
||||
|
@ -49,13 +49,13 @@ private:
|
|||
tests.add(typelistTest);
|
||||
tests.add(typeManipTest);
|
||||
tests.add(typeTraitsTest);
|
||||
tests.add(smallObjectTest);
|
||||
tests.add(singletonTest);
|
||||
tests.add(smartPtrTest);
|
||||
tests.add(factoryTest);
|
||||
// tests.add(smallObjectTest);
|
||||
// tests.add(singletonTest);
|
||||
// tests.add(smartPtrTest);
|
||||
// tests.add(factoryTest);
|
||||
tests.add(abstractFactoryTest);
|
||||
tests.add(assocVectorTest);
|
||||
tests.add(functorTest);
|
||||
// tests.add(assocVectorTest);
|
||||
// tests.add(functorTest);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -65,13 +65,13 @@ private:
|
|||
TypelistTest typelistTest;
|
||||
TypeManipTest typeManipTest;
|
||||
TypeTraitsTest typeTraitsTest;
|
||||
SmallObjectTest smallObjectTest;
|
||||
SingletonTest singletonTest;
|
||||
SmartPtrTest smartPtrTest;
|
||||
FactoryTest factoryTest;
|
||||
// SmallObjectTest smallObjectTest;
|
||||
// SingletonTest singletonTest;
|
||||
// SmartPtrTest smartPtrTest;
|
||||
// FactoryTest factoryTest;
|
||||
AbstractFactoryTest abstractFactoryTest;
|
||||
AssocVectorTest assocVectorTest;
|
||||
FunctorTest functorTest;
|
||||
// AssocVectorTest assocVectorTest;
|
||||
// FunctorTest functorTest;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(disable: 111 193 304 383 444 981 1418)
|
||||
# pragma warning(disable: 111 193 304 383 444 488 981 1418)
|
||||
#endif
|
||||
|
||||
#include "LokiTest.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue