support for <if> tag
authorRoyce Mitchell III <royce3@ev1.net>
Wed, 12 Jan 2005 06:02:58 +0000 (06:02 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Wed, 12 Jan 2005 06:02:58 +0000 (06:02 +0000)
.PHONY must be output before the target gets defined

svn path=/branches/xmlbuildsystem/; revision=12944

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

index 406ff96..a4846c3 100644 (file)
@@ -6,9 +6,18 @@
                        <xi:include href="config.template.xml" />\r
                </xi:fallback>\r
        </xi:include>\r
+\r
        <define name="_M_IX86" />\r
+       <if property="dbg" value="true">\r
+               <define name="dbg_or_kdbg" value="true" />\r
+       </if>\r
+       <if property="kdbg" value="true">\r
+               <define name="dbg_or_kdbg" value="true" />\r
+       </if>\r
+\r
        <include>include</include>\r
        <include>w32api/include</include>\r
+\r
        <directory name="tools">\r
                <xi:include href="tools/tools.xml" />\r
        </directory>\r
index 286251f..073813e 100644 (file)
                <file>rtlfunc.c</file>\r
        </directory>\r
        <directory name="dbg">\r
-               <!--\r
                <if property="arch" value="i386">\r
                        <directory name="i386">\r
-                               <if property="kdbg" value="true">\r
+                               <if property="kdbg" value="1">\r
                                        <group>\r
                                                <file>i386-dis.c</file>\r
                                                <file>kdb_help.S</file>\r
                                </if>\r
                        </directory>\r
                </if>\r
-               -->\r
-               <!--\r
-               <if property="kdbg" value="true">\r
-                       <group>\r
-                               <file>kdb.c</file>\r
-                               <file>kdb_keyboard.c</file>\r
-                               <file>kdb_serial.c</file>\r
-                               <file>rdebug.c</file>\r
-                               <file>profile.c</file>\r
-                       </group>\r
+               <if property="kdbg" value="1">\r
+                       <file>kdb.c</file>\r
+                       <file>kdb_keyboard.c</file>\r
+                       <file>kdb_serial.c</file>\r
+                       <file>rdebug.c</file>\r
+                       <file>profile.c</file>\r
+               </if>\r
+               <if property="dbg_or_kdbg" value="true">\r
+                       <file>kdb_stabs.c</file>\r
+                       <file>kdb_symbols.c</file>\r
                </if>\r
-               -->\r
-               <or>\r
-                       <!--\r
-                       <if property="kdbg" value="true">\r
-                               <group>\r
-                                       <file>kdb_stabs.c</file>\r
-                                       <file>kdb_symbols.c</file>\r
-                               </group>\r
-                       </if>\r
-                       -->\r
-                       <!--\r
-                       <if property="dbg" value="true">\r
-                               <group>\r
-                                       <file>kdb_stabs.c</file>\r
-                                       <file>kdb_symbols.c</file>\r
-                               </group>\r
-                       </if>\r
-                       -->\r
-               </or>\r
                <file>dbgctrl.c</file>\r
                <file>errinfo.c</file>\r
                <file>print.c</file>\r
index 4542a1f..43df9ba 100644 (file)
@@ -237,12 +237,14 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Includ
 void\r
 MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const\r
 {\r
+#if 0\r
        string name ( module.name + "_CFLAGS" );\r
        fprintf ( fMakefile,\r
                  "%s := %s %s\n",\r
                  name.c_str(),\r
-                         GenerateGccDefineParameters(module).c_str(),\r
+                 GenerateGccDefineParameters(module).c_str(),\r
                  GenerateGccIncludeParameters(module).c_str() );\r
+#endif\r
 }\r
 \r
 string\r
@@ -258,73 +260,174 @@ MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
        return parameters;\r
 }\r
 \r
