bugfixes to new <if> and related code

svn path=/branches/xmlbuildsystem/; revision=13016
This commit is contained in:
Royce Mitchell III 2005-01-13 03:43:10 +00:00
parent c869f797fb
commit 84c57ede37
8 changed files with 133 additions and 107 deletions

View file

@ -8,11 +8,13 @@
</xi:include> </xi:include>
<define name="_M_IX86" /> <define name="_M_IX86" />
<if property="dbg" value="true"> <if property="DBG" value="1">
<define name="dbg_or_kdbg" value="true" /> <define name="DBG" value="1" />
<property name="DBG_OR_KDBG" value="true" />
</if> </if>
<if property="kdbg" value="true"> <if property="KDBG" value="1">
<define name="dbg_or_kdbg" value="true" /> <define name="KDBG" value="1" />
<property name="DBG_OR_KDBG" value="true" />
</if> </if>
<include>include</include> <include>include</include>

View file

@ -59,39 +59,79 @@ MingwBackend::GenerateHeader ()
fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" ); fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
} }
string void
MingwBackend::GenerateProjectCFLAGS () MingwBackend::GenerateGlobalCFlagsAndProperties (
const char* op,
const vector<Property*>& properties,
const vector<Include*>& includes,
const vector<Define*>& defines,
const vector<If*>& ifs )
{ {
size_t i; size_t i;
string clags;
for ( i = 0; i < ProjectNode.includes.size (); i++ ) for ( i = 0; i < properties.size(); i++ )
{ {
Include& include = *ProjectNode.includes[i]; Property& prop = *properties[i];
if (clags.length () > 0) fprintf ( fMakefile, "%s := %s\n",
clags += " "; prop.name.c_str(),
clags += "-I" + include.directory; prop.value.c_str() );
} }
for ( i = 0; i < ProjectNode.defines.size (); i++ ) if ( includes.size() || defines.size() )
{ {
Define& define = *ProjectNode.defines[i]; fprintf (
if ( clags.length () > 0 ) fMakefile,
clags += " "; "PROJECT_CFLAGS %s",
clags += "-D" + define.name; op );
if ( define.value.size() > 0 ) for ( i = 0; i < includes.size(); i++ )
{ {
clags += "="; fprintf (
clags += define.value; fMakefile,
" -I%s",
includes[i]->directory.c_str() );
}
for ( i = 0; i < defines.size(); i++ )
{
Define& d = *defines[i];
fprintf (
fMakefile,
" -D%s",
d.name.c_str() );
if ( d.value.size() )
fprintf (
fMakefile,
"=%s",
d.value.c_str() );
}
fprintf ( fMakefile, "\n" );
}
for ( i = 0; i < ifs.size(); i++ )
{
If& rIf = *ifs[i];
if ( rIf.defines.size() || rIf.includes.size() || rIf.ifs.size() )
{
fprintf (
fMakefile,
"ifeq (\"$(%s)\",\"%s\")\n",
rIf.property.c_str(),
rIf.value.c_str() );
GenerateGlobalCFlagsAndProperties (
"+=",
rIf.properties,
rIf.includes,
rIf.defines,
rIf.ifs );
fprintf (
fMakefile,
"endif\n\n" );
} }
} }
return clags;
} }
void void
MingwBackend::GenerateGlobalVariables () MingwBackend::GenerateGlobalVariables ()
{ {
size_t i;
fprintf ( fMakefile, "host_gcc = gcc\n" ); fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_ar = ar\n" ); fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_ld = ld\n" ); fprintf ( fMakefile, "host_ld = ld\n" );
@ -99,15 +139,13 @@ MingwBackend::GenerateGlobalVariables ()
fprintf ( fMakefile, "gcc = gcc\n" ); fprintf ( fMakefile, "gcc = gcc\n" );
fprintf ( fMakefile, "ld = ld\n" ); fprintf ( fMakefile, "ld = ld\n" );
fprintf ( fMakefile, "ar = ar\n" ); fprintf ( fMakefile, "ar = ar\n" );
fprintf ( fMakefile, "dlltool = dlltool\n" ); fprintf ( fMakefile, "dlltool = dlltool\n\n" );
fprintf ( fMakefile, "PROJECT_CFLAGS = %s\n", GenerateProjectCFLAGS ().c_str () ); GenerateGlobalCFlagsAndProperties (
for ( i = 0; i < ProjectNode.properties.size(); i++ ) "=",
{ ProjectNode.properties,
Property& prop = *ProjectNode.properties[i]; ProjectNode.includes,
fprintf ( fMakefile, "%s := %s\n", ProjectNode.defines,
prop.name.c_str(), ProjectNode.ifs );
prop.value.c_str() );
}
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }

View file

@ -14,7 +14,13 @@ private:
void CreateMakefile (); void CreateMakefile ();
void CloseMakefile (); void CloseMakefile ();
void GenerateHeader (); void GenerateHeader ();
std::string GenerateProjectCFLAGS (); void
MingwBackend::GenerateGlobalCFlagsAndProperties (
const char* op,
const std::vector<Property*>& properties,
const std::vector<Include*>& includes,
const std::vector<Define*>& defines,
const std::vector<If*>& ifs );
void GenerateGlobalVariables (); void GenerateGlobalVariables ();
void GenerateAllTarget (); void GenerateAllTarget ();
FILE* fMakefile; FILE* fMakefile;

View file

@ -262,34 +262,34 @@ MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
void void
MingwModuleHandler::GenerateMacros ( MingwModuleHandler::GenerateMacros (
const Module& module,
const char* op, const char* op,
const vector<File*>& files, const vector<File*>& files,
const vector<Include*>* includes, const vector<Include*>& includes,
const vector<Define*>& defines, const vector<Define*>& defines,
const vector<If*>* ifs, const vector<If*>& ifs,
const string& cflags_macro, const string& cflags_macro,
const string& nasmflags_macro, const string& nasmflags_macro,
const string& objs_macro) const const string& objs_macro) const
{ {
size_t i; size_t i;
if ( (includes && includes->size()) || defines.size() ) if ( includes.size() || defines.size() )
{ {
fprintf ( fprintf (
fMakefile, fMakefile,
"%s %s", "%s %s",
cflags_macro.c_str(), cflags_macro.c_str(),
op ); op );
if ( includes ) for ( i = 0; i < includes.size(); i++ )
for ( i = 0; i < includes->size(); i++ ) {
fprintf ( fprintf (
fMakefile, fMakefile,
" -I%s", " -I%s",
(*includes)[i]->directory.c_str() ); includes[i]->directory.c_str() );
for ( i = 0; i < module.defines.size(); i++ ) }
for ( i = 0; i < defines.size(); i++ )
{ {
Define& d = *module.defines[i]; Define& d = *defines[i];
fprintf ( fprintf (
fMakefile, fMakefile,
" -D%s", " -D%s",
@ -321,12 +321,10 @@ MingwModuleHandler::GenerateMacros (
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
if ( ifs && ifs->size() ) for ( i = 0; i < ifs.size(); i++ )
{ {
for ( size_t i = 0; i < ifs->size(); i++ ) If& rIf = *ifs[i];
{ if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() )
If& rIf = *(*ifs)[i];
if ( rIf.defines.size() || rIf.files.size() || rIf.ifs.size() )
{ {
fprintf ( fprintf (
fMakefile, fMakefile,
@ -334,12 +332,11 @@ MingwModuleHandler::GenerateMacros (
rIf.property.c_str(), rIf.property.c_str(),
rIf.value.c_str() ); rIf.value.c_str() );
GenerateMacros ( GenerateMacros (
module,
"+=", "+=",
rIf.files, rIf.files,
NULL, rIf.includes,
rIf.defines, rIf.defines,
&rIf.ifs, rIf.ifs,
cflags_macro, cflags_macro,
nasmflags_macro, nasmflags_macro,
objs_macro ); objs_macro );
@ -348,7 +345,6 @@ MingwModuleHandler::GenerateMacros (
"endif\n\n" ); "endif\n\n" );
} }
} }
}
} }
void void
@ -359,42 +355,16 @@ MingwModuleHandler::GenerateMacros (
const string& objs_macro) const const string& objs_macro) const
{ {
GenerateMacros ( GenerateMacros (
module,
"=", "=",
module.files, module.files,
&module.includes, module.includes,
module.defines, module.defines,
NULL, module.ifs,
cflags_macro, cflags_macro,
nasmflags_macro, nasmflags_macro,
objs_macro ); objs_macro );
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
for ( size_t i = 0; i < module.ifs.size(); i++ )
{
If& rIf = *module.ifs[i];
if ( rIf.defines.size() || rIf.files.size() || rIf.ifs.size() )
{
fprintf (
fMakefile,
"ifeq (\"$(%s)\",\"%s\")\n",
rIf.property.c_str(),
rIf.value.c_str() );
GenerateMacros (
module,
"+=",
rIf.files,
NULL,
rIf.defines,
&rIf.ifs,
cflags_macro,
nasmflags_macro,
objs_macro );
fprintf (
fMakefile,
"endif\n\n" );
}
}
fprintf ( fprintf (
fMakefile, fMakefile,
"%s += $(PROJECT_CFLAGS)\n\n", "%s += $(PROJECT_CFLAGS)\n\n",

View file

@ -46,12 +46,11 @@ private:
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const; std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
std::string GenerateGccDefineParameters ( const Module& module ) const; std::string GenerateGccDefineParameters ( const Module& module ) const;
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const; std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
void GenerateMacros ( const Module& module, void GenerateMacros ( const char* op,
const char* op,
const std::vector<File*>& files, const std::vector<File*>& files,
const std::vector<Include*>* includes, const std::vector<Include*>& includes,
const std::vector<Define*>& defines, const std::vector<Define*>& defines,
const std::vector<If*>* ifs, const std::vector<If*>& ifs,
const std::string& cflags_macro, const std::string& cflags_macro,
const std::string& nasmflags_macro, const std::string& nasmflags_macro,
const std::string& objs_macro) const; const std::string& objs_macro) const;

View file

@ -122,11 +122,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
} }
else if ( e.name == "include" ) else if ( e.name == "include" )
{ {
Include* include = new Include ( project, this, e );
if ( pIf ) if ( pIf )
throw InvalidBuildFileException ( pIf->includes.push_back ( include );
e.location, else
"<include> is not a valid sub-element of <if>" ); includes.push_back ( include );
includes.push_back ( new Include ( project, this, e ) );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "define" ) else if ( e.name == "define" )
@ -513,6 +513,8 @@ If::~If ()
size_t i; size_t i;
for ( i = 0; i < files.size(); i++ ) for ( i = 0; i < files.size(); i++ )
delete files[i]; delete files[i];
for ( i = 0; i < includes.size(); i++ )
delete includes[i];
for ( i = 0; i < defines.size(); i++ ) for ( i = 0; i < defines.size(); i++ )
delete defines[i]; delete defines[i];
for ( i = 0; i < ifs.size(); i++ ) for ( i = 0; i < ifs.size(); i++ )

View file

@ -96,6 +96,10 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
string subpath(path); string subpath(path);
if ( e.name == "module" ) if ( e.name == "module" )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<module> is not a valid sub-element of <if>" );
Module* module = new Module ( *this, e, path ); Module* module = new Module ( *this, e, path );
if ( LocateModule ( module->name ) ) if ( LocateModule ( module->name ) )
throw InvalidBuildFileException ( throw InvalidBuildFileException (
@ -114,7 +118,11 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
} }
else if ( e.name == "include" ) else if ( e.name == "include" )
{ {
includes.push_back ( new Include ( *this, e ) ); Include* include = new Include ( *this, e );
if ( pIf )
pIf->includes.push_back ( include );
else
includes.push_back ( include );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "define" ) else if ( e.name == "define" )

View file

@ -256,6 +256,7 @@ public:
const Module* module; const Module* module;
std::string property, value; std::string property, value;
std::vector<File*> files; std::vector<File*> files;
std::vector<Include*> includes;
std::vector<Define*> defines; std::vector<Define*> defines;
std::vector<Property*> properties; std::vector<Property*> properties;
std::vector<If*> ifs; std::vector<If*> ifs;