Author: hpoussin
Date: Sun Jul 27 11:17:50 2008
New Revision: 34852
URL:
http://svn.reactos.org/svn/reactos?rev=34852&view=rev
Log:
Resolve <if> and <ifnot> elements during parsing time.
Backend don't have to deal anymore with if-able modules, defines, ...
Modified:
trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp
trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
trunk/reactos/tools/rbuild/module.cpp
trunk/reactos/tools/rbuild/project.cpp
trunk/reactos/tools/rbuild/rbuild.h
trunk/reactos/tools/rbuild/testsupportcode.cpp
Modified: trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/codeb…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp [iso-8859-1] Sun Jul 27
11:17:50 2008
@@ -423,16 +423,6 @@
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
- for ( i = 0; i < data.ifs.size(); i++ )
- {
- const Property* property = _lookup_property( module, data.ifs[i]->property );
- if ( property != NULL )
- {
- if ( data.ifs[i]->value == property->value && data.ifs[i]->negated
== false ||
- data.ifs[i]->value != property->value && data.ifs[i]->negated)
- ifs_list.push_back ( &data.ifs[i]->data );
- }
- }
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp [iso-8859-1] Sun Jul 27 11:17:50
2008
@@ -247,25 +247,6 @@
if ( compilationUnit.GetFiles ().size () != 1 )
return false;
}
- // intentionally make a copy so that we can append more work in
- // the middle of processing without having to go recursive
- vector<If*> v = module.non_if_data.ifs;
- for ( i = 0; i < v.size (); i++ )
- {
- size_t j;
- If& rIf = *v[i];
- // check for sub-ifs to add to list
- const vector<If*>& ifs = rIf.data.ifs;
- for ( j = 0; j < ifs.size (); j++ )
- v.push_back ( ifs[j] );
- const vector<CompilationUnit*>& compilationUnits =
rIf.data.compilationUnits;
- for ( j = 0; j < compilationUnits.size (); j++ )
- {
- CompilationUnit& compilationUnit = *compilationUnits[j];
- if ( compilationUnit.GetFiles ().size () != 1 )
- return false;
- }
- }
return true;
}
@@ -455,27 +436,6 @@
GenerateProjectCFlagsMacro ( assignmentOperation,
data );
}
-
- for ( i = 0; i < data.ifs.size(); i++ )
- {
- const If& rIf = *data.ifs[i];
- if ( rIf.data.defines.size()
- || rIf.data.includes.size()
- || rIf.data.ifs.size() )
- {
- fprintf (
- fMakefile,
- "ifeq (\"$(%s)\",\"%s\")\n",
- rIf.property.c_str(),
- rIf.value.c_str() );
- GenerateGlobalCFlagsAndProperties (
- "+=",
- rIf.data );
- fprintf (
- fMakefile,
- "endif\n\n" );
- }
- }
}
void
@@ -508,32 +468,10 @@
const char* assignmentOperation,
IfableData& data ) const
{
- size_t i;
-
if ( data.compilerFlags.size() )
{
GenerateProjectGccOptionsMacro ( assignmentOperation,
data );
- }
-
- for ( i = 0; i < data.ifs.size(); i++ )
- {
- If& rIf = *data.ifs[i];
- if ( rIf.data.compilerFlags.size()
- || rIf.data.ifs.size() )
- {
- fprintf (
- fMakefile,
- "ifeq (\"$(%s)\",\"%s\")\n",
- rIf.property.c_str(),
- rIf.value.c_str() );
- GenerateProjectGccOptions (
- "+=",
- rIf.data );
- fprintf (
- fMakefile,
- "endif\n\n" );
- }
}
}
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp [iso-8859-1] Sun Jul 27
11:17:50 2008
@@ -814,8 +814,6 @@
const vector<LinkerFlag*>* linkerFlags,
set<const Define *>& used_defs )
{
- size_t i;
-
GenerateMacro ( assignmentOperation,
cflagsMacro,
data,
@@ -852,34 +850,6 @@
libsMacro.c_str(),
assignmentOperation,
deps.c_str() );
- }
- }
-
- const vector<If*>& ifs = data.ifs;
- for ( i = 0; i < ifs.size(); i++ )
- {
- If& rIf = *ifs[i];
- if ( rIf.data.defines.size()
- || rIf.data.includes.size()
- || rIf.data.libraries.size()
- || rIf.data.compilationUnits.size()
- || rIf.data.compilerFlags.size()
- || rIf.data.ifs.size() )
- {
- fprintf (
- fMakefile,
- "%s (\"$(%s)\",\"%s\")\n",
- rIf.negated ? "ifneq" : "ifeq",
- rIf.property.c_str(),
- rIf.value.c_str() );
- GenerateMacros (
- "+=",
- rIf.data,
- NULL,
- used_defs );
- fprintf (
- fMakefile,
- "endif\n\n" );
}
}
}
@@ -923,32 +893,6 @@
backend->GetFullName ( compilationName ).c_str () );
}
fprintf ( fMakefile, "\n" );
- }
-
- const vector<If*>& ifs = data.ifs;
- for ( i = 0; i < ifs.size(); i++ )
- {
- If& rIf = *ifs[i];
- if ( rIf.data.defines.size()
- || rIf.data.includes.size()
- || rIf.data.libraries.size()
- || rIf.data.compilationUnits.size()
- || rIf.data.compilerFlags.size()
- || rIf.data.ifs.size() )
- {
- fprintf (
- fMakefile,
- "%s (\"$(%s)\",\"%s\")\n",
- rIf.negated ? "ifneq" : "ifeq",
- rIf.property.c_str(),
- rIf.value.c_str() );
- GenerateSourceMacros (
- "+=",
- rIf.data );
- fprintf (
- fMakefile,
- "endif\n\n" );
- }
}
vector<CompilationUnit*> sourceCompilationUnits;
@@ -1081,32 +1025,6 @@
delete mcresources[i];
}
fprintf ( fMakefile, "\n" );
- }
-
- const vector<If*>& ifs = data.ifs;
- for ( i = 0; i < ifs.size(); i++ )
- {
- If& rIf = *ifs[i];
- if ( rIf.data.defines.size()
- || rIf.data.includes.size()
- || rIf.data.libraries.size()
- || rIf.data.compilationUnits.size()
- || rIf.data.compilerFlags.size()
- || rIf.data.ifs.size() )
- {
- fprintf (
- fMakefile,
- "%s (\"$(%s)\",\"%s\")\n",
- rIf.negated ? "ifneq" : "ifeq",
- rIf.property.c_str(),
- rIf.value.c_str() );
- GenerateObjectMacros (
- "+=",
- rIf.data );
- fprintf (
- fMakefile,
- "endif\n\n" );
- }
}
vector<CompilationUnit*> sourceCompilationUnits;
@@ -1704,12 +1622,6 @@
"\n" );
}
- const vector<If*>& ifs = data.ifs;
- for ( i = 0; i < ifs.size(); i++ )
- {
- GenerateObjectFileTargets ( ifs[i]->data );
- }
-
vector<CompilationUnit*> sourceCompilationUnits;
GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
for ( i = 0; i < sourceCompilationUnits.size (); i++ )
Modified: trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msbui…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp [iso-8859-1] Sun Jul 27
11:17:50 2008
@@ -100,16 +100,6 @@
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
- for ( i = 0; i < data.ifs.size(); i++ )
- {
- const Property* property = _lookup_property( module, data.ifs[i]->property );
- if ( property != NULL )
- {
- if ( data.ifs[i]->value == property->value && data.ifs[i]->negated
== false ||
- data.ifs[i]->value != property->value && data.ifs[i]->negated)
- ifs_list.push_back ( &data.ifs[i]->data );
- }
- }
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
Modified: trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp [iso-8859-1] Sun Jul 27 11:17:50
2008
@@ -95,9 +95,6 @@
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
- // TODO FIXME - refactor needed - we're discarding if conditions
- for ( i = 0; i < data.ifs.size(); i++ )
- ifs_list.push_back ( &data.ifs[i]->data );
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp [iso-8859-1] Sun Jul 27
11:17:50 2008
@@ -147,16 +147,6 @@
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
- for ( i = 0; i < data.ifs.size(); i++ )
- {
- const Property* property = _lookup_property( module, data.ifs[i]->property );
- if ( property != NULL )
- {
- if ( data.ifs[i]->value == property->value && data.ifs[i]->negated
== false ||
- data.ifs[i]->value != property->value && data.ifs[i]->negated)
- ifs_list.push_back ( &data.ifs[i]->data );
- }
- }
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
Modified: trunk/reactos/tools/rbuild/module.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?re…
==============================================================================
--- trunk/reactos/tools/rbuild/module.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/module.cpp [iso-8859-1] Sun Jul 27 11:17:50 2008
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 Casper S. Hornstrup
+ * Copyright (C) 2008 Hervé Poussineau
*
* 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
@@ -210,8 +211,6 @@
delete compilerFlags[i];
for ( i = 0; i < modules.size(); i++ )
delete modules[i];
- for ( i = 0; i < ifs.size (); i++ )
- delete ifs[i];
for ( i = 0; i < compilationUnits.size (); i++ )
delete compilationUnits[i];
}
@@ -229,8 +228,6 @@
properties[i]->ProcessXML ();
for ( i = 0; i < compilerFlags.size(); i++ )
compilerFlags[i]->ProcessXML ();
- for ( i = 0; i < ifs.size (); i++ )
- ifs[i]->ProcessXML ();
for ( i = 0; i < compilationUnits.size (); i++ )
compilationUnits[i]->ProcessXML ();
}
@@ -606,7 +603,6 @@
const string& relative_path,
ParseContext& parseContext )
{
- If* pOldIf = parseContext.ifData;
CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
bool subs_invalid = false;
string subpath ( relative_path );
@@ -652,46 +648,35 @@
else
{
CompilationUnit* pCompilationUnit = new CompilationUnit ( pFile );
- if ( parseContext.ifData )
- parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit );
+ string ext = ToLower ( GetExtension ( e.value ) );
+ if ( ext == ".idl" )
+ {
+ // put .idl files at the start of the module
+ non_if_data.compilationUnits.insert (
+ non_if_data.compilationUnits.begin(),
+ pCompilationUnit );
+ }
+ else if ( ext == ".asm" || ext == ".s" )
+ {
+ // put .asm files at the end of the module
+ non_if_data.compilationUnits.push_back ( pCompilationUnit );
+ non_if_data.asmFiles++;
+ }
else
{
- string ext = ToLower ( GetExtension ( e.value ) );
- if ( ext == ".idl" )
- {
- // put .idl files at the start of the module
- non_if_data.compilationUnits.insert (
- non_if_data.compilationUnits.begin(),
- pCompilationUnit );
- }
- else if ( ext == ".asm" || ext == ".s" )
- {
- // put .asm files at the end of the module
- non_if_data.compilationUnits.push_back ( pCompilationUnit );
- non_if_data.asmFiles++;
- }
- else
- {
- // put other files in the middle
- non_if_data.compilationUnits.insert (
- non_if_data.compilationUnits.end() - non_if_data.asmFiles,
- pCompilationUnit );
- }
+ // put other files in the middle
+ non_if_data.compilationUnits.insert (
+ non_if_data.compilationUnits.end() - non_if_data.asmFiles,
+ pCompilationUnit );
}
}
- if ( parseContext.ifData )
- parseContext.ifData->data.files.push_back ( pFile );
- else
- non_if_data.files.push_back ( pFile );
+ non_if_data.files.push_back ( pFile );
subs_invalid = true;
}
else if ( e.name == "library" && e.value.size () )
{
Library* pLibrary = new Library ( e, *this, e.value );
- if ( parseContext.ifData )
- parseContext.ifData->data.libraries.push_back ( pLibrary );
- else
- non_if_data.libraries.push_back ( pLibrary );
+ non_if_data.libraries.push_back ( pLibrary );
subs_invalid = true;
}
else if ( e.name == "directory" )
@@ -718,73 +703,37 @@
else if ( e.name == "include" )
{
Include* include = new Include ( project, &e, this );
- if ( parseContext.ifData )
- parseContext.ifData->data.includes.push_back ( include );
- else
- non_if_data.includes.push_back ( include );
+ non_if_data.includes.push_back ( include );
subs_invalid = true;
}
else if ( e.name == "define" )
{
Define* pDefine = new Define ( project, this, e );
- if ( parseContext.ifData )
- parseContext.ifData->data.defines.push_back ( pDefine );
- else
- non_if_data.defines.push_back ( pDefine );
+ non_if_data.defines.push_back ( pDefine );
subs_invalid = true;
}
else if ( e.name == "metadata" )
{
- if ( parseContext.ifData )
- {
- throw XMLInvalidBuildFileException (
- e.location,
- "<metadata> is not a valid sub-element of <if>" );
- }
metadata = new Metadata ( e, *this );
subs_invalid = false;
}
else if ( e.name == "invoke" )
{
- if ( parseContext.ifData )
- {
- 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 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 == "bootsector" )
{
- if ( parseContext.ifData )
- {
- throw XMLInvalidBuildFileException (
- e.location,
- "<bootsector> is not a valid sub-element of <if>" );
- }
bootSector = new Bootsector ( e, this );
subs_invalid = true;
}
else if ( e.name == "importlibrary" )
{
- if ( parseContext.ifData )
- {
- throw XMLInvalidBuildFileException (
- e.location,
- "<importlibrary> is not a valid sub-element of <if>" );
- }
if ( importLibrary )
{
throw XMLInvalidBuildFileException (
@@ -794,31 +743,40 @@
SetImportLibrary ( new ImportLibrary ( project, e, this ) );
subs_invalid = true;
}
- else if ( e.name == "if" )
- {
- parseContext.ifData = new If ( e, project, this );
- if ( pOldIf )
- pOldIf->data.ifs.push_back ( parseContext.ifData );
- else
- non_if_data.ifs.push_back ( parseContext.ifData );
+ else if ( e.name == "if" || e.name == "ifnot" )
+ {
+ const XMLAttribute* name;
+ name = e.GetAttribute ( "property", true );
+ assert( name );
+ const Property *property = project.LookupProperty( name->value );
+ if ( !property )
+ {
+ // Property not found
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Test on unknown property '%s' at
%s",
+ name->value.c_str (), e.location.c_str () );
+ }
+
+ const XMLAttribute* value;
+ value = e.GetAttribute ( "value", true );
+ assert( value );
+
+ bool negate = ( e.name == "ifnot" );
+ bool equality = ( property->value == value->value );
+ if ( equality == negate )
+ {
+ // Failed, skip this element
+ if ( project.configuration.Verbose )
+ printf("Skipping 'If' at %s\n", e.location.c_str () );
+ return;
+ }
subs_invalid = false;
}
- else if ( e.name == "ifnot" )
- {
- parseContext.ifData = new If ( e, project, this, true );
- if ( pOldIf )
- pOldIf->data.ifs.push_back ( parseContext.ifData );
- else
- non_if_data.ifs.push_back ( parseContext.ifData );
- subs_invalid = false;
- }
else if ( e.name == "compilerflag" )
{
CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
- if ( parseContext.ifData )
- parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
- else
- non_if_data.compilerFlags.push_back ( pCompilerFlag );
+ non_if_data.compilerFlags.push_back ( pCompilerFlag );
subs_invalid = true;
}
else if ( e.name == "linkerflag" )
@@ -828,12 +786,6 @@
}
else if ( e.name == "linkerscript" )
{
- if ( parseContext.ifData )
- {
- throw XMLInvalidBuildFileException (
- e.location,
- "<linkerscript> is not a valid sub-element of <if>" );
- }
if ( linkerScript )
{
throw XMLInvalidBuildFileException (
@@ -873,12 +825,6 @@
}
else if ( e.name == "pch" )
{
- if ( parseContext.ifData )
- {
- throw XMLInvalidBuildFileException (
- e.location,
- "<pch> is not a valid sub-element of <if>" );
- }
if ( pch )
{
throw XMLInvalidBuildFileException (
@@ -905,10 +851,7 @@
if ( project.configuration.CompilationUnitsEnabled )
{
CompilationUnit* pCompilationUnit = new CompilationUnit ( &project, this, &e
);
- if ( parseContext.ifData )
- parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit );
- else
- non_if_data.compilationUnits.push_back ( pCompilationUnit );
+ non_if_data.compilationUnits.push_back ( pCompilationUnit );
parseContext.compilationUnit = pCompilationUnit;
}
subs_invalid = false;
@@ -934,7 +877,6 @@
}
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXMLSubElement ( *e.subElements[i], subdirectory, subpath, parseContext );
- parseContext.ifData = pOldIf;
parseContext.compilationUnit = pOldCompilationUnit;
}
@@ -1335,11 +1277,6 @@
if ( compilationUnit->HasFileWithExtension ( extension ) )
return true;
}
- for ( i = 0; i < data.ifs.size (); i++ )
- {
- if ( HasFileWithExtension ( data.ifs[i]->data, extension ) )
- return true;
- }
return false;
}
@@ -1828,34 +1765,6 @@
}
-If::If ( const XMLElement& node_,
- const Project& project_,
- const Module* module_,
- const bool negated_ )
- : node(node_), project(project_), module(module_), negated(negated_)
-{
- const XMLAttribute* att;
-
- att = node.GetAttribute ( "property", true );
- assert(att);
- property = att->value;
-
- att = node.GetAttribute ( "value", true );
- assert(att);
- value = att->value;
-}
-
-If::~If ()
-{
-}
-
-void
-If::ProcessXML()
-{
-
-}
-
-
Property::Property ( const XMLElement& node_,
const Project& project_,
const Module* module_ )
Modified: trunk/reactos/tools/rbuild/project.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/project.cpp?r…
==============================================================================
--- trunk/reactos/tools/rbuild/project.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/project.cpp [iso-8859-1] Sun Jul 27 11:17:50 2008
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 Casper S. Hornstrup
+ * Copyright (C) 2008 Hervé Poussineau
*
* 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
@@ -93,8 +94,7 @@
}
ParseContext::ParseContext ()
- : ifData (NULL),
- compilationUnit (NULL)
+ : compilationUnit (NULL)
{
}
@@ -373,27 +373,6 @@
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 ();
for ( i = 0; i < modules.size (); i++ )
@@ -410,7 +389,6 @@
ParseContext& parseContext )
{
bool subs_invalid = false;
- If* pOldIf = parseContext.ifData;
string subpath(path);
if ( e.name == "module" )
@@ -422,10 +400,7 @@
"module name conflict: '%s' (originally defined at %s)",
module->name.c_str(),
module->node.location.c_str() );
- if ( parseContext.ifData )
- parseContext.ifData->data.modules.push_back( module );
- else
- non_if_data.modules.push_back ( module );
+ non_if_data.modules.push_back ( module );
return; // defer processing until later
}
else if ( e.name == "cdfile" )
@@ -449,28 +424,19 @@
else if ( e.name == "include" )
{
Include* include = new Include ( *this, &e );
- if ( parseContext.ifData )
- parseContext.ifData->data.includes.push_back ( include );
- else
- non_if_data.includes.push_back ( include );
+ non_if_data.includes.push_back ( include );
subs_invalid = true;
}
else if ( e.name == "define" )
{
Define* define = new Define ( *this, e );
- if ( parseContext.ifData )
- parseContext.ifData->data.defines.push_back ( define );
- else
- non_if_data.defines.push_back ( define );
+ non_if_data.defines.push_back ( define );
subs_invalid = true;
}
else if ( e.name == "compilerflag" )
{
CompilerFlag* pCompilerFlag = new CompilerFlag ( *this, e );
- if ( parseContext.ifData )
- parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
- else
- non_if_data.compilerFlags.push_back ( pCompilerFlag );
+ non_if_data.compilerFlags.push_back ( pCompilerFlag );
subs_invalid = true;
}
else if ( e.name == "linkerflag" )
@@ -478,31 +444,40 @@
linkerFlags.push_back ( new LinkerFlag ( *this, e ) );
subs_invalid = true;
}
- else if ( e.name == "if" )
- {
- parseContext.ifData = new If ( e, *this, NULL );
- if ( pOldIf )
- pOldIf->data.ifs.push_back ( parseContext.ifData );
- else
- non_if_data.ifs.push_back ( parseContext.ifData );
+ else if ( e.name == "if" || e.name == "ifnot" )
+ {
+ const XMLAttribute* name;
+ name = e.GetAttribute ( "property", true );
+ assert( name );
+ const Property *property = LookupProperty( name->value );
+ if ( !property )
+ {
+ // Property not found
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Test on unknown property '%s' at
%s",
+ name->value.c_str (), e.location.c_str () );
+ }
+
+ const XMLAttribute* value;
+ value = e.GetAttribute ( "value", true );
+ assert( value );
+
+ bool negate = ( e.name == "ifnot" );
+ bool equality = ( property->value == value->value );
+ if ( equality == negate )
+ {
+ // Failed, skip this element
+ if ( configuration.Verbose )
+ printf("Skipping 'If' at %s\n", e.location.c_str () );
+ return;
+ }
subs_invalid = false;
}
- else if ( e.name == "ifnot" )
- {
- parseContext.ifData = new If ( e, *this, NULL, true );
- if ( pOldIf )
- pOldIf->data.ifs.push_back ( parseContext.ifData );
- else
- non_if_data.ifs.push_back ( parseContext.ifData );
- subs_invalid = false;
- }
else if ( e.name == "property" )
{
Property* property = new Property ( e, *this, NULL );
- if ( parseContext.ifData )
- parseContext.ifData->data.properties.push_back ( property );
- else
- non_if_data.properties.push_back ( property );
+ non_if_data.properties.push_back ( property );
}
if ( subs_invalid && e.subElements.size() )
{
@@ -513,8 +488,6 @@
}
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
-
- parseContext.ifData = pOldIf;
}
Module*
Modified: trunk/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=…
==============================================================================
--- trunk/reactos/tools/rbuild/rbuild.h [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/rbuild.h [iso-8859-1] Sun Jul 27 11:17:50 2008
@@ -83,7 +83,6 @@
class InvokeFile;
class Dependency;
class ImportLibrary;
-class If;
class CompilerFlag;
class LinkerFlag;
class LinkerScript;
@@ -198,7 +197,6 @@
class ParseContext
{
public:
- If* ifData;
CompilationUnit* compilationUnit;
ParseContext ();
};
@@ -215,7 +213,6 @@
std::vector<Property*> properties;
std::vector<Module*> modules;
std::vector<CompilerFlag*> compilerFlags;
- std::vector<If*> ifs;
int asmFiles; // number of .asm files in compilationUnits
IfableData();
@@ -254,9 +251,9 @@
const Module* LocateModule ( const std::string& name ) const;
const std::string& GetProjectFilename () const;
std::string ResolveProperties ( const std::string& s ) const;
+ const Property* LookupProperty ( const std::string& name ) const;
private:
std::string ResolveNextProperty ( const std::string& s ) const;
- const Property* LookupProperty ( const std::string& name ) const;
void SetConfigurationOption ( char* s,
std::string name,
std::string alternativeName );
@@ -600,26 +597,6 @@
};
-class If
-{
-public:
- const XMLElement& node;
- const Project& project;
- const Module* module;
- const bool negated;
- std::string property, value;
- IfableData data;
-
- If ( const XMLElement& node_,
- const Project& project_,
- const Module* module_,
- const bool negated_ = false );
- ~If();
-
- void ProcessXML();
-};
-
-
class CompilerFlag
{
public:
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/testsupportco…
==============================================================================
--- trunk/reactos/tools/rbuild/testsupportcode.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/testsupportcode.cpp [iso-8859-1] Sun Jul 27 11:17:50 2008
@@ -312,27 +312,6 @@
if ( !compilationUnits[i]->IsGeneratedFile () && IsTestFile ( filename ) )
list.push_back ( filename );
}
- // intentionally make a copy so that we can append more work in
- // the middle of processing without having to go recursive
- vector<If*> v = module.non_if_data.ifs;
- for ( i = 0; i < v.size (); i++ )
- {
- size_t j;
- If& rIf = *v[i];
- // check for sub-ifs to add to list
- const vector<If*>& ifs = rIf.data.ifs;
- for ( j = 0; j < ifs.size (); j++ )
- v.push_back ( ifs[j] );
- const vector<CompilationUnit*>& compilationUnits =
rIf.data.compilationUnits;
- for ( j = 0; j < compilationUnits.size (); j++ )
- {
- CompilationUnit& compilationUnit = *compilationUnits[j];
- const FileLocation& sourceFileLocation = compilationUnits[j]->GetFilename ();
- string filename = sourceFileLocation.relative_path + sSep + sourceFileLocation.name;
- if ( !compilationUnit.IsGeneratedFile () && IsTestFile ( filename ) )
- list.push_back ( filename );
- }
- }
}
char*