-string\r
-MingwModuleHandler::GenerateGccParameters ( 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<Define*>& defines,\r
+       const string& cflags_macro,\r
+       const string& nasmflags_macro,\r
+       const string& objs_macro) const\r
 {\r
-       return ssprintf(" $(%s_CFLAGS)", module.name.c_str());\r
+       size_t i;\r
+\r
+       if ( (includes && 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
+               {\r
+                       Define& d = *module.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
+       if ( files.size() )\r
+       {\r
+               fprintf (\r
+                       fMakefile,\r
+                       "%s %s",\r
+                       objs_macro.c_str(),\r
+                       op );\r
+               for ( i = 0; i < files.size(); i++ )\r
+               {\r
+                       fprintf (\r
+                               fMakefile,\r
+                               "%s%s",\r
+                               ( i%10 == 9 ? "\\\n\t" : " " ),\r
+                               GetObjectFilename(files[i]->name).c_str() );\r
+               }\r
+               fprintf ( fMakefile, "\n" );\r
+       }\r
 }\r
 \r
-string\r
-MingwModuleHandler::GenerateNasmParameters ( const Module& module ) const\r
-{\r
-       return "";\r
+void\r
+MingwModuleHandler::GenerateMacros (\r
+       const Module& module,\r
+       const string& cflags_macro,\r
+       const string& nasmflags_macro,\r
+       const string& objs_macro) const\r
+{\r
+       GenerateMacros (\r
+               module,\r
+               "=",\r
+               module.files,\r
+               &module.includes,\r
+               module.defines,\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() )\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
+                               cflags_macro,\r
+                               nasmflags_macro,\r
+                               objs_macro );\r
+                       fprintf ( \r
+                               fMakefile,\r
+                               "endif\n\n" );\r
+               }\r
+       }\r
 }\r
 \r
 string\r
 MingwModuleHandler::GenerateGccCommand ( const Module& module,\r
-                                            const string& sourceFilename,\r
-                                            const string& cc ) const\r
+                                         const string& sourceFilename,\r
+                                         const string& cc,\r
+                                         const string& cflagsMacro ) const\r
 {\r
        string objectFilename = GetObjectFilename ( sourceFilename );\r
        return ssprintf ( "%s -c %s -o %s %s\n",\r
                              cc.c_str (),\r
                              sourceFilename.c_str (),\r
                              objectFilename.c_str (),\r
-                             GenerateGccParameters ( module ).c_str () );\r
+                             cflagsMacro.c_str () );\r
 }\r
 \r
 string\r
 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,\r
-                                                     const string& sourceFilename,\r
-                                                     const string& cc ) const\r
+                                                  const string& sourceFilename,\r
+                                                  const string& cc,\r
+                                                  const string& cflagsMacro ) const\r
 {\r
        string objectFilename = GetObjectFilename ( sourceFilename );\r
        return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",\r
-                             cc.c_str (),\r
-                             sourceFilename.c_str (),\r
-                             objectFilename.c_str (),\r
-                             GenerateGccParameters ( module ).c_str () );\r
+                         cc.c_str (),\r
+                         sourceFilename.c_str (),\r
+                         objectFilename.c_str (),\r
+                         cflagsMacro.c_str () );\r
 }\r
 \r
 string\r
 MingwModuleHandler::GenerateNasmCommand ( const Module& module,\r
-                                             const string& sourceFilename ) const\r
+                                          const string& sourceFilename,\r
+                                          const string& nasmflagsMacro ) const\r
 {\r
        string objectFilename = GetObjectFilename ( sourceFilename );\r
        return ssprintf ( "%s -f win32 %s -o %s %s\n",\r
                              "nasm",\r
                              sourceFilename.c_str (),\r
                              objectFilename.c_str (),\r
-                             GenerateNasmParameters ( module ).c_str () );\r
+                             nasmflagsMacro.c_str () );\r
 }\r
 \r
 string\r
 MingwModuleHandler::GenerateCommand ( const Module& module,\r
-                                         const string& sourceFilename,\r
-                                         const string& cc ) const\r
+                                      const string& sourceFilename,\r
+                                      const string& cc,\r
+                                      const string& cflagsMacro,\r
+                                      const string& nasmflagsMacro ) const\r
 {\r
        string extension = GetExtension ( sourceFilename );\r
        if ( extension == ".c" || extension == ".C" )\r
                return GenerateGccCommand ( module,\r
                                            sourceFilename,\r
-                                           cc );\r
+                                           cc,\r
+                                           cflagsMacro );\r
        else if ( extension == ".s" || extension == ".S" )\r
                return GenerateGccAssemblerCommand ( module,\r
                                                     sourceFilename,\r
-                                                    cc );\r
+                                                    cc,\r
+                                                    cflagsMacro );\r
        else if ( extension == ".asm" || extension == ".ASM" )\r
                return GenerateNasmCommand ( module,\r
-                                            sourceFilename );\r
+                                            sourceFilename,\r
+                                            nasmflagsMacro );\r
 \r
        throw InvalidOperationException ( __FILE__,\r
                                          __LINE__,\r
@@ -335,16 +438,17 @@ MingwModuleHandler::GenerateCommand ( const Module& module,
 \r
 void\r
 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,\r
-                                                   const string& cc) const\r
+                                                const vector<File*>& files,\r
+                                                const string& cc,\r
+                                                const string& cflagsMacro,\r
+                                                const string& nasmflagsMacro ) const\r
 {\r
-       if ( module.files.size () == 0 )\r
+       if ( files.size () == 0 )\r
                return;\r
-       \r
-       GenerateGccModuleIncludeVariable ( module );\r
 \r
-       for ( size_t i = 0; i < module.files.size (); i++ )\r
+       for ( size_t i = 0; i < files.size (); i++ )\r
        {\r
-               string sourceFilename = module.files[i]->name;\r
+               string sourceFilename = files[i]->name;\r
                string objectFilename = GetObjectFilename ( sourceFilename );\r
                fprintf ( fMakefile,\r
                          "%s: %s\n",\r
@@ -354,58 +458,76 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
                          "\t%s\n",\r
                          GenerateCommand ( module,\r
                                            sourceFilename,\r
-                                           cc ).c_str () );\r
+                                           cc,\r
+                                           cflagsMacro,\r
+                                           nasmflagsMacro ).c_str () );\r
        }\r
        \r
        fprintf ( fMakefile, "\n" );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateObjectFileTargetsHost ( const Module& module ) const\r
-{\r
-       GenerateObjectFileTargets ( module,\r
-                                   "${host_gcc}" );\r
-}\r
-\r
-void\r
-MingwModuleHandler::GenerateObjectFileTargetsTarget ( const Module& module ) const\r
+MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,\r
+                                                const string& cc,\r
+                                                const string& cflagsMacro,\r
+                                                const string& nasmflagsMacro ) const\r
 {\r
-       GenerateObjectFileTargets ( module,\r
-                                   "${gcc}" );\r
+       GenerateObjectFileTargets ( module, module.files, cc, cflagsMacro, nasmflagsMacro );\r
+       for ( size_t i = 0; i < module.ifs.size(); i++ )\r
+               GenerateObjectFileTargets ( module, module.ifs[i]->files, cc, cflagsMacro, nasmflagsMacro );\r
 }\r
 \r
 void\r
 MingwModuleHandler::GenerateArchiveTarget ( const Module& module,\r
-                                               const string& ar ) const\r
+                                            const string& ar,\r
+                                            const string& objs_macro ) const\r
 {\r
        string archiveFilename = GetModuleArchiveFilename ( module );\r
        string sourceFilenames = GetSourceFilenames ( module );\r
-       string objectsMacro = GenerateObjectList ( module );\r
        \r
        fprintf ( fMakefile,\r
                  "%s: %s\n",\r
                  archiveFilename.c_str (),\r
-                 objectsMacro.c_str ());\r
+                 objs_macro.c_str ());\r
 \r
        fprintf ( fMakefile,\r
                  "\t%s -rc %s %s\n\n",\r
                  ar.c_str (),\r
                  archiveFilename.c_str (),\r
-                 objectsMacro.c_str ());\r
+                 objs_macro.c_str ());\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateArchiveTargetHost ( const Module& module ) const\r
+MingwModuleHandler::GenerateMacrosAndTargets (\r
+       const Module& module,\r
+       const string& cc,\r
+       const string& ar ) const\r
 {\r
-       GenerateArchiveTarget ( module,\r
-                               "${host_ar}" );\r
+       string cflagsMacro = ssprintf("%s_CFLAGS",module.name.c_str());\r
+       string nasmflagsMacro = ssprintf("%s_NASMFLAGS",module.name.c_str());\r
+       string objectsMacro = ssprintf("%s_OBJS",module.name.c_str());\r
+\r
+       GenerateMacros ( module, cflagsMacro, nasmflagsMacro, objectsMacro );\r
+\r
+       // future references to the macros will be to get their values\r
+       cflagsMacro = ssprintf("$(%s)",cflagsMacro.c_str());\r
+       nasmflagsMacro = ssprintf("$(%s)",nasmflagsMacro.c_str());\r
+       objectsMacro = ssprintf("$(%s)",objectsMacro.c_str());\r
+\r
+       GenerateArchiveTarget ( module, ar, objectsMacro );\r
+       GenerateObjectFileTargets ( module, cc, cflagsMacro, nasmflagsMacro );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateArchiveTargetTarget ( const Module& module ) const\r
+MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const\r
 {\r
-       GenerateArchiveTarget ( module,\r
-                               "${ar}" );\r
+       GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}" );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const\r
+{\r
+       GenerateMacrosAndTargets ( module, "${gcc}", "${ar}" );\r
 }\r
 \r
 string\r
@@ -513,28 +635,37 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
                dependencies += s;\r
        }\r
        \r
+       fprintf ( fMakefile,\r
+                 ".PHONY: %s\n\n",\r
+                 preconditionDependenciesName.c_str () );\r
        fprintf ( fMakefile,\r
                  "%s: %s\n\n",\r
                  preconditionDependenciesName.c_str (),\r
                  dependencies.c_str () );\r
-       fprintf ( fMakefile,\r
-                 "%s: %s\n\n",\r
-                 sourceFilenames.c_str (),\r
-                 preconditionDependenciesName.c_str ());\r
-       fprintf ( fMakefile,\r
-                 ".PHONY: %s\n\n",\r
-                 preconditionDependenciesName.c_str () );\r
-}\r
-\r
-string MingwModuleHandler::GenerateObjectList ( const Module& module ) const\r
-{\r
-       string macro ( ssprintf("%s_OBJS",module.name.c_str()) );\r
-       fprintf (\r
-               fMakefile,\r
-               "%s = %s\n",\r
-               macro.c_str(),\r
-               GetObjectFilenames(module).c_str() );\r
-       return ssprintf("$(%s)",macro.c_str());\r
+       const char* p = sourceFilenames.c_str();\r
+       const char* end = p + strlen(p);\r
+       while ( p < end )\r
+       {\r
+               const char* p2 = &p[512];\r
+               if ( p2 > end )\r
+                       p2 = end;\r
+               while ( p2 > p && !isspace(*p2) )\r
+                       --p2;\r
+               if ( p == p2 )\r
+               {\r
+                       p2 = strpbrk ( p, " \t" );\r
+                       if ( !p2 )\r
+                               p2 = end;\r
+               }\r
+               fprintf ( fMakefile,\r
+                                 "%.*s: %s\n",\r
+                                 p2-p,\r
+                                 p,\r
+                                 preconditionDependenciesName.c_str ());\r
+               p = p2;\r
+               p += strspn ( p, " \t" );\r
+       }\r
+       fprintf ( fMakefile, "\n" );\r
 }\r
 \r
 \r
@@ -562,11 +693,10 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
                  target.c_str (),\r
                  archiveFilename.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${host_gcc} -o %s %s\n",\r
+                 "\t${host_gcc} -o %s %s\n\n",\r
                  target.c_str (),\r
                  archiveFilename.c_str () );\r
-       GenerateArchiveTargetHost ( module );\r
-       GenerateObjectFileTargetsHost ( module );\r
+       GenerateMacrosAndTargetsHost ( module );\r
 }\r
 \r
 static MingwKernelModuleHandler kernelmodule_handler;\r
@@ -628,11 +758,10 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s\n",\r
+                 "\t${rm} %s\n\n",\r
                  temp_exp.c_str () );\r
        \r
-       GenerateArchiveTargetTarget ( module );\r
-       GenerateObjectFileTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module );\r
 }\r
 \r
 \r
@@ -654,8 +783,7 @@ MingwStaticLibraryModuleHandler::Process ( const Module& module )
 void\r
 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )\r
 {\r
-       GenerateArchiveTargetTarget ( module );\r
-       GenerateObjectFileTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module );\r
 }\r
 \r
 \r
@@ -703,17 +831,16 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
                          importLibraryDependencies.c_str () );\r
        \r
                fprintf ( fMakefile,\r
-                         "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n",\r
+                         "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n\n",\r
                          target.c_str (),\r
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
                \r
-               GenerateArchiveTargetTarget ( module );\r
-               GenerateObjectFileTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module );\r
        }\r
        else\r
        {\r
-               fprintf ( fMakefile, "%s:\n\n",\r
+               fprintf ( fMakefile, "%s:\n",\r
                          target.c_str ());\r
                fprintf ( fMakefile, ".PHONY: %s\n\n",\r
                          target.c_str ());\r
@@ -765,13 +892,12 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
                          importLibraryDependencies.c_str () );\r
        \r
                fprintf ( fMakefile,\r
-                         "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n",\r
+                         "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n\n",\r
                          target.c_str (),\r
                          archiveFilename.c_str (),\r
                          importLibraryDependencies.c_str () );\r
                \r
-               GenerateArchiveTargetTarget ( module );\r
-               GenerateObjectFileTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module );\r
        }\r
        else\r
        {\r
index d7bf6a5..d2715c7 100644 (file)
@@ -30,15 +30,15 @@ protected:
 \r
        std::string GetObjectFilename ( const std::string& sourceFilename ) const;\r
        std::string GetObjectFilenames ( const Module& module ) const;\r
-       void GenerateObjectFileTargetsHost ( const Module& module ) const;\r
-       void GenerateObjectFileTargetsTarget ( const Module& module ) const;\r
-       void GenerateArchiveTargetHost ( const Module& module ) const;\r
-       void GenerateArchiveTargetTarget ( const Module& module ) const;\r
+       void GenerateMacrosAndTargetsHost ( const Module& module ) const;\r
+       void GenerateMacrosAndTargetsTarget ( const Module& module ) const;\r
        std::string GetInvocationDependencies ( const Module& module ) const;\r
        std::string GetInvocationParameters ( const Invoke& invoke ) const;\r
        void GenerateInvocations ( const Module& module ) const;\r
        void GeneratePreconditionDependencies ( const Module& module ) const;\r
-       std::string GenerateObjectList ( const Module& module ) const;\r
+       std::string GenerateMacros ( const Module& module,\r
+                                    const std::string& cflags_macro,\r
+                                    const std::string& objs_macro ) const;\r
        static FILE* fMakefile;\r
 private:\r
        std::string ConcatenatePaths ( const std::string& path1,\r
@@ -46,25 +46,53 @@ 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
+                             const std::vector<File*>& files,\r
+                             const std::vector<Include*>* includes,\r
+                             const std::vector<Define*>& defines,\r
+                             const std::string& cflags_macro,\r
+                             const std::string& nasmflags_macro,\r
+                             const std::string& objs_macro) const;\r
+       void GenerateMacros ( const Module& module,\r
+                             const std::string& cflags_macro,\r
+                             const std::string& nasmflags_macro,\r
+                             const std::string& objs_macro) const;\r
        void GenerateGccModuleIncludeVariable ( const Module& module ) const;\r
        std::string GenerateGccIncludeParameters ( const Module& module ) const;\r
        std::string GenerateGccParameters ( const Module& module ) const;\r
        std::string GenerateNasmParameters ( const Module& module ) const;\r
        std::string GenerateGccCommand ( const Module& module,\r
                                         const std::string& sourceFilename,\r
-                                        const std::string& cc ) const;\r
+                                        const std::string& cc,\r
+                                        const std::string& cflagsMacro ) const;\r
        std::string GenerateGccAssemblerCommand ( const Module& module,\r
                                                  const std::string& sourceFilename,\r
-                                                 const std::string& cc ) const;\r
+                                                 const std::string& cc,\r
+                                                 const std::string& cflagsMacro ) const;\r
        std::string GenerateNasmCommand ( const Module& module,\r
-                                         const std::string& sourceFilename ) const;\r
+                                         const std::string& sourceFilename,\r
+                                         const std::string& nasmflagsMacro ) const;\r
        std::string GenerateCommand ( const Module& module,\r
                                      const std::string& sourceFilename,\r
-                                     const std::string& cc ) const;\r
+                                     const std::string& cc,\r
+                                     const std::string& cflagsMacro,\r
+                                     const std::string& nasmflagsMacro ) const;\r
        void GenerateObjectFileTargets ( const Module& module,\r
-                                        const std::string& cc ) const;\r
+                                        const std::vector<File*>& files,\r
+                                        const std::string& cc,\r
+                                        const std::string& cflagsMacro,\r
+                                        const std::string& nasmflagsMacro ) const;\r
+       void GenerateObjectFileTargets ( const Module& module,\r
+                                        const std::string& cc,\r
+                                        const std::string& cflagsMacro,\r
+                                        const std::string& nasmflagsMacro ) const;\r
        void GenerateArchiveTarget ( const Module& module,\r
-                                    const std::string& ar ) const;\r
+                                    const std::string& ar,\r
+                                    const std::string& objs_macro ) const;\r
+       void GenerateMacrosAndTargets ( const Module& module,\r
+                                       const std::string& cc,\r
+                                       const std::string& ar ) const;\r
        std::string GetPreconditionDependenciesName ( const Module& module ) const;\r
 };\r
 \r
