<include> now has attribute 'base' which allows to specify subdirectory of another...
authorRoyce Mitchell III <royce3@ev1.net>
Sat, 8 Jan 2005 04:33:01 +0000 (04:33 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Sat, 8 Jan 2005 04:33:01 +0000 (04:33 +0000)
svn path=/branches/xmlbuildsystem/; revision=12880

reactos/ReactOS.xml
reactos/lib/kjs/module.xml
reactos/ntoskrnl/module.xml
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/include.cpp
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/tests/data/include.xml
reactos/tools/rbuild/tests/includetest.cpp

index ec6e3f6..0b9a21b 100644 (file)
@@ -1,4 +1,6 @@
-<project name="ReactOS" makefile="Makefile.auto">\r
+<?xml version="1.0"?>\r
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">\r
+<project name="ReactOS" makefile="Makefile.auto" xmlns:xi="http://www.w3.org/2001/XInclude">\r
        <define name="_M_IX86"></define>\r
        <include>include</include>\r
        <include>w32api/include</include>\r
index d0934a6..9c4903f 100644 (file)
@@ -1,7 +1,7 @@
 <module name="kjs" type="staticlibrary">\r
-       <include>.</include>\r
-       <include>src</include>\r
-       <include>include</include>\r
+       <include base="kjs">.</include>\r
+       <include base="kjs">src</include>\r
+       <include base="kjs">include</include>\r
        <directory name="ksrc">\r
                <file>setjmp.S</file>\r
                <file>longjmp.S</file>\r
index d1b6a90..7f9fe3b 100644 (file)
@@ -4,8 +4,7 @@
        <define name="__NTOSKRNL__" />\r
        <define name="__3GB__" />\r
        <include>.</include>\r
-       <include>./include</include>\r
-       <include>../lib/kjs/include</include>\r
+       <include base="kjs">./include</include>\r
        <library>kjs</library>\r
        <directory name="cc">\r
                <file>cacheman.c</file>\r
index e3fadca..d0832dd 100644 (file)
@@ -140,8 +140,7 @@ MingwModuleHandler::ConcatenatePaths ( const string& path1,
 }\r
 \r
 string\r
-MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const string& basePath,\r
-                                                                const vector<Include*>& includes ) const\r
+MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Include*>& includes ) const\r
 {\r
        string parameters;\r
        for (size_t i = 0; i < includes.size (); i++)\r
@@ -149,9 +148,7 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const string& baseP
                Include& include = *includes[i];\r
                if (parameters.length () > 0)\r
                        parameters += " ";\r
-               parameters += "-I";\r
-               parameters += ConcatenatePaths ( basePath,\r
-                                                include.directory );\r
+               parameters += "-I" + include.directory;\r
        }\r
        return parameters;\r
 }\r
@@ -159,10 +156,8 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const string& baseP
 string\r
 MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const\r
 {\r
-       string parameters = GenerateGccIncludeParametersFromVector ( ".",\r
-                                                                    module.project.includes );\r
-       string s = GenerateGccIncludeParametersFromVector ( module.path,\r
-                                                           module.includes );\r
+       string parameters = GenerateGccIncludeParametersFromVector ( module.project.includes );\r
+       string s = GenerateGccIncludeParametersFromVector ( module.includes );\r
        if (s.length () > 0)\r
        {\r
                parameters += " ";\r
index b728cfb..a1a7096 100644 (file)
@@ -26,8 +26,7 @@ private:
                                       const std::string& path2 ) const;\r
        std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;\r
        std::string GenerateGccDefineParameters ( const Module& module ) const;\r
-       std::string GenerateGccIncludeParametersFromVector ( const std::string& basePath,\r
-                                                            const std::vector<Include*>& includes ) const;\r
+       std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;\r
        std::string GenerateGccIncludeParameters ( const Module& module ) const;\r
        std::string GenerateGccParameters ( const Module& module ) const;\r
 };\r
index b8d7134..3e80ec3 100644 (file)
@@ -10,7 +10,8 @@ Include::Include ( const Project& project_,
                    const XMLElement& includeNode )\r
        : project(project_),\r
          module(NULL),\r
-         node(includeNode)\r
+         node(includeNode),\r
+         base(NULL)\r
 {\r
        Initialize();\r
 }\r
@@ -20,7 +21,8 @@ Include::Include ( const Project& project_,
                       const XMLElement& includeNode )\r
        : project(project_),\r
          module(module_),\r
-         node(includeNode)\r
+         node(includeNode),\r
+         base(NULL)\r
 {\r
        Initialize();\r
 }\r
