Parse module type.
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp
2005-01-05 21:29:54 UTC (rev 12839)
@@ -63,5 +63,13 @@
attributeName.c_str (),
elementName.c_str ())
{
+}
+
+InvalidAttributeValueException::InvalidAttributeValueException(const
std::string& name,
+ const
std::string& value)
+ : InvalidBuildFileException ( "Attribute '%s' has an invalid
value '%s'.",
+ name.c_str (),
+ value.c_str ())
+{
}
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
2005-01-05 21:29:54 UTC (rev 12839)
@@ -48,4 +48,12 @@
const std::string&
elementName);
};
+
+class InvalidAttributeValueException : public InvalidBuildFileException
+{
+public:
+ InvalidAttributeValueException(const std::string& name,
+ const std::string& value);
+};
+
#endif /* __EXCEPTION_H */
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-05 21:29:54 UTC (rev 12839)
@@ -14,35 +14,43 @@
name(moduleName),
path(modulePath)
{
+ type = GetModuleType ( *moduleNode.GetAttribute ( "type", true )
);
}
-Module::~Module()
+Module::~Module ()
{
for ( size_t i = 0; i < files.size(); i++ )
delete files[i];
}
-void
-Module::ProcessXML ( const XMLElement& e, const string& path )
+void Module::ProcessXML ( const XMLElement& e,
+ const string& path )
{
string subpath ( path );
- if ( e.name == "file" && e.value.size() )
+ if ( e.name == "file" && e.value.size () )
{
- files.push_back ( new File(path + "/" + e.value) );
+ files.push_back ( new File ( path + "/" + e.value ) );
}
else if ( e.name == "directory" )
{
- // this code is duplicated between Project::ProcessXML()
and Module::ProcessXML() :(
const XMLAttribute* att = e.GetAttribute ( "name", true
);
- if ( !att )
- return;
subpath = path + "/" + att->value;
}
- for ( size_t i = 0; i < e.subElements.size(); i++ )
+ for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXML ( *e.subElements[i], subpath );
}
-File::File ( const std::string& _name )
+ModuleType Module::GetModuleType ( const XMLAttribute& attribute )
+{
+ if ( attribute.value == "buildtool" )
+ return BuildTool;
+ if ( attribute.value == "kernelmodedll" )
+ return KernelModeDLL;
+ throw InvalidAttributeValueException ( attribute.name,
+ attribute.value );
+}
+
+File::File ( const string& _name )
: name(_name)
{
}
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-05 21:29:54 UTC (rev 12839)
@@ -30,6 +30,12 @@
};
+enum ModuleType
+{
+ BuildTool,
+ KernelModeDLL
+};
+
class Module
{
public:
@@ -37,10 +43,12 @@
std::string name;
std::string path;
std::vector<File*> files;
+ ModuleType type;
Module ( const XMLElement& moduleNode,
const std::string& moduleName,
const std::string& modulePath );
+ ModuleType GetModuleType (const XMLAttribute& attribute );
~Module();
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/module.xml
2005-01-05 21:29:54 UTC (rev 12839)
@@ -6,7 +6,7 @@
</module>
</directory>
<directory name="dir2">
- <module name="module2" type="buildtool">
+ <module name="module2" type="kernelmodedll">
<file>file3.c</file>
<file>file4.c</file>
</module>
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
2005-01-05 21:00:51 UTC (rev 12838)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
2005-01-05 21:29:54 UTC (rev 12839)
@@ -9,11 +9,13 @@
ARE_EQUAL(2, project.modules.size());
Module& module1 = *project.modules[0];
+ IS_TRUE(module1.type == BuildTool);
ARE_EQUAL(2, module1.files.size());
ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
Module& module2 = *project.modules[1];
+ IS_TRUE(module2.type == KernelModeDLL);
ARE_EQUAL(2, module2.files.size());
ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
Show replies by date