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