6d8a484067467fcecc3333c6bc34b130b79dcfc8
11 : node(NULL), head(NULL)
15 Project::Project ( const string
& filename
)
26 for ( i
= 0; i
< modules
.size (); i
++ )
28 for ( i
= 0; i
< includes
.size(); i
++ )
30 for ( i
= 0; i
< defines
.size(); i
++ )
32 for ( i
= 0; i
< linkerFlags
.size(); i
++ )
33 delete linkerFlags
[i
];
34 for ( i
= 0; i
< properties
.size(); i
++ )
36 for ( i
= 0; i
< ifs
.size(); i
++ )
45 head
= XMLLoadFile ( xmlfile
, path
);
47 for ( size_t i
= 0; i
< head
->subElements
.size(); i
++ )
49 if ( head
->subElements
[i
]->name
== "project" )
51 node
= head
->subElements
[i
];
52 this->ProcessXML ( "." );
57 throw InvalidBuildFileException (
59 "Document contains no 'project' tag." );
63 Project::ProcessXML ( const string
& path
)
65 const XMLAttribute
*att
;
66 if ( node
->name
!= "project" )
67 throw Exception ( "internal tool error: Project::ProcessXML() called with non-<project> node" );
69 att
= node
->GetAttribute ( "name", false );
75 att
= node
->GetAttribute ( "makefile", true );
77 makefile
= att
->value
;
80 for ( i
= 0; i
< node
->subElements
.size(); i
++ )
81 ProcessXMLSubElement ( *node
->subElements
[i
], path
);
82 for ( i
= 0; i
< modules
.size(); i
++ )
83 modules
[i
]->ProcessXML();
84 for ( i
= 0; i
< includes
.size(); i
++ )
85 includes
[i
]->ProcessXML();
86 for ( i
= 0; i
< defines
.size(); i
++ )
87 defines
[i
]->ProcessXML();
88 for ( i
= 0; i
< linkerFlags
.size(); i
++ )
89 linkerFlags
[i
]->ProcessXML();
90 for ( i
= 0; i
< properties
.size(); i
++ )
91 properties
[i
]->ProcessXML();
92 for ( i
= 0; i
< ifs
.size(); i
++ )
97 Project::ProcessXMLSubElement ( const XMLElement
& e
,
101 bool subs_invalid
= false;
102 string
subpath(path
);
103 if ( e
.name
== "module" )
106 throw InvalidBuildFileException (
108 "<module> is not a valid sub-element of <if>" );
109 Module
* module
= new Module ( *this, e
, path
);
110 if ( LocateModule ( module
->name
) )
111 throw InvalidBuildFileException (
113 "module name conflict: '%s' (originally defined at %s)",
114 module
->name
.c_str(),
115 module
->node
.location
.c_str() );
116 modules
.push_back ( module
);
117 return; // defer processing until later
119 else if ( e
.name
== "directory" )
121 const XMLAttribute
* att
= e
.GetAttribute ( "name", true );
123 subpath
= path
+ CSEP
+ att
->value
;
125 else if ( e
.name
== "include" )
127 Include
* include
= new Include ( *this, e
);
129 pIf
->includes
.push_back ( include
);
131 includes
.push_back ( include
);
134 else if ( e
.name
== "define" )
136 Define
* define
= new Define ( *this, e
);
138 pIf
->defines
.push_back ( define
);
140 defines
.push_back ( define
);
143 else if ( e
.name
== "linkerflag" )
145 linkerFlags
.push_back ( new LinkerFlag ( *this, e
) );
148 else if ( e
.name
== "if" )
151 pIf
= new If ( e
, *this, NULL
);
153 pOldIf
->ifs
.push_back ( pIf
);
155 ifs
.push_back ( pIf
);
156 subs_invalid
= false;
158 else if ( e
.name
== "property" )
160 Property
* property
= new Property ( e
, *this, NULL
);
162 pIf
->properties
.push_back ( property
);
164 properties
.push_back ( property
);
166 if ( subs_invalid
&& e
.subElements
.size() )
167 throw InvalidBuildFileException (
169 "<%s> cannot have sub-elements",
171 for ( size_t i
= 0; i
< e
.subElements
.size (); i
++ )
172 ProcessXMLSubElement ( *e
.subElements
[i
], subpath
, pIf
);
176 Project::LocateModule ( const string
& name
)
178 for ( size_t i
= 0; i
< modules
.size (); i
++ )
180 if (modules
[i
]->name
== name
)
188 Project::LocateModule ( const string
& name
) const
190 for ( size_t i
= 0; i
< modules
.size (); i
++ )
192 if (modules
[i
]->name
== name
)