bugfixes to new <if> and related code
authorRoyce Mitchell III <royce3@ev1.net>
Thu, 13 Jan 2005 03:43:10 +0000 (03:43 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Thu, 13 Jan 2005 03:43:10 +0000 (03:43 +0000)
svn path=/branches/xmlbuildsystem/; revision=13016

reactos/ReactOS.xml
reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/mingw.h
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/project.cpp
reactos/tools/rbuild/rbuild.h

index a4846c3..0b74081 100644 (file)
@@ -8,11 +8,13 @@
        </xi:include>\r
 \r
        <define name="_M_IX86" />\r
-       <if property="dbg" value="true">\r
-               <define name="dbg_or_kdbg" value="true" />\r
+       <if property="DBG" value="1">\r
+               <define name="DBG" value="1" />\r
+               <property name="DBG_OR_KDBG" value="true" />\r
        </if>\r
-       <if property="kdbg" value="true">\r
-               <define name="dbg_or_kdbg" value="true" />\r
+       <if property="KDBG" value="1">\r
+               <define name="KDBG" value="1" />\r
+               <property name="DBG_OR_KDBG" value="true" />\r
        </if>\r
 \r
        <include>include</include>\r
index bc8c234..73fc906 100644 (file)
@@ -59,39 +59,79 @@ MingwBackend::GenerateHeader ()
        fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );\r
 }\r
 \r
-string\r
-MingwBackend::GenerateProjectCFLAGS ()\r
+void\r
+MingwBackend::GenerateGlobalCFlagsAndProperties (\r
+       const char* op,\r
+       const vector<Property*>& properties,\r
+       const vector<Include*>& includes,\r
+       const vector<Define*>& defines,\r
+       const vector<If*>& ifs )\r
 {\r
        size_t i;\r
-       string clags;\r
-       for ( i = 0; i < ProjectNode.includes.size (); i++ )\r
+\r
+       for ( i = 0; i < properties.size(); i++ )\r
        {\r
-               Include& include = *ProjectNode.includes[i];\r
-               if (clags.length () > 0)\r
-                       clags += " ";\r
-               clags += "-I" + include.directory;\r
+               Property& prop = *properties[i];\r
+               fprintf ( fMakefile, "%s := %s\n",\r
+                       prop.name.c_str(),\r
+                       prop.value.c_str() );\r
        }\r
-       \r
-       for ( i = 0; i < ProjectNode.defines.size (); i++ )\r
+\r
+       if ( includes.size() || defines.size() )\r
        {\r
-               Define& define = *ProjectNode.defines[i];\r
-               if ( clags.length () > 0 )\r
-                       clags += " ";\r
-               clags += "-D" + define.name;\r
-               if ( define.value.size() > 0 )\r
+               fprintf (\r
+                       fMakefile,\r
+                       "PROJECT_CFLAGS %s",\r
+                       op );\r
+               for ( i = 0; i < includes.size(); i++ )\r
+               {\r
+                       fprintf (\r
+                               fMakefile,\r
+                               " -I%s",\r
+                               includes[i]->directory.c_str() );\r
+               }\r
+               for ( i = 0; i < defines.size(); i++ )\r
                {\r
-                       clags += "=";\r
-                       clags += define.value;\r
+                       Define& d = *defines[i];\r
+                       fprintf (\r
+                               fMakefile,\r
+                               " -D%s",\r
+                               d.name.c_str() );\r
+                       if ( d.value.size() )\r
+                               fprintf (\r
+                                       fMakefile,\r
+                                       "=%s",\r
+                                       d.value.c_str() );\r
+               }\r
+               fprintf ( fMakefile, "\n" );\r
+       }\r
+\r
+       for ( i = 0; i < ifs.size(); i++ )\r
+       {\r
+               If& rIf = *ifs[i];\r
+               if ( rIf.defines.size() || rIf.includes.size() || rIf.ifs.size() )\r
+               {\r
+                       fprintf (\r
+                               fMakefile,\r
+                               "ifeq (\"$(%s)\",\"%s\")\n",\r
+                               rIf.property.c_str(),\r
+                               rIf.value.c_str() );\r
+                       GenerateGlobalCFlagsAndProperties (\r
+                               "+=",\r
+                               rIf.properties,\r
+                               rIf.includes,\r
+                               rIf.defines,\r
+                               rIf.ifs );\r
+                       fprintf ( \r
+                               fMakefile,\r
+                               "endif\n\n" );\r
                }\r
        }\r
-       return clags;\r
 }\r
 \r
 void\r
 MingwBackend::GenerateGlobalVariables ()\r
 {\r
-       size_t i;\r
-\r
        fprintf ( fMakefile, "host_gcc = gcc\n" );\r
        fprintf ( fMakefile, "host_ar = ar\n" );\r
        fprintf ( fMakefile, "host_ld = ld\n" );\r
@@ -99,15 +139,13 @@ MingwBackend::GenerateGlobalVariables ()
        fprintf ( fMakefile, "gcc = gcc\n" );\r
        fprintf ( fMakefile, "ld = ld\n" );\r
        fprintf ( fMakefile, "ar = ar\n" );\r
-       fprintf ( fMakefile, "dlltool = dlltool\n" );\r
-       fprintf ( fMakefile, "PROJECT_CFLAGS = %s\n", GenerateProjectCFLAGS ().c_str () );\r
-       for ( i = 0; i < ProjectNode.properties.size(); i++ )\r
-       {\r
-               Property& prop = *ProjectNode.properties[i];\r
-               fprintf ( fMakefile, "%s := %s\n",\r
-                       prop.name.c_str(),\r
-                       prop.value.c_str() );\r
-       }\r
+       fprintf ( fMakefile, "dlltool = dlltool\n\n" );\r
+       GenerateGlobalCFlagsAndProperties (\r
+               "=",\r
+               ProjectNode.properties,\r
+               ProjectNode.includes,\r
+               ProjectNode.defines,\r
+               ProjectNode.ifs );\r
        fprintf ( fMakefile, "\n" );\r
 }\r
 \r
