mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
remove xml.h/cpp's dependancy on exception.h/cpp - in preparation to move xml.h/cpp and ssprintf.h/ccp out of rbuild directory since buildno uses them too
svn path=/trunk/; revision=19674
This commit is contained in:
parent
d80446e3a9
commit
dccb79c6ac
16 changed files with 563 additions and 282 deletions
|
@ -15,11 +15,10 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH _MAX_PATH
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif//_MSC_VER
|
||||
|
||||
#ifdef WIN32
|
||||
# include <direct.h>
|
||||
|
@ -31,9 +30,12 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "XML.h"
|
||||
#include "exception.h"
|
||||
#include "ssprintf.h"
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH _MAX_PATH
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
@ -46,6 +48,29 @@ static const char* WSEQ = " =\t\r\n";
|
|||
|
||||
string working_directory;
|
||||
|
||||
XMLException::XMLException (
|
||||
const std::string& location,
|
||||
const char* format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args, format );
|
||||
SetExceptionV ( location, format, args );
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
void XMLException::SetExceptionV ( const std::string& location, const char* format, va_list args )
|
||||
{
|
||||
_e = location + ": " + ssvprintf(format,args);
|
||||
}
|
||||
|
||||
void XMLException::SetException ( const std::string& location, const char* format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args, format );
|
||||
SetExceptionV ( location, format, args );
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
XMLIncludes::~XMLIncludes()
|
||||
{
|
||||
for ( size_t i = 0; i < this->size(); i++ )
|
||||
|
@ -56,7 +81,7 @@ void
|
|||
InitWorkingDirectory()
|
||||
{
|
||||
// store the current directory for path calculations
|
||||
working_directory.resize ( _MAX_PATH );
|
||||
working_directory.resize ( MAX_PATH );
|
||||
working_directory[0] = 0;
|
||||
getcwd ( &working_directory[0], working_directory.size() );
|
||||
working_directory.resize ( strlen ( working_directory.c_str() ) );
|
||||
|
@ -70,18 +95,17 @@ unsigned long long
|
|||
filelen ( FILE* f )
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _filelengthi64 ( _fileno(f) );
|
||||
return _filelengthi64 ( _fileno(f) );
|
||||
#else
|
||||
# ifdef __FreeBSD__
|
||||
struct stat file_stat;
|
||||
if ( fstat(fileno(f), &file_stat) != 0 )
|
||||
struct stat file_stat;
|
||||
if ( fstat(fileno(f), &file_stat) != 0 )
|
||||
# else
|
||||
struct stat64 file_stat;
|
||||
if ( fstat64(fileno(f), &file_stat) != 0 )
|
||||
struct stat64 file_stat;
|
||||
if ( fstat64(fileno(f), &file_stat) != 0 )
|
||||
# endif // __FreeBSD__
|
||||
return 0;
|
||||
return file_stat.st_size;
|
||||
|
||||
return 0;
|
||||
return file_stat.st_size;
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
|
@ -227,9 +251,10 @@ Path::RelativeFromDirectory (
|
|||
}
|
||||
|
||||
void
|
||||
Path::Split ( vector<string>& out,
|
||||
const string& path,
|
||||
bool include_last )
|
||||
Path::Split (
|
||||
vector<string>& out,
|
||||
const string& path,
|
||||
bool include_last )
|
||||
{
|
||||
string s ( path );
|
||||
const char* prev = strtok ( &s[0], "/\\" );
|
||||
|
@ -263,7 +288,7 @@ XMLFile::close()
|
|||
}
|
||||
|
||||
bool
|
||||
XMLFile::open(const string& filename_)
|
||||
XMLFile::open ( const string& filename_ )
|
||||
{
|
||||
close();
|
||||
FILE* f = fopen ( filename_.c_str(), "rb" );
|
||||
|
@ -297,7 +322,7 @@ XMLFile::next_is_text()
|
|||
}
|
||||
|
||||
bool
|
||||
XMLFile::more_tokens()
|
||||
XMLFile::more_tokens ()
|
||||
{
|
||||
return _p != _end;
|
||||
}
|
||||
|
@ -305,7 +330,7 @@ XMLFile::more_tokens()
|
|||
// get_token() is used to return a token, and move the pointer
|
||||
// past the token
|
||||
bool
|
||||
XMLFile::get_token(string& token)
|
||||
XMLFile::get_token ( string& token )
|
||||
{
|
||||
const char* tokend;
|
||||
if ( !strncmp ( _p, "<!--", 4 ) )
|
||||
|
@ -372,8 +397,9 @@ XMLAttribute::XMLAttribute()
|
|||
{
|
||||
}
|
||||
|
||||
XMLAttribute::XMLAttribute(const string& name_,
|
||||
const string& value_)
|
||||
XMLAttribute::XMLAttribute(
|
||||
const string& name_,
|
||||
const string& value_ )
|
||||
: name(name_), value(value_)
|
||||
{
|
||||
}
|
||||
|
@ -391,8 +417,9 @@ XMLAttribute& XMLAttribute::operator = ( const XMLAttribute& src )
|
|||
return *this;
|
||||
}
|
||||
|
||||
XMLElement::XMLElement ( XMLFile* xmlFile,
|
||||
const string& location )
|
||||
XMLElement::XMLElement (
|
||||
XMLFile* xmlFile,
|
||||
const string& location )
|
||||
: xmlFile ( xmlFile ),
|
||||
location ( location ),
|
||||
parentElement ( NULL )
|
||||
|
@ -422,8 +449,9 @@ XMLElement::AddSubElement ( XMLElement* e )
|
|||
// Return Value: returns true if you need to look for a </tag> for
|
||||
// the one it just parsed...
|
||||
bool
|
||||
XMLElement::Parse(const string& token,
|
||||
bool& end_tag)
|
||||
XMLElement::Parse (
|
||||
const string& token,
|
||||
bool& end_tag )
|
||||
{
|
||||
const char* p = token.c_str();
|
||||
assert ( *p == '<' );
|
||||
|
@ -493,8 +521,9 @@ XMLElement::Parse(const string& token,
|
|||
}
|
||||
else if ( name[0] != '!' )
|
||||
{
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"attributes must have values" );
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"attributes must have values" );
|
||||
}
|
||||
attributes.push_back ( new XMLAttribute ( attribute, value ) );
|
||||
}
|
||||
|
@ -502,8 +531,9 @@ XMLElement::Parse(const string& token,
|
|||
}
|
||||
|
||||
XMLAttribute*
|
||||
XMLElement::GetAttribute ( const string& attribute,
|
||||
bool required )
|
||||
XMLElement::GetAttribute (
|
||||
const string& attribute,
|
||||
bool required )
|
||||
{
|
||||
// this would be faster with a tree-based container, but our attribute
|
||||
// lists are likely to stay so short as to not be an issue.
|
||||
|
@ -514,16 +544,18 @@ XMLElement::GetAttribute ( const string& attribute,
|
|||
}
|
||||
if ( required )
|
||||
{
|
||||
throw RequiredAttributeNotFoundException ( location,
|
||||
attribute,
|
||||
name );
|
||||
throw XMLRequiredAttributeNotFoundException (
|
||||
location,
|
||||
attribute,
|
||||
name );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const XMLAttribute*
|
||||
XMLElement::GetAttribute ( const string& attribute,
|
||||
bool required ) const
|
||||
XMLElement::GetAttribute (
|
||||
const string& attribute,
|
||||
bool required ) const
|
||||
{
|
||||
// this would be faster with a tree-based container, but our attribute
|
||||
// lists are likely to stay so short as to not be an issue.
|
||||
|
@ -534,13 +566,57 @@ XMLElement::GetAttribute ( const string& attribute,
|
|||
}
|
||||
if ( required )
|
||||
{
|
||||
throw RequiredAttributeNotFoundException ( location,
|
||||
attribute,
|
||||
name );
|
||||
throw XMLRequiredAttributeNotFoundException (
|
||||
location,
|
||||
attribute,
|
||||
name );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
XMLElement::FindElement ( const std::string& type, int prev ) const
|
||||
{
|
||||
int done = subElements.size();
|
||||
while ( ++prev < done )
|
||||
{
|
||||
XMLElement* e = subElements[prev];
|
||||
if ( e->name == type )
|
||||
return prev;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
XMLElement::GetElements (
|
||||
const std::string& type,
|
||||
std::vector<XMLElement*>& v )
|
||||
{
|
||||
int find = FindElement ( type );
|
||||
v.resize ( 0 );
|
||||
while ( find != -1 )
|
||||
{
|
||||
v.push_back ( subElements[find] );
|
||||
find = FindElement ( type, find );
|
||||
}
|
||||
return v.size();
|
||||
}
|
||||
|
||||
int
|
||||
XMLElement::GetElements (
|
||||
const std::string& type,
|
||||
std::vector<const XMLElement*>& v ) const
|
||||
{
|
||||
int find = FindElement ( type );
|
||||
v.resize ( 0 );
|
||||
while ( find != -1 )
|
||||
{
|
||||
v.push_back ( subElements[find] );
|
||||
find = FindElement ( type, find );
|
||||
}
|
||||
return v.size();
|
||||
}
|
||||
|
||||
// XMLParse()
|
||||
// This function reads a "token" from the file loaded in XMLFile
|
||||
// if it finds a tag that is non-singular, it parses sub-elements and/or
|
||||
|
@ -549,30 +625,38 @@ XMLElement::GetAttribute ( const string& attribute,
|
|||
// it's parsed data. Keep calling this function until it returns NULL
|
||||
// (no more data)
|
||||
XMLElement*
|
||||
XMLParse ( XMLFile& f,
|
||||
XMLIncludes* includes,
|
||||
const Path& path,
|
||||
bool* pend_tag = NULL )
|
||||
XMLParse (
|
||||
XMLFile& f,
|
||||
XMLIncludes* includes,
|
||||
const Path& path,
|
||||
bool* pend_tag = NULL )
|
||||
{
|
||||
string token, location;
|
||||
if ( !f.get_token(token,location) )
|
||||
return NULL;
|
||||
bool end_tag, is_include = false;
|
||||
|
||||
while ( token[0] != '<'
|
||||
|| !strncmp ( token.c_str (), "<!--", 4 )
|
||||
|| !strncmp ( token.c_str (), "<?", 2 ) )
|
||||
while
|
||||
(
|
||||
token[0] != '<'
|
||||
|| !strncmp ( token.c_str (), "<!--", 4 )
|
||||
|| !strncmp ( token.c_str (), "<?", 2 )
|
||||
)
|
||||
{
|
||||
if ( token[0] != '<' )
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"expecting xml tag, not '%s'",
|
||||
token.c_str () );
|
||||
if ( !f.get_token(token,location) )
|
||||
{
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"expecting xml tag, not '%s'",
|
||||
token.c_str () );
|
||||
}
|
||||
if ( !f.get_token ( token, location ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XMLElement* e = new XMLElement ( &f,
|
||||
location );
|
||||
XMLElement* e = new XMLElement (
|
||||
&f,
|
||||
location );
|
||||
bool bNeedEnd = e->Parse ( token, end_tag );
|
||||
|
||||
if ( e->name == "xi:include" && includes )
|
||||
|
@ -581,8 +665,10 @@ XMLParse ( XMLFile& f,
|
|||
att = e->GetAttribute ( "href", true );
|
||||
assert ( att );
|
||||
string includeFile ( path.Fixup ( att->value, true ) );
|
||||
string topIncludeFile ( Path::RelativeFromWorkingDirectory ( includeFile ) );
|
||||
includes->push_back ( new XMLInclude ( e, path, topIncludeFile ) );
|
||||
string topIncludeFile (
|
||||
Path::RelativeFromWorkingDirectory ( includeFile ) );
|
||||
includes->push_back (
|
||||
new XMLInclude ( e, path, topIncludeFile ) );
|
||||
is_include = true;
|
||||
}
|
||||
|
||||
|
@ -593,9 +679,10 @@ XMLParse ( XMLFile& f,
|
|||
else if ( end_tag )
|
||||
{
|
||||
delete e;
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"end tag '%s' not expected",
|
||||
token.c_str() );
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"end tag '%s' not expected",
|
||||
token.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
return e;
|
||||
|
@ -607,26 +694,29 @@ XMLParse ( XMLFile& f,
|
|||
{
|
||||
if ( !f.get_token ( token, location ) || token.size () == 0 )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
location,
|
||||
"internal tool error - get_token() failed when more_tokens() returned true" );
|
||||
break;
|
||||
}
|
||||
if ( e->subElements.size() && !bThisMixingErrorReported )
|
||||
{
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"mixing of inner text with sub elements" );
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"mixing of inner text with sub elements" );
|
||||
bThisMixingErrorReported = true;
|
||||
}
|
||||
if ( strchr ( token.c_str (), '>' ) )
|
||||
{
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"invalid symbol '>'" );
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"invalid symbol '>'" );
|
||||
}
|
||||
if ( e->value.size() > 0 )
|
||||
{
|
||||
throw XMLSyntaxErrorException ( location,
|
||||
"multiple instances of inner text" );
|
||||
throw XMLSyntaxErrorException (
|
||||
location,
|
||||
"multiple instances of inner text" );
|
||||
e->value += " " + token;
|
||||
}
|
||||
else
|
||||
|
@ -634,13 +724,14 @@ XMLParse ( XMLFile& f,
|
|||
}
|
||||
else
|
||||
{
|
||||
XMLElement* e2 = XMLParse ( f, is_include ? NULL : includes, path, &end_tag );
|
||||
XMLElement* e2 = XMLParse (
|
||||
f, is_include ? NULL : includes, path, &end_tag );
|
||||
if ( !e2 )
|
||||
{
|
||||
string e_location = e->location;
|
||||
string e_name = e->name;
|
||||
delete e;
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
e_location,
|
||||
"end of file found looking for end tag: </%s>",
|
||||
e_name.c_str() );
|
||||
|
@ -669,8 +760,9 @@ XMLParse ( XMLFile& f,
|
|||
{
|
||||
string e_location = e->location;
|
||||
delete e;
|
||||
throw XMLSyntaxErrorException ( e_location,
|
||||
"mixing of inner text with sub elements" );
|
||||
throw XMLSyntaxErrorException (
|
||||
e_location,
|
||||
"mixing of inner text with sub elements" );
|
||||
bThisMixingErrorReported = true;
|
||||
}
|
||||
e->AddSubElement ( e2 );
|
||||
|
@ -680,7 +772,11 @@ XMLParse ( XMLFile& f,
|
|||
}
|
||||
|
||||
void
|
||||
XMLReadFile ( XMLFile& f, XMLElement& head, XMLIncludes& includes, const Path& path )
|
||||
XMLReadFile (
|
||||
XMLFile& f,
|
||||
XMLElement& head,
|
||||
XMLIncludes& includes,
|
||||
const Path& path )
|
||||
{
|
||||
for ( ;; )
|
||||
{
|
||||
|
@ -692,8 +788,9 @@ XMLReadFile ( XMLFile& f, XMLElement& head, XMLIncludes& includes, const Path& p
|
|||
}
|
||||
|
||||
XMLElement*
|
||||
XMLLoadInclude ( XMLInclude& include,
|
||||
XMLIncludes& includes )
|
||||
XMLLoadInclude (
|
||||
XMLInclude& include,
|
||||
XMLIncludes& includes )
|
||||
{
|
||||
XMLAttribute* att;
|
||||
att = include.e->GetAttribute("href", true);
|
||||
|
@ -720,13 +817,17 @@ XMLLoadInclude ( XMLInclude& include,
|
|||
{
|
||||
att = e3->GetAttribute ( "href", true );
|
||||
assert ( att );
|
||||
string includeFile ( include.path.Fixup ( att->value, true ) );
|
||||
string topIncludeFile ( Path::RelativeFromWorkingDirectory ( includeFile ) );
|
||||
XMLInclude* fallbackInclude = new XMLInclude ( e3, include.path, topIncludeFile );
|
||||
return XMLLoadInclude ( *fallbackInclude, includes );
|
||||
string includeFile (
|
||||
include.path.Fixup ( att->value, true ) );
|
||||
string topIncludeFile (
|
||||
Path::RelativeFromWorkingDirectory ( includeFile ) );
|
||||
XMLInclude* fallbackInclude =
|
||||
new XMLInclude ( e3, include.path, topIncludeFile );
|
||||
return XMLLoadInclude (
|
||||
*fallbackInclude, includes );
|
||||
}
|
||||
}
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
e2->location,
|
||||
"<xi:fallback> must have a <xi:include> sub-element" );
|
||||
return NULL;
|
||||
|
@ -737,8 +838,9 @@ XMLLoadInclude ( XMLInclude& include,
|
|||
else
|
||||
{
|
||||
include.fileExists = true;
|
||||
XMLElement* new_e = new XMLElement ( fInc,
|
||||
include.e->location );
|
||||
XMLElement* new_e = new XMLElement (
|
||||
fInc,
|
||||
include.e->location );
|
||||
new_e->name = "xi:included";
|
||||
Path path2 ( include.path, att->value );
|
||||
XMLReadFile ( *fInc, *new_e, includes, path2 );
|
||||
|
@ -754,10 +856,12 @@ XMLLoadFile ( const string& filename,
|
|||
XMLFile* f = new XMLFile();
|
||||
|
||||
if ( !f->open ( filename ) )
|
||||
throw FileNotFoundException ( filename );
|
||||
{
|
||||
throw XMLFileNotFoundException ( "(virtual)", filename );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XMLElement* head = new XMLElement ( f,
|
||||
"(virtual)" );
|
||||
XMLElement* head = new XMLElement ( f, "(virtual)" );
|
||||
|
||||
XMLReadFile ( *f, *head, includes, path );
|
||||
|
||||
|
@ -767,17 +871,17 @@ XMLLoadFile ( const string& filename,
|
|||
XMLElement* e2 = XMLLoadInclude ( *includes[i], includes );
|
||||
if ( !e2 )
|
||||
{
|
||||
throw FileNotFoundException (
|
||||
ssprintf ( "%s (referenced from %s)",
|
||||
e->GetAttribute ( "top_href", true )->value.c_str (),
|
||||
f->Location ().c_str () ) );
|
||||
throw XMLFileNotFoundException (
|
||||
f->Location(),
|
||||
e->GetAttribute ( "top_href", true )->value );
|
||||
}
|
||||
XMLElement* parent = e->parentElement;
|
||||
XMLElement** parent_container = NULL;
|
||||
if ( !parent )
|
||||
{
|
||||
string location = e->location;
|
||||
delete e;
|
||||
throw Exception ( "internal tool error: xi:include doesn't have a parent" );
|
||||
throw XMLException ( location, "internal tool error: xi:include doesn't have a parent" );
|
||||
return NULL;
|
||||
}
|
||||
for ( size_t j = 0; j < parent->subElements.size (); j++ )
|
||||
|
@ -790,8 +894,9 @@ XMLLoadFile ( const string& filename,
|
|||
}
|
||||
if ( !parent_container )
|
||||
{
|
||||
string location = e->location;
|
||||
delete e;
|
||||
throw Exception ( "internal tool error: couldn't find xi:include in parent's sub-elements" );
|
||||
throw XMLException ( location, "internal tool error: couldn't find xi:include in parent's sub-elements" );
|
||||
return NULL;
|
||||
}
|
||||
// replace inclusion tree with the imported tree
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#ifndef XML_H
|
||||
#define XML_H
|
||||
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdarg.h>
|
||||
|
||||
class XMLElement;
|
||||
|
||||
|
@ -34,6 +36,75 @@ unsigned long long
|
|||
#endif
|
||||
filelen ( FILE* f );
|
||||
|
||||
class XMLException
|
||||
{
|
||||
public:
|
||||
XMLException ( const std::string& location, const char* format, ... );
|
||||
const std::string& operator *() { return _e; }
|
||||
|
||||
protected:
|
||||
XMLException() {}
|
||||
void SetExceptionV ( const std::string& location, const char* format, va_list args );
|
||||
void SetException ( const std::string& location, const char* format, ... );
|
||||
|
||||
private:
|
||||
std::string _e;
|
||||
};
|
||||
|
||||
class XMLSyntaxErrorException : public XMLException
|
||||
{
|
||||
public:
|
||||
XMLSyntaxErrorException (
|
||||
const std::string& location,
|
||||
const char* format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args, format );
|
||||
SetExceptionV ( location, format, args );
|
||||
va_end ( args );
|
||||
}
|
||||
};
|
||||
|
||||
class XMLRequiredAttributeNotFoundException : public XMLException
|
||||
{
|
||||
public:
|
||||
XMLRequiredAttributeNotFoundException (
|
||||
const std::string& location,
|
||||
const std::string& attributeName,
|
||||
const std::string& elementName )
|
||||
{
|
||||
SetException ( location, "Required attribute '%s' not found in element '%s'",
|
||||
attributeName.c_str(),
|
||||
elementName.c_str() );
|
||||
}
|
||||
};
|
||||
|
||||
class XMLInvalidBuildFileException : public XMLException
|
||||
{
|
||||
public:
|
||||
XMLInvalidBuildFileException (
|
||||
const std::string& location,
|
||||
const char* format,
|
||||
... )
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args, format );
|
||||
SetExceptionV ( location, format, args );
|
||||
va_end ( args );
|
||||
}
|
||||
};
|
||||
|
||||
class XMLFileNotFoundException : public XMLException
|
||||
{
|
||||
public:
|
||||
XMLFileNotFoundException (
|
||||
const std::string& location,
|
||||
const std::string& filename )
|
||||
{
|
||||
SetException ( location, "Can't open file '%s'", filename.c_str() );
|
||||
}
|
||||
};
|
||||
|
||||
class Path
|
||||
{
|
||||
std::vector<std::string> path;
|
||||
|
@ -46,9 +117,10 @@ public:
|
|||
static std::string RelativeFromWorkingDirectory ( const std::string& path );
|
||||
static std::string RelativeFromDirectory ( const std::string& path, const std::string& base_directory);
|
||||
|
||||
static void Split ( std::vector<std::string>& out,
|
||||
const std::string& path,
|
||||
bool include_last );
|
||||
static void Split (
|
||||
std::vector<std::string>& out,
|
||||
const std::string& path,
|
||||
bool include_last );
|
||||
};
|
||||
|
||||
class XMLInclude
|
||||
|
@ -59,8 +131,13 @@ public:
|
|||
std::string topIncludeFilename;
|
||||
bool fileExists;
|
||||
|
||||
XMLInclude ( XMLElement* e_, const Path& path_, const std::string topIncludeFilename_ )
|
||||
: e ( e_ ), path ( path_ ), topIncludeFilename ( topIncludeFilename_ )
|
||||
XMLInclude (
|
||||
XMLElement* e_,
|
||||
const Path& path_,
|
||||
const std::string topIncludeFilename_ )
|
||||
: e ( e_ ),
|
||||
path ( path_ ),
|
||||
topIncludeFilename ( topIncludeFilename_ )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -117,21 +194,43 @@ public:
|
|||
std::vector<XMLElement*> subElements;
|
||||
std::string value;
|
||||
|
||||
XMLElement ( XMLFile* xmlFile,
|
||||
const std::string& location );
|
||||
XMLElement (
|
||||
XMLFile* xmlFile,
|
||||
const std::string& location );
|
||||
|
||||
~XMLElement();
|
||||
bool Parse(const std::string& token,
|
||||
bool& end_tag);
|
||||
|
||||
bool Parse (
|
||||
const std::string& token,
|
||||
bool& end_tag);
|
||||
|
||||
void AddSubElement ( XMLElement* e );
|
||||
XMLAttribute* GetAttribute ( const std::string& attribute,
|
||||
bool required);
|
||||
const XMLAttribute* GetAttribute ( const std::string& attribute,
|
||||
bool required) const;
|
||||
|
||||
XMLAttribute* GetAttribute (
|
||||
const std::string& attribute,
|
||||
bool required);
|
||||
|
||||
const XMLAttribute* GetAttribute (
|
||||
const std::string& attribute,
|
||||
bool required ) const;
|
||||
|
||||
int FindElement (
|
||||
const std::string& type,
|
||||
int prev = -1 ) const;
|
||||
|
||||
int GetElements (
|
||||
const std::string& type,
|
||||
std::vector<XMLElement*>& v );
|
||||
|
||||
int GetElements (
|
||||
const std::string& type,
|
||||
std::vector<const XMLElement*>& v ) const;
|
||||
};
|
||||
|
||||
XMLElement*
|
||||
XMLLoadFile ( const std::string& filename,
|
||||
const Path& path,
|
||||
XMLIncludes& includes );
|
||||
XMLLoadFile (
|
||||
const std::string& filename,
|
||||
const Path& path,
|
||||
XMLIncludes& includes );
|
||||
|
||||
#endif // XML_H
|
||||
|
|
|
@ -1944,8 +1944,9 @@ MingwModuleHandler::GenerateInvocations () const
|
|||
|
||||
if ( invoke.invokeModule->type != BuildTool )
|
||||
{
|
||||
throw InvalidBuildFileException ( module.node.location,
|
||||
"Only modules of type buildtool can be invoked." );
|
||||
throw XMLInvalidBuildFileException (
|
||||
module.node.location,
|
||||
"Only modules of type buildtool can be invoked." );
|
||||
}
|
||||
|
||||
string invokeTarget = module.GetInvocationTarget ( i );
|
||||
|
|
|
@ -72,7 +72,7 @@ Bootstrap::Initialize ()
|
|||
{
|
||||
if ( !IsSupportedModuleType ( module->type ) )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<bootstrap> is not applicable for this module type." );
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ CompilerFlag::Initialize ()
|
|||
{
|
||||
if (node.value.size () == 0)
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<compilerflag> is empty." );
|
||||
}
|
||||
|
|
|
@ -26,25 +26,28 @@ Exception::Exception ()
|
|||
|
||||
Exception::Exception ( const string& message )
|
||||
{
|
||||
Message = message;
|
||||
_e = message;
|
||||
}
|
||||
|
||||
Exception::Exception ( const char* format,
|
||||
...)
|
||||
Exception::Exception ( const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args,
|
||||
format);
|
||||
Message = ssvprintf ( format,
|
||||
args);
|
||||
va_start ( args, format);
|
||||
_e = ssvprintf ( format, args);
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
void Exception::SetMessage ( const char* message,
|
||||
va_list args)
|
||||
void Exception::SetMessage ( const char* format, ...)
|
||||
{
|
||||
Message = ssvprintf ( message,
|
||||
args);
|
||||
va_list args;
|
||||
va_start ( args, format);
|
||||
_e = ssvprintf ( format, args);
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
void Exception::SetMessageV ( const char* message, va_list args )
|
||||
{
|
||||
_e = ssvprintf ( message, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,30 +57,29 @@ OutOfMemoryException::OutOfMemoryException ()
|
|||
}
|
||||
|
||||
|
||||
InvalidOperationException::InvalidOperationException ( const char* filename,
|
||||
const int linenumber )
|
||||
InvalidOperationException::InvalidOperationException (
|
||||
const char* filename,
|
||||
const int linenumber )
|
||||
: Exception ( "%s:%d", filename, linenumber )
|
||||
{
|
||||
Message = ssprintf ( "%s:%d",
|
||||
filename,
|
||||
linenumber );
|
||||
}
|
||||
|
||||
InvalidOperationException::InvalidOperationException ( const char* filename,
|
||||
const int linenumber,
|
||||
const char* message,
|
||||
... )
|
||||
InvalidOperationException::InvalidOperationException (
|
||||
const char* filename,
|
||||
const int linenumber,
|
||||
const char* message,
|
||||
... )
|
||||
{
|
||||
string errorMessage;
|
||||
va_list args;
|
||||
va_start ( args,
|
||||
message );
|
||||
errorMessage = ssvprintf ( message,
|
||||
args );
|
||||
va_start ( args, message );
|
||||
errorMessage = ssvprintf ( message, args );
|
||||
va_end ( args );
|
||||
Message = ssprintf ( "%s:%d %s",
|
||||
filename,
|
||||
linenumber,
|
||||
errorMessage.c_str () );
|
||||
SetMessage (
|
||||
"%s:%d %s",
|
||||
filename,
|
||||
linenumber,
|
||||
errorMessage.c_str () );
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,49 +99,15 @@ AccessDeniedException::AccessDeniedException ( const string& filename)
|
|||
}
|
||||
|
||||
|
||||
InvalidBuildFileException::InvalidBuildFileException ( const string& location,
|
||||
const char* message,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args,
|
||||
message );
|
||||
SetLocationMessage ( location, message, args );
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
InvalidBuildFileException::InvalidBuildFileException ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InvalidBuildFileException::SetLocationMessage ( const std::string& location,
|
||||
const char* message,
|
||||
va_list args )
|
||||
{
|
||||
Message = location + ": " + ssvprintf ( message, args );
|
||||
}
|
||||
|
||||
XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
|
||||
const char* message,
|
||||
... )
|
||||
{
|
||||
va_list args;
|
||||
va_start ( args,
|
||||
message );
|
||||
SetLocationMessage ( location, message, args );
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
|
||||
RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
|
||||
const string& location,
|
||||
const string& attributeName,
|
||||
const string& elementName )
|
||||
: InvalidBuildFileException ( location,
|
||||
"Required attribute '%s' not found on '%s'.",
|
||||
attributeName.c_str (),
|
||||
elementName.c_str ())
|
||||
: XMLInvalidBuildFileException (
|
||||
location,
|
||||
"Required attribute '%s' not found on '%s'.",
|
||||
attributeName.c_str (),
|
||||
elementName.c_str ())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -147,10 +115,11 @@ InvalidAttributeValueException::InvalidAttributeValueException (
|
|||
const string& location,
|
||||
const string& name,
|
||||
const string& value )
|
||||
: InvalidBuildFileException ( location,
|
||||
"Attribute '%s' has an invalid value '%s'.",
|
||||
name.c_str (),
|
||||
value.c_str () )
|
||||
: XMLInvalidBuildFileException (
|
||||
location,
|
||||
"Attribute '%s' has an invalid value '%s'.",
|
||||
name.c_str (),
|
||||
value.c_str () )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -171,9 +140,10 @@ UnknownBackendException::UnknownBackendException ( const string& name )
|
|||
|
||||
UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
|
||||
int moduletype )
|
||||
: InvalidBuildFileException ( location,
|
||||
"module type requested: %i",
|
||||
moduletype )
|
||||
: XMLInvalidBuildFileException (
|
||||
location,
|
||||
"module type requested: %i",
|
||||
moduletype )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define __EXCEPTION_H
|
||||
|
||||
#include "pch.h"
|
||||
#include "XML.h"
|
||||
|
||||
class Exception
|
||||
{
|
||||
|
@ -26,11 +27,15 @@ public:
|
|||
Exception ( const std::string& message );
|
||||
Exception ( const char* format,
|
||||
...);
|
||||
std::string Message;
|
||||
const std::string& operator *() { return _e; }
|
||||
|
||||
protected:
|
||||
Exception ();
|
||||
void SetMessage ( const char* message,
|
||||
va_list args );
|
||||
void SetMessage ( const char* message, ... );
|
||||
void SetMessageV ( const char* message, va_list args );
|
||||
|
||||
private:
|
||||
std::string _e;
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,30 +73,8 @@ public:
|
|||
std::string Filename;
|
||||
};
|
||||
|
||||
class InvalidBuildFileException : public Exception
|
||||
{
|
||||
public:
|
||||
InvalidBuildFileException ( const std::string& location,
|
||||
const char* message,
|
||||
...);
|
||||
void SetLocationMessage ( const std::string& location,
|
||||
const char* message,
|
||||
va_list args );
|
||||
protected:
|
||||
InvalidBuildFileException ();
|
||||
};
|
||||
|
||||
|
||||
class XMLSyntaxErrorException : public InvalidBuildFileException
|
||||
{
|
||||
public:
|
||||
XMLSyntaxErrorException ( const std::string& location,
|
||||
const char* message,
|
||||
... );
|
||||
};
|
||||
|
||||
|
||||
class RequiredAttributeNotFoundException : public InvalidBuildFileException
|
||||
class RequiredAttributeNotFoundException : public XMLInvalidBuildFileException
|
||||
{
|
||||
public:
|
||||
RequiredAttributeNotFoundException ( const std::string& location,
|
||||
|
@ -100,7 +83,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class InvalidAttributeValueException : public InvalidBuildFileException
|
||||
class InvalidAttributeValueException : public XMLInvalidBuildFileException
|
||||
{
|
||||
public:
|
||||
InvalidAttributeValueException ( const std::string& location,
|
||||
|
@ -122,7 +105,7 @@ public:
|
|||
UnknownBackendException ( const std::string& name );
|
||||
};
|
||||
|
||||
class UnknownModuleTypeException : public InvalidBuildFileException
|
||||
class UnknownModuleTypeException : public XMLInvalidBuildFileException
|
||||
{
|
||||
public:
|
||||
UnknownModuleTypeException ( const std::string& location,
|
||||
|
|
|
@ -62,12 +62,11 @@ void
|
|||
Include::ProcessXML()
|
||||
{
|
||||
const XMLAttribute* att;
|
||||
att = node->GetAttribute ( "base",
|
||||
false );
|
||||
att = node->GetAttribute ( "base", false );
|
||||
if ( att )
|
||||
{
|
||||
if ( !module )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"'base' attribute illegal from global <include>" );
|
||||
bool referenceResolved = false;
|
||||
|
@ -87,7 +86,7 @@ Include::ProcessXML()
|
|||
}
|
||||
}
|
||||
if ( !referenceResolved )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"<include> attribute 'base' references non-existant project or module '%s'",
|
||||
att->value.c_str() );
|
||||
|
|
|
@ -56,7 +56,7 @@ LinkerFlag::ProcessXML ()
|
|||
{
|
||||
if ( node.value.size () == 0 )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<linkerflag> is empty." );
|
||||
}
|
||||
|
|
|
@ -62,10 +62,12 @@ LinkerScript::ProcessXML()
|
|||
}
|
||||
}
|
||||
if ( !referenceResolved )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<linkerscript> attribute 'base' references non-existant project or module '%s'",
|
||||
att->value.c_str() );
|
||||
}
|
||||
directory = NormalizeFilename ( basePath + sSep + node.value );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -123,11 +123,11 @@ GetSubPath (
|
|||
const string& att_value )
|
||||
{
|
||||
if ( !att_value.size() )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
location,
|
||||
"<directory> tag has empty 'name' attribute" );
|
||||
if ( strpbrk ( att_value.c_str (), "/\\?*:<>|" ) )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
location,
|
||||
"<directory> tag has invalid characters in 'name' attribute" );
|
||||
if ( !path.size() )
|
||||
|
@ -415,17 +415,21 @@ Module::ProcessXML()
|
|||
if ( type == Alias )
|
||||
{
|
||||
if ( aliasedModuleName == name )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' cannot link against itself",
|
||||
name.c_str() );
|
||||
const Module* m = project.LocateModule ( aliasedModuleName );
|
||||
}
|
||||
const Module* m = project.LocateModule ( aliasedModuleName );
|
||||
if ( !m )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' trying to alias non-existant module '%s'",
|
||||
name.c_str(),
|
||||
aliasedModuleName.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
size_t i;
|
||||
|
@ -471,9 +475,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
if ( !stricmp ( att->value.c_str(), "true" ) )
|
||||
first = true;
|
||||
else if ( stricmp ( att->value.c_str(), "false" ) )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"attribute 'first' of <file> element can only be 'true' or 'false'" );
|
||||
}
|
||||
}
|
||||
string switches = "";
|
||||
att = e.GetAttribute ( "switches", false );
|
||||
|
@ -546,31 +552,39 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
else if ( e.name == "invoke" )
|
||||
{
|
||||
if ( parseContext.ifData )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<invoke> is not a valid sub-element of <if>" );
|
||||
}
|
||||
invocations.push_back ( new Invoke ( e, *this ) );
|
||||
subs_invalid = false;
|
||||
}
|
||||
else if ( e.name == "dependency" )
|
||||
{
|
||||
if ( parseContext.ifData )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<dependency> is not a valid sub-element of <if>" );
|
||||
}
|
||||
dependencies.push_back ( new Dependency ( e, *this ) );
|
||||
subs_invalid = true;
|
||||
}
|
||||
else if ( e.name == "importlibrary" )
|
||||
{
|
||||
if ( parseContext.ifData )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<importlibrary> is not a valid sub-element of <if>" );
|
||||
}
|
||||
if ( importLibrary )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"Only one <importlibrary> is valid per module" );
|
||||
}
|
||||
importLibrary = new ImportLibrary ( e, *this );
|
||||
subs_invalid = true;
|
||||
}
|
||||
|
@ -609,9 +623,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
else if ( e.name == "linkerscript" )
|
||||
{
|
||||
if ( linkerScript )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"Only one <linkerscript> is valid per module" );
|
||||
}
|
||||
linkerScript = new LinkerScript ( project, this, e );
|
||||
subs_invalid = true;
|
||||
}
|
||||
|
@ -622,7 +638,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
else if ( e.name == "property" )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<property> is not a valid sub-element of <module>" );
|
||||
}
|
||||
|
@ -634,13 +650,17 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
else if ( e.name == "pch" )
|
||||
{
|
||||
if ( parseContext.ifData )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<pch> is not a valid sub-element of <if>" );
|
||||
}
|
||||
if ( pch )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"Only one <pch> is valid per module" );
|
||||
}
|
||||
pch = new PchFile (
|
||||
e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) );
|
||||
subs_invalid = true;
|
||||
|
@ -662,18 +682,21 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
{
|
||||
if ( autoRegister != NULL)
|
||||
{
|
||||
throw InvalidBuildFileException ( e.location,
|
||||
"there can be only one <%s> element for a module",
|
||||
e.name.c_str() );
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"there can be only one <%s> element for a module",
|
||||
e.name.c_str() );
|
||||
}
|
||||
autoRegister = new AutoRegister ( project, this, e );
|
||||
subs_invalid = true;
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size() > 0 )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
|
||||
parseContext.ifData = pOldIf;
|
||||
|
@ -1019,27 +1042,33 @@ Library::Library ( const XMLElement& _node,
|
|||
importedModule(_module.project.LocateModule(_name))
|
||||
{
|
||||
if ( module.name == name )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' cannot link against itself",
|
||||
name.c_str() );
|
||||
}
|
||||
if ( !importedModule )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' trying to import non-existant module '%s'",
|
||||
module.name.c_str(),
|
||||
name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Library::ProcessXML()
|
||||
{
|
||||
if ( !module.project.LocateModule ( name ) )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' is trying to link against non-existant module '%s'",
|
||||
module.name.c_str(),
|
||||
name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1060,11 +1089,13 @@ Invoke::ProcessXML()
|
|||
{
|
||||
invokeModule = module.project.LocateModule ( att->value );
|
||||
if ( invokeModule == NULL )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' is trying to invoke non-existant module '%s'",
|
||||
module.name.c_str(),
|
||||
att->value.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < node.subElements.size (); i++ )
|
||||
|
@ -1086,9 +1117,12 @@ Invoke::ProcessXMLSubElement ( const XMLElement& e )
|
|||
ProcessXMLSubElementOutput ( *e.subElements[i] );
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size() > 0 )
|
||||
throw InvalidBuildFileException ( e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1097,13 +1131,17 @@ Invoke::ProcessXMLSubElementInput ( const XMLElement& e )
|
|||
bool subs_invalid = false;
|
||||
if ( e.name == "inputfile" && e.value.size () > 0 )
|
||||
{
|
||||
input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + cSep + e.value ) ) );
|
||||
input.push_back ( new InvokeFile (
|
||||
e, FixSeparator ( module.path + cSep + e.value ) ) );
|
||||
subs_invalid = true;
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size() > 0 )
|
||||
throw InvalidBuildFileException ( e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1112,14 +1150,17 @@ Invoke::ProcessXMLSubElementOutput ( const XMLElement& e )
|
|||
bool subs_invalid = false;
|
||||
if ( e.name == "outputfile" && e.value.size () > 0 )
|
||||
{
|
||||
output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + cSep + e.value ) ) );
|
||||
output.push_back ( new InvokeFile (
|
||||
e, FixSeparator ( module.path + cSep + e.value ) ) );
|
||||
subs_invalid = true;
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size() > 0 )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1197,10 +1238,13 @@ Dependency::ProcessXML()
|
|||
{
|
||||
dependencyModule = module.project.LocateModule ( node.value );
|
||||
if ( dependencyModule == NULL )
|
||||
throw InvalidBuildFileException ( node.location,
|
||||
"module '%s' depend on non-existant module '%s'",
|
||||
module.name.c_str(),
|
||||
node.value.c_str() );
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"module '%s' depend on non-existant module '%s'",
|
||||
module.name.c_str(),
|
||||
node.value.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1338,7 +1382,7 @@ AutoRegister::GetAutoRegisterType( string type )
|
|||
return DllInstall;
|
||||
if ( type == "Both" )
|
||||
return Both;
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<autoregister> type attribute must be DllRegisterServer, DllInstall or Both." );
|
||||
}
|
||||
|
@ -1348,7 +1392,7 @@ AutoRegister::Initialize ()
|
|||
{
|
||||
if ( !IsSupportedModuleType ( module->type ) )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<autoregister> is not applicable for this module type." );
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ Project::ReadXml ()
|
|||
if (node == NULL)
|
||||
node = head->subElements[0];
|
||||
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"Document contains no 'project' tag." );
|
||||
}
|
||||
|
@ -295,12 +295,12 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
if ( e.name == "module" )
|
||||
{
|
||||
if ( parseContext.ifData )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<module> is not a valid sub-element of <if>" );
|
||||
Module* module = new Module ( *this, e, path );
|
||||
if ( LocateModule ( module->name ) )
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"module name conflict: '%s' (originally defined at %s)",
|
||||
module->name.c_str(),
|
||||
|
@ -387,10 +387,12 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
non_if_data.properties.push_back ( property );
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size() )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
|
||||
}
|
||||
|
|
|
@ -36,8 +36,9 @@ static string RootXmlFile = "ReactOS.xml";
|
|||
static Configuration configuration;
|
||||
|
||||
bool
|
||||
ParseAutomaticDependencySwitch ( char switchChar2,
|
||||
char* switchStart )
|
||||
ParseAutomaticDependencySwitch (
|
||||
char switchChar2,
|
||||
char* switchStart )
|
||||
{
|
||||
switch ( switchChar2 )
|
||||
{
|
||||
|
@ -62,8 +63,9 @@ ParseAutomaticDependencySwitch ( char switchChar2,
|
|||
}
|
||||
|
||||
bool
|
||||
ParseCompilationUnitSwitch ( char switchChar2,
|
||||
char* switchStart )
|
||||
ParseCompilationUnitSwitch (
|
||||
char switchChar2,
|
||||
char* switchStart )
|
||||
{
|
||||
switch ( switchChar2 )
|
||||
{
|
||||
|
@ -79,8 +81,9 @@ ParseCompilationUnitSwitch ( char switchChar2,
|
|||
}
|
||||
|
||||
bool
|
||||
ParseVCProjectSwitch ( char switchChar2,
|
||||
char* switchStart )
|
||||
ParseVCProjectSwitch (
|
||||
char switchChar2,
|
||||
char* switchStart )
|
||||
{
|
||||
switch ( switchChar2 )
|
||||
{
|
||||
|
@ -153,8 +156,11 @@ ParseSwitch ( int argc, char** argv, int index )
|
|||
{
|
||||
case 'v':
|
||||
if (switchChar2 == 's')
|
||||
return ParseVCProjectSwitch ( switchChar2,
|
||||
argv[index] );
|
||||
{
|
||||
return ParseVCProjectSwitch (
|
||||
switchChar2,
|
||||
argv[index] );
|
||||
}
|
||||
else
|
||||
configuration.Verbose = true;
|
||||
break;
|
||||
|
@ -162,11 +168,13 @@ ParseSwitch ( int argc, char** argv, int index )
|
|||
configuration.CleanAsYouGo = true;
|
||||
break;
|
||||
case 'd':
|
||||
return ParseAutomaticDependencySwitch ( switchChar2,
|
||||
argv[index] );
|
||||
return ParseAutomaticDependencySwitch (
|
||||
switchChar2,
|
||||
argv[index] );
|
||||
case 'u':
|
||||
return ParseCompilationUnitSwitch ( switchChar2,
|
||||
argv[index] );
|
||||
return ParseCompilationUnitSwitch (
|
||||
switchChar2,
|
||||
argv[index] );
|
||||
case 'r':
|
||||
RootXmlFile = string(&argv[index][2]);
|
||||
break;
|
||||
|
@ -175,8 +183,9 @@ ParseSwitch ( int argc, char** argv, int index )
|
|||
case 'p':
|
||||
return ParseProxyMakefileSwitch ( switchChar2 );
|
||||
default:
|
||||
printf ( "Unknown switch -%c\n",
|
||||
switchChar );
|
||||
printf (
|
||||
"Unknown switch -%c\n",
|
||||
switchChar );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -239,18 +248,23 @@ main ( int argc, char** argv )
|
|||
printf ( "done\n" );
|
||||
project.WriteConfigurationFile ();
|
||||
project.ExecuteInvocations ();
|
||||
Backend* backend = Backend::Factory::Create ( BuildSystem,
|
||||
project,
|
||||
configuration );
|
||||
Backend* backend = Backend::Factory::Create (
|
||||
BuildSystem,
|
||||
project,
|
||||
configuration );
|
||||
backend->Process ();
|
||||
delete backend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception& ex)
|
||||
catch ( Exception& ex )
|
||||
{
|
||||
printf ( "%s\n",
|
||||
ex.Message.c_str () );
|
||||
printf ( "%s\n", (*ex).c_str () );
|
||||
return 1;
|
||||
}
|
||||
catch ( XMLException& ex )
|
||||
{
|
||||
printf ( "%s\n", (*ex).c_str () );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ LINK32=link.exe
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../lib/inflib" /I "../../include/reactos" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INFLIB_HOST" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@ -253,6 +253,10 @@ SOURCE=.\stubbedcomponent.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\syssetupgenerator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\testsupportcode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -292,5 +296,57 @@ SOURCE=.\test.h
|
|||
SOURCE=.\XML.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "inflib"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\builddep.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infcommon.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infcore.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infget.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infhost.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infhostgen.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infhostget.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infhostglue.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infhostput.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\inflib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infpriv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\lib\inflib\infput.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -59,10 +59,12 @@ StubbedComponent::ProcessXMLSubElement ( const XMLElement& e )
|
|||
subs_invalid = false;
|
||||
}
|
||||
if ( subs_invalid && e.subElements.size () > 0 )
|
||||
throw InvalidBuildFileException (
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
e.location,
|
||||
"<%s> cannot have sub-elements",
|
||||
e.name.c_str() );
|
||||
}
|
||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXMLSubElement ( *e.subElements[i] );
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ StubbedSymbol::ProcessXML ()
|
|||
{
|
||||
if ( node.value.size () == 0 )
|
||||
{
|
||||
throw InvalidBuildFileException (
|
||||
throw XMLInvalidBuildFileException (
|
||||
node.location,
|
||||
"<symbol> is empty." );
|
||||
}
|
||||
|
|
|
@ -167,10 +167,14 @@ public:
|
|||
if (test.Failed)
|
||||
numberOfFailedTests++;
|
||||
}
|
||||
catch (Exception& ex)
|
||||
catch ( Exception& ex )
|
||||
{
|
||||
printf("%s\n",
|
||||
ex.Message.c_str());
|
||||
printf ( "%s\n", (*ex).c_str () );
|
||||
numberOfFailedTests++;
|
||||
}
|
||||
catch ( XMLException& ex )
|
||||
{
|
||||
printf ( "%s\n", (*ex).c_str () );
|
||||
numberOfFailedTests++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue