#include <assert.h>
#include "rbuild.h"
+#include "backend/backend.h"
using std::string;
using std::vector;
/* static */ string
Environment::GetIntermediatePath ()
{
+ string defaultIntermediate =
+ string( "obj-" ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "i386" );
return GetEnvironmentVariablePathOrDefault ( "ROS_INTERMEDIATE",
- "obj-i386" );
+ defaultIntermediate );
}
/* static */ string
Environment::GetOutputPath ()
{
+ string defaultOutput =
+ string( "output-" ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "i386" );
return GetEnvironmentVariablePathOrDefault ( "ROS_OUTPUT",
- "output-i386" );
+ defaultOutput );
}
/* static */ string
Environment::GetInstallPath ()
{
+ string defaultInstall =
+ string( "reactos." ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "" );
return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
+ defaultInstall );
+}
+
+/* static */ string
+Environment::GetCdOutputPath ()
+{
+ return GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT",
"reactos" );
}
+/* static */ string
+Environment::GetAutomakeFile ( const std::string& defaultFile )
+{
+ return GetEnvironmentVariablePathOrDefault ( "ROS_AUTOMAKE",
+ defaultFile );
+}
+
ParseContext::ParseContext ()
: ifData (NULL),
compilationUnit (NULL)
node (NULL),
head (NULL),
configuration (configuration)
-{
+{
+ _backend = NULL;
ReadXml();
}
Project::~Project ()
{
size_t i;
+ if ( _backend )
+ delete _backend;
+#ifdef NOT_NEEDED_SINCE_THESE_ARE_CLEANED_BY_IFABLE_DATA
for ( i = 0; i < modules.size (); i++ )
delete modules[i];
+#endif
for ( i = 0; i < linkerFlags.size (); i++ )
delete linkerFlags[i];
for ( i = 0; i < cdfiles.size (); i++ )
s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
- FileSupportCode::WriteIfChanged ( buf, "include" + sSep + "roscfg.h" );
+ FileSupportCode::WriteIfChanged ( buf, Environment::GetIntermediatePath() + sSep + "include" + sSep + "roscfg.h" );
free ( buf );
}
{
node = head->subElements[i];
string path;
- this->ProcessXML ( path );
+ ProcessXML ( path );
return;
}
}
if (node == NULL)
node = head->subElements[0];
- throw InvalidBuildFileException (
+ throw XMLInvalidBuildFileException (
node->location,
"Document contains no 'project' tag." );
}
att = node->GetAttribute ( "makefile", true );
assert(att);
- makefile = att->value;
+ makefile = Environment::GetAutomakeFile ( att->value );
size_t i;
for ( i = 0; i < node->subElements.size (); i++ )
ParseContext parseContext;
ProcessXMLSubElement ( *node->subElements[i], path, parseContext );
}
- for ( i = 0; i < modules.size (); i++ )
- modules[i]->ProcessXML ();
+
+ non_if_data.ProcessXML ();
+
+ non_if_data.ExtractModules( modules );
+
+ for ( i = 0; i < non_if_data.ifs.size (); i++ )
+ {
+ const Property *property =
+ LookupProperty( non_if_data.ifs[i]->property );
+
+ if( !property ) continue;
+
+ bool conditionTrue =
+ (non_if_data.ifs[i]->negated &&
+ (property->value != non_if_data.ifs[i]->value)) ||
+ (property->value == non_if_data.ifs[i]->value);
+ if ( conditionTrue )
+ non_if_data.ifs[i]->data.ExtractModules( modules );
+ else
+ {
+ If * if_data = non_if_data.ifs[i];
+ non_if_data.ifs.erase ( non_if_data.ifs.begin () + i );
+ delete if_data;
+ i--;
+ }
+ }
for ( i = 0; i < linkerFlags.size (); i++ )
linkerFlags[i]->ProcessXML ();
- non_if_data.ProcessXML ();
+ for ( i = 0; i < modules.size (); i++ )
+ modules[i]->ProcessXML ();
for ( i = 0; i < cdfiles.size (); i++ )
cdfiles[i]->ProcessXML ();
for ( i = 0; i < installfiles.size (); i++ )
ParseContext& parseContext )
{
bool subs_invalid = false;
+ If* pOldIf = parseContext.ifData;
+
string subpath(path);
if ( e.name == "module" )
{
- if ( parseContext.ifData )
- throw InvalidBuildFileException (
- 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(),
module->node.location.c_str() );
- modules.push_back ( module );
+ if ( parseContext.ifData )
+ parseContext.ifData->data.modules.push_back( module );
+ else
+ non_if_data.modules.push_back ( module );
return; // defer processing until later
}
else if ( e.name == "cdfile" )
else if ( e.name == "directory" )
{
const XMLAttribute* att = e.GetAttribute ( "name", true );
+ const XMLAttribute* base = e.GetAttribute ( "root", false );
assert(att);
- subpath = GetSubPath ( e.location, path, att->value );
+ subpath = GetSubPath ( *this, e.location, path, base, att->value );
}
else if ( e.name == "include" )
{
}
else if ( e.name == "if" )
{
- If* pOldIf = parseContext.ifData;
parseContext.ifData = new If ( e, *this, NULL );
if ( pOldIf )
pOldIf->data.ifs.push_back ( parseContext.ifData );
}
else if ( e.name == "ifnot" )
{
- If* pOldIf = parseContext.ifData;
parseContext.ifData = new If ( e, *this, NULL, true );
if ( pOldIf )
pOldIf->data.ifs.push_back ( parseContext.ifData );
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 );
+
+ parseContext.ifData = pOldIf;
}
Module*
return NULL;
}
-std::string
+const std::string&
Project::GetProjectFilename () const
{
return xmlfile;