index f23d84c..6fc8164 100644 (file)
@@ -14,7 +14,13 @@ private:
        void CreateMakefile ();\r
        void CloseMakefile ();\r
        void GenerateHeader ();\r
-       std::string GenerateProjectCFLAGS ();\r
+       void\r
+       MingwBackend::GenerateGlobalCFlagsAndProperties (\r
+               const char* op,\r
+               const std::vector<Property*>& properties,\r
+               const std::vector<Include*>& includes,\r
+               const std::vector<Define*>& defines,\r
+               const std::vector<If*>& ifs );\r
        void GenerateGlobalVariables ();\r
        void GenerateAllTarget ();\r
        FILE* fMakefile;\r
index f01f216..c8d482c 100644 (file)
@@ -262,34 +262,34 @@ MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
 \r
 void\r
 MingwModuleHandler::GenerateMacros (\r
-       const Module& module,\r
        const char* op,\r
        const vector<File*>& files,\r
-       const vector<Include*>* includes,\r
+       const vector<Include*>& includes,\r
        const vector<Define*>& defines,\r
-       const vector<If*>* ifs,\r
+       const vector<If*>& ifs,\r
        const string& cflags_macro,\r
        const string& nasmflags_macro,\r
        const string& objs_macro) const\r
 {\r
        size_t i;\r
 \r
-       if ( (includes && includes->size()) || defines.size() )\r
+       if ( includes.size() || defines.size() )\r
        {\r
                fprintf (\r
                        fMakefile,\r
                        "%s %s",\r
                        cflags_macro.c_str(),\r
                        op );\r
-               if ( includes )\r
-                       for ( i = 0; i < includes->size(); i++ )\r
-                               fprintf (\r
-                                       fMakefile,\r
-                                       " -I%s",\r
-                                       (*includes)[i]->directory.c_str() );\r
-               for ( i = 0; i < module.defines.size(); i++ )\r
+               for ( i = 0; i < includes.size(); i++ )\r
                {\r
-                       Define& d = *module.defines[i];\r
+                       fprintf (\r
+                               fMakefile,\r
+                               " -I%s",\r
+                               includes[i]->directory.c_str() );\r
+               }\r
+               for ( i = 0; i < defines.size(); i++ )\r
+               {\r
+                       Define& d = *defines[i];\r
                        fprintf (\r
                                fMakefile,\r
                                " -D%s",\r
@@ -321,32 +321,28 @@ MingwModuleHandler::GenerateMacros (
                fprintf ( fMakefile, "\n" );\r
        }\r
 \r
-       if ( ifs && ifs->size() )\r
+       for ( i = 0; i < ifs.size(); i++ )\r
        {\r
-               for ( size_t i = 0; i < ifs->size(); i++ )\r
+               If& rIf = *ifs[i];\r
+               if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() )\r
                {\r
-                       If& rIf = *(*ifs)[i];\r
-                       if ( rIf.defines.size() || rIf.files.size() || rIf.ifs.size() )\r
-                       {\r
-                               fprintf (\r
-                                       fMakefile,\r
-                                       "ifeq ($(%s),\"%s\")\n",\r
-                                       rIf.property.c_str(),\r
-                                       rIf.value.c_str() );\r
-                               GenerateMacros (\r
-                                       module,\r
-                                       "+=",\r
-                                       rIf.files,\r
-                                       NULL,\r
-                                       rIf.defines,\r
-                                       &rIf.ifs,\r
-                                       cflags_macro,\r
-                                       nasmflags_macro,\r
-                                       objs_macro );\r
-                               fprintf ( \r
-                                       fMakefile,\r
-                                       "endif\n\n" );\r
-                       }\r
+                       fprintf (\r
+                               fMakefile,\r
+                               "ifeq ($(%s),\"%s\")\n",\r
+                               rIf.property.c_str(),\r
+                               rIf.value.c_str() );\r
+                       GenerateMacros (\r
+                               "+=",\r
+                               rIf.files,\r
+                               rIf.includes,\r
+                               rIf.defines,\r
+                               rIf.ifs,\r
+                               cflags_macro,\r
+                               nasmflags_macro,\r
+                               objs_macro );\r
+                       fprintf ( \r
+                               fMakefile,\r
+                               "endif\n\n" );\r
                }\r
        }\r
 }\r
@@ -359,42 +355,16 @@ MingwModuleHandler::GenerateMacros (
        const string& objs_macro) const\r
 {\r
        GenerateMacros (\r
-               module,\r
                "=",\r
                module.files,\r
-               &module.includes,\r
+               module.includes,\r
                module.defines,\r
-               NULL,\r
+               module.ifs,\r
                cflags_macro,\r
                nasmflags_macro,\r
                objs_macro );\r
        fprintf ( fMakefile, "\n" );\r
 \r
-       for ( size_t i = 0; i < module.ifs.size(); i++ )\r
-       {\r
-               If& rIf = *module.ifs[i];\r
-               if ( rIf.defines.size() || rIf.files.size() || rIf.ifs.size() )\r
-               {\r
-                       fprintf (\r
-                               fMakefile,\r
-                               "ifeq (\"$(%s)\",\"%s\")\n",\r
-                               rIf.property.c_str(),\r
-                               rIf.value.c_str() );\r
-                       GenerateMacros (\r
-                               module,\r
-                               "+=",\r
-                               rIf.files,\r
-                               NULL,\r
-                               rIf.defines,\r
-                               &rIf.ifs,\r
-                               cflags_macro,\r
-                               nasmflags_macro,\r
-                               objs_macro );\r
-                       fprintf ( \r
-                               fMakefile,\r
-                               "endif\n\n" );\r
-               }\r
-       }\r
        fprintf (\r
                fMakefile,\r
                "%s += $(PROJECT_CFLAGS)\n\n",\r
index 582ce0a..3dfc558 100644 (file)
@@ -46,12 +46,11 @@ private:
        std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;\r
        std::string GenerateGccDefineParameters ( const Module& module ) const;\r
        std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;\r
-       void GenerateMacros ( const Module& module,\r
-                             const char* op,\r
+       void GenerateMacros ( const char* op,\r
                              const std::vector<File*>& files,\r
-                             const std::vector<Include*>* includes,\r
+                             const std::vector<Include*>& includes,\r
                              const std::vector<Define*>& defines,\r
-                             const std::vector<If*>* ifs,\r
+                             const std::vector<If*>& ifs,\r
                              const std::string& cflags_macro,\r
                              const std::string& nasmflags_macro,\r
                              const std::string& objs_macro) const;\r
index 63fac98..e1a883d 100644 (file)
@@ -122,11 +122,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }\r
        else if ( e.name == "include" )\r
        {\r
+               Include* include = new Include ( project, this, e );\r
                if ( pIf )\r
-                       throw InvalidBuildFileException (\r
-                               e.location,\r
-                               "<include> is not a valid sub-element of <if>" );\r
-               includes.push_back ( new Include ( project, this, e ) );\r
+                       pIf->includes.push_back ( include );\r
+               else\r
+                       includes.push_back ( include );\r
                subs_invalid = true;\r
        }\r
        else if ( e.name == "define" )\r
@@ -513,6 +513,8 @@ If::~If ()
        size_t i;\r
        for ( i = 0; i < files.size(); i++ )\r
                delete files[i];\r
+       for ( i = 0; i < includes.size(); i++ )\r
+               delete includes[i];\r
        for ( i = 0; i < defines.size(); i++ )\r
                delete defines[i];\r
        for ( i = 0; i < ifs.size(); i++ )\r
index c469f81..1dd4791 100644 (file)
@@ -96,6 +96,10 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
        string subpath(path);\r
        if ( e.name == "module" )\r
        {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<module> is not a valid sub-element of <if>" );\r
                Module* module = new Module ( *this, e, path );\r
                if ( LocateModule ( module->name ) )\r
                        throw InvalidBuildFileException (\r
@@ -114,7 +118,11 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
        }\r
        else if ( e.name == "include" )\r
        {\r
-               includes.push_back ( new Include ( *this, e ) );\r
+               Include* include = new Include ( *this, e );\r
+               if ( pIf )\r
+                       pIf->includes.push_back ( include );\r
+               else\r
+                       includes.push_back ( include );\r
                subs_invalid = true;\r
        }\r
        else if ( e.name == "define" )\r
index 02ae038..dccde48 100644 (file)
@@ -256,6 +256,7 @@ public:
        const Module* module;\r
        std::string property, value;\r
        std::vector<File*> files;\r
+       std::vector<Include*> includes;\r
        std::vector<Define*> defines;\r
        std::vector<Property*> properties;\r
        std::vector<If*> ifs;\r