Don't decide whether to preprocess .spec files based on Kernel-Mode vs. User-Mode...
authorColin Finck <colin@reactos.org>
Wed, 29 Oct 2008 16:42:03 +0000 (16:42 +0000)
committerColin Finck <colin@reactos.org>
Wed, 29 Oct 2008 16:42:03 +0000 (16:42 +0000)
.pspec files are preprocessed now, while .spec files aren't. A change like this was already done in the amd64 branch before KJK rewrote the .spec stuff in rbuild.

- Renamed currently preprocessed .spec files to .pspec and changed that in the .rbuild files appropriately
- Renamed "IsWineModule" to "IsSpecDefinitionFile",  the new name is more appropriate
- Removed some checks for uppercased file extensions, we neither use them in our tree nor it will totally work as we only support them in a few places

Commit dedicated to Timo ;-)

svn path=/trunk/; revision=37070

15 files changed:
reactos/hal/hal/hal.pspec [moved from reactos/hal/hal/hal.spec with 100% similarity]
reactos/hal/hal/hal.rbuild
reactos/hal/halarm/up/halup.rbuild
reactos/hal/halx86/halmp.rbuild
reactos/hal/halx86/halup.rbuild
reactos/hal/halx86/halxbox.rbuild
reactos/ntoskrnl/ntoskrnl-generic.rbuild
reactos/ntoskrnl/ntoskrnl.pspec [moved from reactos/ntoskrnl/ntoskrnl.spec with 100% similarity]
reactos/subsystems/win32/win32k/win32k.pspec [moved from reactos/subsystems/win32/win32k/win32k.spec with 100% similarity]
reactos/subsystems/win32/win32k/win32k.rbuild
reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
reactos/tools/rbuild/backend/codeblocks/codeblocks.h
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/compilationunit.cpp

index 564920b..71c4308 100644 (file)
@@ -9,18 +9,18 @@
                <define name="_NTHAL_" />
                <file>hal.c</file>
                <file>hal.rc</file>
-               <file>hal.spec</file>
+               <file>hal.pspec</file>
        </module>
     </if>
     <if property="ARCH" value="i386">
        <module name="hal" type="kernelmodedll">
-               <importlibrary definition="hal.spec" />
+               <importlibrary definition="hal.pspec" />
                <include base="ntoskrnl">include</include>
                <library>ntoskrnl</library>
                <define name="_NTHAL_" />
                <file>hal.c</file>
                <file>hal.rc</file>
-               <file>hal.spec</file>
+               <file>hal.pspec</file>
        </module>
     </if>
        <if property="ARCH" value="i386">
index c295073..6f4179d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
 <module name="halarm_up" type="kernelmodedll" installbase="system32" installname="hal.dll">
-       <importlibrary base="hal" definition="hal.spec" />
+       <importlibrary base="hal" definition="hal.pspec" />
        <bootstrap installbase="$(CDOUTPUT)" nameoncd="hal.dll" />
        <include base="halarm_generic">../include</include>
        <include base="ntoskrnl">include</include>
index 724e789..d806406 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
        <module name="halmp" type="kernelmodedll" entrypoint="0">
-               <importlibrary base="hal" definition="hal.spec" />
+               <importlibrary base="hal" definition="hal.pspec" />
                <bootstrap installbase="$(CDOUTPUT)" />
                <include>include</include>
                <include base="ntoskrnl">include</include>
index c206b7e..26ed546 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
        <module name="halup" type="kernelmodedll" entrypoint="0" installname="hal.dll">
-               <importlibrary base="hal" definition="hal.spec" />
+               <importlibrary base="hal" definition="hal.pspec" />
                <bootstrap installbase="$(CDOUTPUT)" />
                <include>include</include>
                <include base="ntoskrnl">include</include>
index 923583a..f1573b8 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
        <module name="halxbox" type="kernelmodedll" entrypoint="0" allowwarnings="true">
-               <importlibrary base="hal" definition="hal.spec" />
+               <importlibrary base="hal" definition="hal.pspec" />
                <include>include</include>
                <include base="ntoskrnl">include</include>
                <define name="_DISABLE_TIDENTS" />
index 2387103..99f6c8f 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE module SYSTEM "../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
        <bootstrap installbase="$(CDOUTPUT)" />
-       <importlibrary definition="ntoskrnl.spec" />
+       <importlibrary definition="ntoskrnl.pspec" />
        <define name="_DISABLE_TIDENTS" />
        <define name="__NTOSKRNL__" />
        <define name="_NTOSKRNL_" />
                <file>wmi.c</file>
        </directory>
        <file>ntoskrnl.rc</file>
-       <file>ntoskrnl.spec</file>
+       <file>ntoskrnl.pspec</file>
        <linkerscript>ntoskrnl_$(ARCH).lnk</linkerscript>
 </group>
index 97f210a..28649dd 100644 (file)
        </directory>
 </module>
 <module name="win32k" type="kernelmodedriver" installbase="system32" installname="win32k.sys" allowwarnings="true">
-       <importlibrary definition="win32k.spec" />
+       <importlibrary definition="win32k.pspec" />
        <library>win32k_base</library>
        <library>pseh</library>
        <library>ntoskrnl</library>
index 2a79d3a..73502e8 100644 (file)
@@ -685,7 +685,7 @@ CBBackend::_generate_cbproj ( const Module& module )
 #if 0
                if ( dll )
                {
-                       if (IsWineModule( module ))
+                       if (IsSpecDefinitionFile( module ))
                                fprintf ( OUT, "\t\t\t\t\t<Add before=\"%s\\tools\\winebuild\\winebuild.exe -o %s --def -E %s.spec\" />\r\n", outdir.c_str(), module.importLibrary->definition.c_str(),  module.name.c_str());
                        fprintf ( OUT, "\t\t\t\t\t<Add before=\"dlltool --dllname %s --def %s --output-exp %s.temp.exp %s\" />\r\n", module.GetTargetName ().c_str(), module.importLibrary->definition.c_str(), module.name.c_str(), module.mangledSymbols ? "" : "--kill-at" );
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"%s\\tools\\pefixup $exe_output -exports\" />\r\n", outdir.c_str() );
@@ -902,11 +902,11 @@ CBBackend::_lookup_property ( const Module& module, const std::string& name ) co
 }
 
 bool
-CBBackend::IsWineModule ( const Module& module ) const
+CBBackend::IsSpecDefinitionFile ( const Module& module ) const
 {
        if ( module.importLibrary == NULL)
                return false;
 
-       size_t index = module.importLibrary->source->name.rfind ( ".spec.def" );
+       size_t index = module.importLibrary->source->name.rfind ( ".spec" );
        return ( index != string::npos );
 }
index 22d0312..6ab399e 100644 (file)
@@ -74,7 +74,7 @@ class CBBackend : public Backend
                std::string DependFileName ( const Module& module ) const;
                std::string GenerateProjectLinkerFlags () const;
                void MingwAddImplicitLibraries( Module &module );
-               bool IsWineModule ( const Module& module ) const;
+               bool IsSpecDefinitionFile ( const Module& module ) const;
                std::vector<CBConfiguration*> m_configurations;
 
                std::vector<FileUnit> m_fileUnits;
index 0e68730..dce4877 100644 (file)
@@ -416,13 +416,13 @@ MingwModuleHandler::GetObjectFilename (
 
        if ( module.type == BootSector )
                return new FileLocation ( *module.output );
-       else if ( extension == ".rc" || extension == ".RC" )
+       else if (extension == ".rc")
                newExtension = "_" + module.name + ".coff";
-       else if ( extension == ".mc" || extension == ".MC" )
+       else if (extension == ".mc")
                newExtension = ".rc";
-       else if ( extension == ".spec" || extension == ".SPEC" )
+       else if (extension == ".spec" || extension == ".pspec")
                newExtension = "_" + module.name + ".stubs.o";
-       else if ( extension == ".idl" || extension == ".IDL" )
+       else if (extension == ".idl")
        {
                if ( module.type == RpcServer )
                        newExtension = "_s.o";
@@ -1056,28 +1056,28 @@ Rule wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc
                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc",
                "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h",
                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule winebuildKMDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
-                                                 "\t$(ECHO_WINEBLD)\n"
-                                                 "\t${gcc} -xc -E $(source) -I. > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
-                                                 "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).spec.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n\n",
-                                                 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
-                                                 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec.def",
-                                                 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule winebuildKMRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c:\n"
-                       "\t${cp} $(NUL) $@ 1>$(NUL)\n"
-                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
-                       "\t$(ECHO_CC)\n"
-                       "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
-                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
-                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
-                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
-                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
-                                               "\t$(ECHO_WINEBLD)\n"
-                                               "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).spec.def --def -E $(source)\n\n",
-                                               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
-                                               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).spec.def",
-                                               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule winebuildPDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                         "\t$(ECHO_WINEBLD)\n"
+                         "\t${gcc} -xc -E $(source) -I. > $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n"
+                         "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec\n\n",
+                         "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
+                         "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
+                         "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule winebuildPRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c:\n"
+                      "\t${cp} $(NUL) $@ 1>$(NUL)\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                      "\t$(ECHO_CC)\n"
+                      "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.c",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).stubs.o",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule winebuildDefRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                        "\t$(ECHO_WINEBLD)\n"
+                        "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).auto.def --def -E $(source)\n\n",
+                        "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec",
+                        "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).auto.def",
+                        "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
 Rule winebuildRule (                      "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
                      "\t$(ECHO_WINEBLD)\n"
                      "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext)_$(module_name).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
@@ -1256,8 +1256,7 @@ MingwModuleHandler::GenerateCommands (
                { HostDontCare, TypeDontCare, ".asm", &nasmRule },
                { HostDontCare, TypeDontCare, ".rc", &windresRule },
                { HostDontCare, TypeDontCare, ".mc", &wmcRule },
-               { HostFalse, Kernel, ".spec", &winebuildKMRule },
-               { HostFalse, KernelModeDLL, ".spec", &winebuildKMRule },
+               { HostDontCare, TypeDontCare, ".pspec", &winebuildPRule },
                { HostDontCare, TypeDontCare, ".spec", &winebuildRule },
                { HostDontCare, RpcServer, ".idl", &widlServerRule },
                { HostDontCare, RpcClient, ".idl", &widlClientRule },
@@ -1856,7 +1855,7 @@ MingwModuleHandler::GenerateOtherMacros ()
                        used_defs );
        }
 
-       if ( IsWineModule() )
+       if ( IsSpecDefinitionFile() )
        {
                vector<FileLocation> s;
                GetSpecImplibDependencies ( s, module.importLibrary->source );
@@ -1988,6 +1987,8 @@ MingwModuleHandler::GenerateOtherMacros ()
 void
 MingwModuleHandler::GenerateRules ()
 {
+    SpecFileType spec;
+
        fprintf ( fMakefile, "# RULES\n" );
        string targetMacro = GetTargetMacro ( module );
        //CLEAN_FILE ( targetMacro );
@@ -2015,12 +2016,15 @@ MingwModuleHandler::GenerateRules ()
                delete ar_target;
        }
 
-       if ( IsWineModule() )
+
+    spec = IsSpecDefinitionFile();
+
+    if(spec)
        {
                Rule * defRule;
 
-               if ( module.type == Kernel || module.type == KernelModeDLL || module.type == KernelModeDriver )
-                       defRule = &winebuildKMDefRule;
+               if (spec == PSpec)
+                       defRule = &winebuildPDefRule;
                else
                        defRule = &winebuildDefRule;
 
@@ -2172,14 +2176,19 @@ MingwModuleHandler::GeneratePreconditionDependencies ()
        fprintf ( fMakefile, "\n" );
 }
 
-bool
-MingwModuleHandler::IsWineModule () const
+SpecFileType
+MingwModuleHandler::IsSpecDefinitionFile () const
 {
-       if ( module.importLibrary == NULL)
-               return false;
+    if(!module.importLibrary)
+        return None;
+
+    if(module.importLibrary->source->name.rfind(".spec") != string::npos)
+        return Spec;
+
+    if(module.importLibrary->source->name.rfind(".pspec") != string::npos)
+        return PSpec;
 
-       size_t index = module.importLibrary->source->name.rfind ( ".spec" );
-       return ( index != string::npos );
+    return None;
 }
 
 /* caller needs to delete the returned object */
@@ -2189,11 +2198,11 @@ MingwModuleHandler::GetDefinitionFilename () const
        if ( module.importLibrary == NULL )
                return NULL;
 
-       if ( IsWineModule () )
+       if ( IsSpecDefinitionFile () )
        {
                return new FileLocation ( IntermediateDirectory,
                                                                  module.importLibrary->source->relative_path,
-                                                                 GetBasename ( module.importLibrary->source->name ) + "_" + module.name + ".spec.def" );
+                                                                 GetBasename ( module.importLibrary->source->name ) + "_" + module.name + ".auto.def" );
        }
        else
        {
@@ -2268,7 +2277,7 @@ MingwModuleHandler::GetSpecImplibDependencies (
 {
        dependencies.push_back ( FileLocation ( IntermediateDirectory,
                                                                                        file->relative_path,
-                                                                                       GetBasename ( file->name ) + "_" + module.name + ".spec.def" ) );
+                                                                                       GetBasename ( file->name ) + "_" + module.name + ".auto.def" ) );
 }
 
 void
@@ -2316,9 +2325,11 @@ MingwModuleHandler::GetDefinitionDependencies (
                const CompilationUnit& compilationUnit = *compilationUnits[i];
                const FileLocation& sourceFile = compilationUnit.GetFilename ();
                string extension = GetExtension ( sourceFile );
-               if ( extension == ".spec" || extension == ".SPEC" )
+
+               if (extension == ".spec" || extension == ".pspec")
                        GetSpecObjectDependencies ( dependencies, &sourceFile );
-               if ( extension == ".idl" || extension == ".IDL" )
+
+               if (extension == ".idl")
                {
                        if ( ( module.type == RpcServer ) || ( module.type == RpcClient ) || ( module.type == RpcProxy ) )
                                GetWidlObjectDependencies ( dependencies, &sourceFile );
index 556cf5d..331335f 100644 (file)
@@ -32,6 +32,13 @@ PrefixFilename (
        const std::string& filename,
        const std::string& prefix );
 
+enum SpecFileType
+{
+    None,
+    Spec = 1,
+    PSpec = 2
+};
+
 class MingwModuleHandler
 {
 public:
@@ -150,7 +157,7 @@ private:
                                         const FileLocation *file ) const;
        void GetDefaultDependencies ( string_list& dependencies ) const;
        void GetInvocationDependencies ( const Module& module, string_list& dependencies );
-       bool IsWineModule () const;
+       SpecFileType IsSpecDefinitionFile () const;
        const FileLocation* GetDefinitionFilename () const;
        void GenerateBuildNonSymbolStrippedCode ();
        void CleanupCompilationUnitVector ( std::vector<CompilationUnit*>& compilationUnits );
index 0fa05c0..35d0311 100644 (file)
@@ -77,7 +77,7 @@ CompilationUnit::IsGeneratedFile () const
                return false;
        const File* file = files[0];
        string extension = GetExtension ( file->file );
-       return ( extension == ".spec" || extension == ".SPEC" || extension == ".mc" || extension == ".MC");
+       return ( extension == ".spec" || extension == ".pspec" || extension == ".mc");
 }
 
 bool