-
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
#include "pch.h"
#include <assert.h>
#include "rbuild.h"
+#include "backend/backend.h"
using std::string;
using std::vector;
"reactos" );
}
+ParseContext::ParseContext ()
+ : ifData (NULL),
+ compilationUnit (NULL)
+{
+}
+
+
+FileLocation::FileLocation ( Directory* directory,
+ std::string filename )
+ : directory (directory),
+ filename (filename)
+{
+}
+
-Project::Project ( const string& filename )
+Project::Project ( const Configuration& configuration,
+ const string& filename )
: xmlfile (filename),
node (NULL),
- head (NULL)
+ head (NULL),
+ configuration (configuration)
{
ReadXml();
}
Project::~Project ()
{
size_t i;
+ if ( _backend )
+ delete _backend;
for ( i = 0; i < modules.size (); i++ )
delete modules[i];
for ( i = 0; i < linkerFlags.size (); i++ )
s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
- FileSupportCode::WriteIfChanged ( buf, "include" SSEP "roscfg.h" );
+ FileSupportCode::WriteIfChanged ( buf, "include" + sSep + "roscfg.h" );
free ( buf );
}
}
}
- throw InvalidBuildFileException (
+ if (node == NULL)
+ node = head->subElements[0];
+
+ throw XMLInvalidBuildFileException (
node->location,
"Document contains no 'project' tag." );
}
size_t i;
for ( i = 0; i < node->subElements.size (); i++ )
- ProcessXMLSubElement ( *node->subElements[i], path );
+ {
+ ParseContext parseContext;
+ ProcessXMLSubElement ( *node->subElements[i], path, parseContext );
+ }
for ( i = 0; i < modules.size (); i++ )
modules[i]->ProcessXML ();
for ( i = 0; i < linkerFlags.size (); i++ )
void
Project::ProcessXMLSubElement ( const XMLElement& e,
const string& path,
- If* pIf )
+ ParseContext& parseContext )
{
bool subs_invalid = false;
string subpath(path);
if ( e.name == "module" )
{
- if ( pIf )
- throw InvalidBuildFileException (
+ if ( parseContext.ifData )
+ 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(),
else if ( e.name == "include" )
{
Include* include = new Include ( *this, &e );
- if ( pIf )
- pIf->data.includes.push_back ( include );
+ if ( parseContext.ifData )
+ parseContext.ifData->data.includes.push_back ( include );
else
non_if_data.includes.push_back ( include );
subs_invalid = true;
else if ( e.name == "define" )
{
Define* define = new Define ( *this, e );
- if ( pIf )
- pIf->data.defines.push_back ( define );
+ if ( parseContext.ifData )
+ parseContext.ifData->data.defines.push_back ( define );
else
non_if_data.defines.push_back ( define );
subs_invalid = true;
else if ( e.name == "compilerflag" )
{
CompilerFlag* pCompilerFlag = new CompilerFlag ( *this, e );
- if ( pIf )
- pIf->data.compilerFlags.push_back ( pCompilerFlag );
+ if ( parseContext.ifData )
+ parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
else
non_if_data.compilerFlags.push_back ( pCompilerFlag );
subs_invalid = true;
}
else if ( e.name == "if" )
{
- If* pOldIf = pIf;
- pIf = new If ( e, *this, NULL );
+ If* pOldIf = parseContext.ifData;
+ parseContext.ifData = new If ( e, *this, NULL );
if ( pOldIf )
- pOldIf->data.ifs.push_back ( pIf );
+ pOldIf->data.ifs.push_back ( parseContext.ifData );
else
- non_if_data.ifs.push_back ( pIf );
+ non_if_data.ifs.push_back ( parseContext.ifData );
subs_invalid = false;
}
else if ( e.name == "ifnot" )
{
- If* pOldIf = pIf;
- pIf = new If ( e, *this, NULL, true );
+ If* pOldIf = parseContext.ifData;
+ parseContext.ifData = new If ( e, *this, NULL, true );
if ( pOldIf )
- pOldIf->data.ifs.push_back ( pIf );
+ pOldIf->data.ifs.push_back ( parseContext.ifData );
else
- non_if_data.ifs.push_back ( pIf );
+ non_if_data.ifs.push_back ( parseContext.ifData );
subs_invalid = false;
}
else if ( e.name == "property" )
{
Property* property = new Property ( e, *this, NULL );
- if ( pIf )
- pIf->data.properties.push_back ( property );
+ if ( parseContext.ifData )
+ parseContext.ifData->data.properties.push_back ( property );
else
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, pIf );
+ ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
}
Module*
{
return xmlfile;
}
-
-