@@ -32,10 +34,27 @@ Include::~Include ()
 void\r
 Include::Initialize()\r
 {\r
-       directory = FixSeparator ( node.value );\r
 }\r
 \r
 void\r
 Include::ProcessXML()\r
 {\r
+       const XMLAttribute* att;\r
+       att = node.GetAttribute("base",false);\r
+       if ( att )\r
+       {\r
+               if ( !module )\r
+                       throw InvalidBuildFileException (\r
+                               node.location,\r
+                               "'base' attribute illegal from global <include>" );\r
+               base = project.LocateModule ( att->value );\r
+               if ( !base )\r
+                       throw InvalidBuildFileException (\r
+                               node.location,\r
+                               "<include> attribute 'base' references non-existant module '%s'",\r
+                               att->value.c_str() );\r
+               directory = FixSeparator ( base->GetBasePath() + "/" + node.value );\r
+       }\r
+       else\r
+               directory = FixSeparator ( node.value );\r
 }\r
index 0ca1a65..f7d589e 100644 (file)
@@ -62,8 +62,14 @@ Module::ProcessXML()
        size_t i;\r
        for ( i = 0; i < node.subElements.size(); i++ )\r
                ProcessXMLSubElement ( *node.subElements[i], path );\r
+       for ( i = 0; i < files.size(); i++ )\r
+               files[i]->ProcessXML();\r
        for ( i = 0; i < libraries.size(); i++ )\r
                libraries[i]->ProcessXML();\r
+       for ( i = 0; i < includes.size(); i++ )\r
+               includes[i]->ProcessXML();\r
+       for ( i = 0; i < defines.size(); i++ )\r
+               defines[i]->ProcessXML();\r
 }\r
 \r
 void\r
@@ -136,10 +142,16 @@ Module::GetDefaultModuleExtension () const
                                         __LINE__);\r
 }\r
 \r
+string\r
+Module::GetBasePath() const\r
+{\r
+       return path;\r
+}\r
+\r
 string\r
 Module::GetPath () const\r
 {\r
-       return FixSeparator (path) + CSEP + name + extension;\r
+       return path + CSEP + name + extension;\r
 }\r
 \r
 \r
@@ -148,6 +160,10 @@ File::File ( const string& _name )
 {\r
 }\r
 \r
+void\r
+File::ProcessXML()\r
+{\r
+}\r
 \r
 Library::Library ( const XMLElement& _node,\r
                    const Module& _module,\r
index 7844a1e..387d2be 100644 (file)
@@ -79,6 +79,7 @@ public:
                 const std::string& modulePath );\r
        ~Module ();\r
        ModuleType GetModuleType (const XMLAttribute& attribute );\r
+       std::string GetBasePath() const;\r
        std::string GetPath () const;\r
        void ProcessXML();\r
 private:\r
@@ -95,6 +96,7 @@ public:
        const Module* module;\r
        const XMLElement& node;\r
        std::string directory;\r
+       const Module* base;\r
 \r
        Include ( const Project& project,\r
                  const XMLElement& includeNode );\r
@@ -135,6 +137,8 @@ public:
        std::string name;\r
 \r
        File ( const std::string& _name );\r
+\r
+       void ProcessXML();\r
 };\r
 \r
 \r
index 92c45fc..69add64 100644 (file)
@@ -3,7 +3,12 @@
        <include>include1</include>\r
        <directory name="dir1">\r
                <module name="module1" type="buildtool">\r
-                               <include>include2</include>\r
+                       <include>include2</include>\r
+               </module>\r
+       </directory>\r
+       <directory name="dir2">\r
+               <module name="module2" type="buildtool">\r
+                       <include base="module1">include3</include>\r
                </module>\r
        </directory>\r
 </project>\r
index 955bffd..aa6891f 100644 (file)
@@ -10,10 +10,15 @@ void IncludeTest::Run()
        Include& include1 = *project.includes[0];\r
        ARE_EQUAL("include1", include1.directory);\r
 \r
-       ARE_EQUAL(1, project.modules.size());\r
+       ARE_EQUAL(2, project.modules.size());\r
        Module& module1 = *project.modules[0];\r
+       Module& module2 = *project.modules[1];\r
 \r
        ARE_EQUAL(1, module1.includes.size());\r
        Include& include2 = *module1.includes[0];\r
        ARE_EQUAL("include2", include2.directory);\r
+\r
+       ARE_EQUAL(1, module2.includes.size());\r
+       Include& include3 = *module2.includes[0];\r
+       ARE_EQUAL(FixSeparator("./dir1/include3"), include3.directory);\r
 }\r