mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Support compilerflag within IFs
svn path=/branches/xmlbuildsystem/; revision=15267
This commit is contained in:
parent
92bdf77b07
commit
d32ad9196b
12 changed files with 88 additions and 42 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id:$
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
|
|
@ -393,6 +393,15 @@ MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation,
|
|||
fMakefile,
|
||||
"PROJECT_CFLAGS %s",
|
||||
assignmentOperation );
|
||||
|
||||
for ( i = 0; i < data.compilerFlags.size(); i++ )
|
||||
{
|
||||
fprintf (
|
||||
fMakefile,
|
||||
" %s",
|
||||
data.compilerFlags[i]->flag.c_str() );
|
||||
}
|
||||
|
||||
for ( i = 0; i < data.includes.size(); i++ )
|
||||
{
|
||||
fprintf (
|
||||
|
@ -432,7 +441,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
|
|||
prop.value.c_str() );
|
||||
}
|
||||
|
||||
if ( data.includes.size() || data.defines.size() )
|
||||
if ( data.includes.size() || data.defines.size() || data.compilerFlags.size() )
|
||||
{
|
||||
GenerateProjectCFlagsMacro ( assignmentOperation,
|
||||
data );
|
||||
|
@ -443,6 +452,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
|
|||
If& rIf = *data.ifs[i];
|
||||
if ( rIf.data.defines.size()
|
||||
|| rIf.data.includes.size()
|
||||
|| rIf.data.compilerFlags.size()
|
||||
|| rIf.data.ifs.size() )
|
||||
{
|
||||
fprintf (
|
||||
|
|
|
@ -562,7 +562,6 @@ MingwModuleHandler::GenerateGccIncludeParameters () const
|
|||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
|
||||
{
|
||||
|
@ -618,8 +617,7 @@ void
|
|||
MingwModuleHandler::GenerateMacro (
|
||||
const char* assignmentOperation,
|
||||
const string& macro,
|
||||
const IfableData& data,
|
||||
const vector<CompilerFlag*>* compilerFlags )
|
||||
const IfableData& data )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -629,16 +627,13 @@ MingwModuleHandler::GenerateMacro (
|
|||
macro.c_str(),
|
||||
assignmentOperation );
|
||||
|
||||
if ( compilerFlags != NULL )
|
||||
string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags );
|
||||
if ( compilerParameters.size () > 0 )
|
||||
{
|
||||
string compilerParameters = GenerateCompilerParametersFromVector ( *compilerFlags );
|
||||
if ( compilerParameters.size () > 0 )
|
||||
{
|
||||
fprintf (
|
||||
fMakefile,
|
||||
" %s",
|
||||
compilerParameters.c_str () );
|
||||
}
|
||||
fprintf (
|
||||
fMakefile,
|
||||
" %s",
|
||||
compilerParameters.c_str () );
|
||||
}
|
||||
|
||||
for ( i = 0; i < data.includes.size(); i++ )
|
||||
|
@ -668,21 +663,18 @@ void
|
|||
MingwModuleHandler::GenerateMacros (
|
||||
const char* assignmentOperation,
|
||||
const IfableData& data,
|
||||
const vector<CompilerFlag*>* compilerFlags,
|
||||
const vector<LinkerFlag*>* linkerFlags )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if ( data.includes.size () > 0 || data.defines.size () > 0 )
|
||||
if ( data.includes.size () > 0 || data.defines.size () > 0 || data.compilerFlags.size () > 0 )
|
||||
{
|
||||
GenerateMacro ( assignmentOperation,
|
||||
cflagsMacro,
|
||||
data,
|
||||
compilerFlags );
|
||||
data );
|
||||
GenerateMacro ( assignmentOperation,
|
||||
windresflagsMacro,
|
||||
data,
|
||||
compilerFlags );
|
||||
data );
|
||||
}
|
||||
|
||||
if ( linkerFlags != NULL )
|
||||
|
@ -721,6 +713,7 @@ MingwModuleHandler::GenerateMacros (
|
|||
|| rIf.data.includes.size()
|
||||
|| rIf.data.libraries.size()
|
||||
|| rIf.data.files.size()
|
||||
|| rIf.data.compilerFlags.size()
|
||||
|| rIf.data.ifs.size() )
|
||||
{
|
||||
fprintf (
|
||||
|
@ -731,7 +724,6 @@ MingwModuleHandler::GenerateMacros (
|
|||
GenerateMacros (
|
||||
"+=",
|
||||
rIf.data,
|
||||
NULL,
|
||||
NULL );
|
||||
fprintf (
|
||||
fMakefile,
|
||||
|
@ -744,7 +736,6 @@ void
|
|||
MingwModuleHandler::GenerateObjectMacros (
|
||||
const char* assignmentOperation,
|
||||
const IfableData& data,
|
||||
const vector<CompilerFlag*>* compilerFlags,
|
||||
const vector<LinkerFlag*>* linkerFlags )
|
||||
{
|
||||
size_t i;
|
||||
|
@ -794,6 +785,7 @@ MingwModuleHandler::GenerateObjectMacros (
|
|||
|| rIf.data.includes.size()
|
||||
|| rIf.data.libraries.size()
|
||||
|| rIf.data.files.size()
|
||||
|| rIf.data.compilerFlags.size()
|
||||
|| rIf.data.ifs.size() )
|
||||
{
|
||||
fprintf (
|
||||
|
@ -804,7 +796,6 @@ MingwModuleHandler::GenerateObjectMacros (
|
|||
GenerateObjectMacros (
|
||||
"+=",
|
||||
rIf.data,
|
||||
NULL,
|
||||
NULL );
|
||||
fprintf (
|
||||
fMakefile,
|
||||
|
@ -1531,7 +1522,6 @@ MingwModuleHandler::GenerateObjectMacro ()
|
|||
GenerateObjectMacros (
|
||||
"=",
|
||||
module.non_if_data,
|
||||
&module.compilerFlags,
|
||||
&module.linkerFlags );
|
||||
|
||||
// future references to the macro will be to get its values
|
||||
|
@ -1561,7 +1551,6 @@ MingwModuleHandler::GenerateOtherMacros ()
|
|||
GenerateMacros (
|
||||
"=",
|
||||
module.non_if_data,
|
||||
&module.compilerFlags,
|
||||
&module.linkerFlags );
|
||||
|
||||
if ( module.importLibrary )
|
||||
|
|
|
@ -109,15 +109,12 @@ private:
|
|||
std::string GenerateLinkerParameters () const;
|
||||
void GenerateMacro ( const char* assignmentOperation,
|
||||
const std::string& macro,
|
||||
const IfableData& data,
|
||||
const std::vector<CompilerFlag*>* compilerFlags );
|
||||
const IfableData& data );
|
||||
void GenerateMacros ( const char* op,
|
||||
const IfableData& data,
|
||||
const std::vector<CompilerFlag*>* compilerFlags,
|
||||
const std::vector<LinkerFlag*>* linkerFlags );
|
||||
void GenerateObjectMacros ( const char* assignmentOperation,
|
||||
const IfableData& data,
|
||||
const std::vector<CompilerFlag*>* compilerFlags,
|
||||
const std::vector<LinkerFlag*>* linkerFlags );
|
||||
std::string GenerateGccIncludeParameters () const;
|
||||
std::string GenerateGccParameters () const;
|
||||
|
|
|
@ -31,11 +31,6 @@ CompilerFlag::~CompilerFlag ()
|
|||
|
||||
void
|
||||
CompilerFlag::Initialize ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CompilerFlag::ProcessXML ()
|
||||
{
|
||||
if (node.value.size () == 0)
|
||||
{
|
||||
|
@ -45,3 +40,8 @@ CompilerFlag::ProcessXML ()
|
|||
}
|
||||
flag = node.value;
|
||||
}
|
||||
|
||||
void
|
||||
CompilerFlag::ProcessXML ()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ IfableData::~IfableData()
|
|||
delete libraries[i];
|
||||
for ( i = 0; i < properties.size(); i++ )
|
||||
delete properties[i];
|
||||
for ( i = 0; i < compilerFlags.size(); i++ )
|
||||
delete compilerFlags[i];
|
||||
for ( i = 0; i < ifs.size(); i++ )
|
||||
delete ifs[i];
|
||||
}
|
||||
|
@ -117,6 +119,8 @@ void IfableData::ProcessXML ()
|
|||
libraries[i]->ProcessXML ();
|
||||
for ( i = 0; i < properties.size(); i++ )
|
||||
properties[i]->ProcessXML ();
|
||||
for ( i = 0; i < compilerFlags.size(); i++ )
|
||||
compilerFlags[i]->ProcessXML ();
|
||||
for ( i = 0; i < ifs.size (); i++ )
|
||||
ifs[i]->ProcessXML ();
|
||||
}
|
||||
|
@ -390,7 +394,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
else if ( e.name == "compilerflag" )
|
||||
{
|
||||
compilerFlags.push_back ( new CompilerFlag ( project, this, e ) );
|
||||
CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
|
||||
if ( pIf )
|
||||
pIf->data.compilerFlags.push_back ( pCompilerFlag );
|
||||
else
|
||||
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
||||
subs_invalid = true;
|
||||
}
|
||||
else if ( e.name == "linkerflag" )
|
||||
|
|
|
@ -285,6 +285,15 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
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 );
|
||||
else
|
||||
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
||||
subs_invalid = true;
|
||||
}
|
||||
else if ( e.name == "linkerflag" )
|
||||
{
|
||||
linkerFlags.push_back ( new LinkerFlag ( *this, e ) );
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
std::vector<Define*> defines;
|
||||
std::vector<Library*> libraries;
|
||||
std::vector<Property*> properties;
|
||||
std::vector<CompilerFlag*> compilerFlags;
|
||||
std::vector<If*> ifs;
|
||||
|
||||
~IfableData();
|
||||
|
|
|
@ -310,7 +310,7 @@ Value:
|
|||
None.
|
||||
|
||||
Elements:
|
||||
define, directory, file, if, include, property.
|
||||
compilerflag, define, directory, file, if, include, property.
|
||||
|
||||
|
||||
Importlibrary element
|
||||
|
|
|
@ -97,6 +97,9 @@ class IfTest : public BaseTest
|
|||
{
|
||||
public:
|
||||
void Run ();
|
||||
private:
|
||||
void TestProjectIf ( Project& project );
|
||||
void TestModuleIf ( Project& project );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" ?>
|
||||
<project name="Project" makefile="Makefile">
|
||||
<if property="VAR1" value="value1">
|
||||
<compilerflag>compilerflag1</compilerflag>
|
||||
</if>
|
||||
<module name="module1" type="buildtool">
|
||||
<if property="VAR1" value="value1">
|
||||
<if property="VAR2" value="value2">
|
||||
<compilerflag>compilerflag2</compilerflag>
|
||||
<file>file1.c</file>
|
||||
</if>
|
||||
<file>file2.c</file>
|
||||
|
|
|
@ -2,18 +2,29 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
void IfTest::Run()
|
||||
void
|
||||
IfTest::TestProjectIf ( Project& project )
|
||||
{
|
||||
string projectFilename ( RBUILD_BASE "tests/data/if.xml" );
|
||||
Project project ( projectFilename );
|
||||
ARE_EQUAL ( 1, project.non_if_data.ifs.size () );
|
||||
If& if1 = *project.non_if_data.ifs[0];
|
||||
ARE_EQUAL ( "VAR1", if1.property );
|
||||
ARE_EQUAL ( "value1", if1.value );
|
||||
|
||||
ARE_EQUAL ( 1, if1.data.compilerFlags.size () );
|
||||
CompilerFlag& compilerFlag1 = *if1.data.compilerFlags[0];
|
||||
ARE_EQUAL( "compilerflag1", compilerFlag1.flag );
|
||||
}
|
||||
|
||||
void
|
||||
IfTest::TestModuleIf ( Project& project )
|
||||
{
|
||||
ARE_EQUAL ( 1, project.modules.size () );
|
||||
Module& module1 = *project.modules[0];
|
||||
|
||||
ARE_EQUAL ( 1, module1.non_if_data.ifs.size () );
|
||||
If& if1 = *module1.non_if_data.ifs[0];
|
||||
ARE_EQUAL ( "VAR1", if1.property );
|
||||
ARE_EQUAL ( "value1", if1.value );
|
||||
ARE_EQUAL ( "VAR2", if1.property );
|
||||
ARE_EQUAL ( "value2", if1.value );
|
||||
|
||||
ARE_EQUAL ( 1, if1.data.files.size () );
|
||||
File& file1 = *if1.data.files[0];
|
||||
|
@ -22,4 +33,18 @@ void IfTest::Run()
|
|||
ARE_EQUAL ( 1, module1.non_if_data.files.size () );
|
||||
File& file2 = *module1.non_if_data.files[0];
|
||||
ARE_EQUAL( SSEP "file2.c", file2.name );
|
||||
|
||||
ARE_EQUAL ( 1, if1.data.compilerFlags.size () );
|
||||
CompilerFlag& compilerFlag2 = *if1.data.compilerFlags[0];
|
||||
ARE_EQUAL( "compilerflag2", compilerFlag2.flag );
|
||||
}
|
||||
|
||||
void
|
||||
IfTest::Run ()
|
||||
{
|
||||
string projectFilename ( RBUILD_BASE "tests/data/if.xml" );
|
||||
Project project ( projectFilename );
|
||||
|
||||
TestProjectIf ( project );
|
||||
TestModuleIf ( project );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue