mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +00:00
Resolve <if> and <ifnot> elements during parsing time.
Backend don't have to deal anymore with if-able modules, defines, ... svn path=/trunk/; revision=34852
This commit is contained in:
parent
e880f2361a
commit
d4d0c4fdf6
|
@ -423,16 +423,6 @@ CBBackend::_generate_cbproj ( const Module& module )
|
|||
{
|
||||
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++ )
|
||||
{
|
||||
|
|
|
@ -247,25 +247,6 @@ MingwBackend::CanEnablePreCompiledHeaderSupportForModule ( const Module& module
|
|||
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 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
|
|||
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,33 +468,11 @@ MingwBackend::GenerateProjectGccOptions (
|
|||
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" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string
|
||||
|
|
|
@ -814,8 +814,6 @@ MingwModuleHandler::GenerateMacros (
|
|||
const vector<LinkerFlag*>* linkerFlags,
|
||||
set<const Define *>& used_defs )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
GenerateMacro ( assignmentOperation,
|
||||
cflagsMacro,
|
||||
data,
|
||||
|
@ -854,34 +852,6 @@ MingwModuleHandler::GenerateMacros (
|
|||
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" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -925,32 +895,6 @@ MingwModuleHandler::GenerateSourceMacros (
|
|||
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;
|
||||
GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
|
||||
for ( i = 0; i < sourceCompilationUnits.size (); i++ )
|
||||
|
@ -1083,32 +1027,6 @@ MingwModuleHandler::GenerateObjectMacros (
|
|||
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;
|
||||
GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
|
||||
for ( i = 0; i < sourceCompilationUnits.size (); i++ )
|
||||
|
@ -1704,12 +1622,6 @@ MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
|
|||
"\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++ )
|
||||
|
|
|
@ -100,16 +100,6 @@ MsBuildBackend::_generate_sources ( const Module& module )
|
|||
{
|
||||
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++ )
|
||||
{
|
||||
|
|
|
@ -95,9 +95,6 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
|||
{
|
||||
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++ )
|
||||
{
|
||||
|
|
|
@ -147,16 +147,6 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
|||
{
|
||||
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++ )
|
||||
{
|
||||
|
|
|
@ -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 @@ IfableData::~IfableData()
|
|||
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 @@ void IfableData::ProcessXML ()
|
|||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
SetImportLibrary ( new ImportLibrary ( project, e, this ) );
|
||||
subs_invalid = true;
|
||||
}
|
||||
else if ( e.name == "if" )
|
||||
else if ( e.name == "if" || e.name == "ifnot" )
|
||||
{
|
||||
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 );
|
||||
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 );
|
||||
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 == "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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
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 @@ Module::HasFileWithExtension (
|
|||
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 @@ ImportLibrary::ImportLibrary ( const Project& project,
|
|||
}
|
||||
|
||||
|
||||
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_ )
|
||||
|
|
|
@ -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 @@ Environment::GetAutomakeFile ( const std::string& defaultFile )
|
|||
}
|
||||
|
||||
ParseContext::ParseContext ()
|
||||
: ifData (NULL),
|
||||
compilationUnit (NULL)
|
||||
: compilationUnit (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -373,27 +373,6 @@ Project::ProcessXML ( const string& path )
|
|||
|
||||
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 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
ParseContext& parseContext )
|
||||
{
|
||||
bool subs_invalid = false;
|
||||
If* pOldIf = parseContext.ifData;
|
||||
|
||||
string subpath(path);
|
||||
if ( e.name == "module" )
|
||||
|
@ -422,10 +400,7 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
"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 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
linkerFlags.push_back ( new LinkerFlag ( *this, e ) );
|
||||
subs_invalid = true;
|
||||
}
|
||||
else if ( e.name == "if" )
|
||||
else if ( e.name == "if" || e.name == "ifnot" )
|
||||
{
|
||||
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 );
|
||||
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 );
|
||||
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 == "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 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
|
||||
|
||||
parseContext.ifData = pOldIf;
|
||||
}
|
||||
|
||||
Module*
|
||||
|
|
|
@ -83,7 +83,6 @@ class Invoke;
|
|||
class InvokeFile;
|
||||
class Dependency;
|
||||
class ImportLibrary;
|
||||
class If;
|
||||
class CompilerFlag;
|
||||
class LinkerFlag;
|
||||
class LinkerScript;
|
||||
|
@ -198,7 +197,6 @@ public:
|
|||
class ParseContext
|
||||
{
|
||||
public:
|
||||
If* ifData;
|
||||
CompilationUnit* compilationUnit;
|
||||
ParseContext ();
|
||||
};
|
||||
|
@ -215,7 +213,6 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
};
|
||||
|
||||
|
||||
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:
|
||||
|
|
|
@ -312,27 +312,6 @@ TestSupportCode::GetSourceFilenames ( string_list& list,
|
|||
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*
|
||||
|
|
Loading…
Reference in a new issue