index fba4022..125531f 100644 (file)
@@ -63,6 +63,8 @@ Module::~Module ()
                delete invocations[i];\r
        for ( i = 0; i < dependencies.size(); i++ )\r
                delete dependencies[i];\r
+       for ( i = 0; i < ifs.size(); i++ )\r
+               delete ifs[i];\r
 }\r
 \r
 void\r
@@ -83,21 +85,32 @@ Module::ProcessXML()
                invocations[i]->ProcessXML ();\r
        for ( i = 0; i < dependencies.size(); i++ )\r
                dependencies[i]->ProcessXML ();\r
+       for ( i = 0; i < ifs.size(); i++ )\r
+               ifs[i]->ProcessXML();\r
 }\r
 \r
 void\r
 Module::ProcessXMLSubElement ( const XMLElement& e,\r
-                               const string& path )\r
+                               const string& path,\r
+                               If* pIf /*= NULL*/ )\r
 {\r
        bool subs_invalid = false;\r
        string subpath ( path );\r
        if ( e.name == "file" && e.value.size () > 0 )\r
        {\r
-               files.push_back ( new File ( FixSeparator ( path + CSEP + e.value ) ) );\r
+               File* pFile = new File ( FixSeparator ( path + CSEP + e.value ) );\r
+               if ( pIf )\r
+                       pIf->files.push_back ( pFile );\r
+               else\r
+                       files.push_back ( pFile );\r
                subs_invalid = true;\r
        }\r
        else if ( e.name == "library" && e.value.size () )\r
        {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<library> is not a valid sub-element of <if>" );\r
                libraries.push_back ( new Library ( e, *this, e.value ) );\r
                subs_invalid = true;\r
        }\r
@@ -109,36 +122,66 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }\r
        else if ( e.name == "include" )\r
        {\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
                subs_invalid = true;\r
        }\r
        else if ( e.name == "define" )\r
        {\r
-               defines.push_back ( new Define ( project, this, e ) );\r
+               Define* pDefine = new Define ( project, this, e );\r
+               if ( pIf )\r
+                       pIf->defines.push_back ( pDefine );\r
+               else\r
+                       defines.push_back ( pDefine );\r
                subs_invalid = true;\r
        }\r
        else if ( e.name == "invoke" )\r
        {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<invoke> is not a valid sub-element of <if>" );\r
                invocations.push_back ( new Invoke ( e, *this ) );\r
                subs_invalid = false;\r
        }\r
        else if ( e.name == "dependency" )\r
        {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<dependency> is not a valid sub-element of <if>" );\r
                dependencies.push_back ( new Dependency ( e, *this ) );\r
                subs_invalid = true;\r
        }\r
        else if ( e.name == "importlibrary" )\r
        {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<importlibrary> is not a valid sub-element of <if>" );\r
+               if ( importLibrary )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "Only one <importlibrary> is valid per module" );\r
                importLibrary = new ImportLibrary ( e, *this );\r
                subs_invalid = true;\r
        }\r
+       else if ( e.name == "if" )\r
+       {\r
+               pIf = new If ( e, *this );\r
+               ifs.push_back ( pIf );\r
+               subs_invalid = false;\r
+       }\r
        if ( subs_invalid && e.subElements.size() > 0 )\r
                throw InvalidBuildFileException (\r
                        e.location,\r
                        "<%s> cannot have sub-elements",\r
                        e.name.c_str() );\r
        for ( size_t i = 0; i < e.subElements.size (); i++ )\r
-               ProcessXMLSubElement ( *e.subElements[i], subpath );\r
+               ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );\r
 }\r
 \r
 ModuleType\r
@@ -188,14 +231,23 @@ Module::GetTargetName () const
 string\r
 Module::GetDependencyPath () const\r
 {\r
-       if ( type == KernelModeDLL )\r
+       switch ( type )\r
+       {\r
+       case KernelModeDLL:\r
                return ssprintf ( "dk%snkm%slib%slib%s.a",\r
                                  SSEP,\r
                                  SSEP,\r
                                  SSEP,\r
                                  name.c_str () );\r
-       else\r
-               return GetPath ();\r
+       case NativeDLL:\r
+               return ssprintf ( "dk%sw32%slib%slib%s.a",\r
+                                 SSEP,\r
+                                 SSEP,\r
+                                 SSEP,\r
+                                 name.c_str () );\r
+       default:\r
+               return GetPath();\r
+       }\r
 }\r
 \r
 string\r
@@ -425,5 +477,36 @@ ImportLibrary::ImportLibrary ( const XMLElement& _node,
 \r
        att = _node.GetAttribute ( "definition", true );\r
        assert (att);\r
-       definition = att->value;\r
+       definition = FixSeparator(att->value);\r
+}\r
+\r
+\r
+If::If ( const XMLElement& node_, const Module& module_ )\r
+       : node(node_), module(module_)\r
+{\r
+       const XMLAttribute* att;\r
+\r
+       att = node.GetAttribute ( "property", true );\r
+       assert(att);\r
+       property = att->value;\r
+\r
+       att = node.GetAttribute ( "value", true );\r
+       assert(att);\r
+       value = att->value;\r
+}\r
+\r
+If::~If ()\r
+{\r
+       size_t i;\r
+       for ( i = 0; i < files.size(); i++ )\r
+               delete files[i];\r
+       for ( i = 0; i < defines.size(); i++ )\r
+               delete defines[i];\r
+       for ( i = 0; i < ifs.size(); i++ )\r
+               delete ifs[i];\r
+}\r
+\r
+void\r
+If::ProcessXML()\r
+{\r
 }\r
index 8411a35..cde527b 100644 (file)
@@ -31,6 +31,7 @@ class Invoke;
 class InvokeFile;\r
 class Dependency;\r
 class ImportLibrary;\r
+class If;\r
 \r
 class Project\r
 {\r
@@ -86,6 +87,7 @@ public:
        std::vector<Define*> defines;\r
        std::vector<Invoke*> invocations;\r
        std::vector<Dependency*> dependencies;\r
+       std::vector<If*> ifs;\r
 \r
        Module ( const Project& project,\r
                 const XMLElement& moduleNode,\r
@@ -104,7 +106,8 @@ public:
 private:\r
        std::string GetDefaultModuleExtension () const;\r
        void ProcessXMLSubElement ( const XMLElement& e,\r
-                                   const std::string& path );\r
+                                   const std::string& path,\r
+                                   If* pIf = NULL );\r
 };\r
 \r
 \r
@@ -239,6 +242,23 @@ public:
        void ProcessXML ();\r
 };\r
 \r
+class If\r
+{\r
+public:\r
+       const XMLElement& node;\r
+       const Module& module;\r
+       std::string property, value;\r
+       std::vector<File*> files;\r
+       std::vector<Define*> defines;\r
+       std::vector<If*> ifs;\r
+\r
+       If ( const XMLElement& node_,\r
+            const Module& module_ );\r
+       ~If();\r
+\r
+       void ProcessXML();\r
+};\r
+\r
 extern std::string\r
 FixSeparator ( const std::string& s );\r
 \r