- Add specific properties to the keyboardlayout module type. They will assist us...
[reactos.git] / reactos / tools / rbuild / module.cpp
index f6e6341..b2b4958 100644 (file)
@@ -121,7 +121,6 @@ GetSubPath (
        const Project& project,
        const string& location,
        const string& path,
-       const XMLAttribute* root,
        const string& att_value )
 {
        if ( !att_value.size() )
@@ -135,28 +134,10 @@ GetSubPath (
        if ( !path.size() )
                return att_value;
 
-       string path_prefix;
-       if ( root )
-       {
-               if ( root->value == "intermediate" )
-                       path_prefix = Environment::GetIntermediatePath() + cSep;
-               else if ( root->value == "output" )
-                       path_prefix = Environment::GetOutputPath() + cSep;
-               else
-               {
-                       throw InvalidAttributeValueException (
-                               location,
-                               "root",
-                               root->value );
-               }
-       }
-       else
-               path_prefix = "";
-
-       return FixSeparator(path_prefix + path + cSep + att_value);
+       return FixSeparator(path + cSep + att_value);
 }
 
-string
+static string
 GetExtension ( const string& filename )
 {
        size_t index = filename.find_last_of ( '/' );
@@ -169,23 +150,9 @@ GetExtension ( const string& filename )
 }
 
 string
-GetDirectory ( const string& filename )
+GetExtension ( const FileLocation& file )
 {
-       size_t index = filename.find_last_of ( cSep );
-       if ( index == string::npos )
-               return "";
-       else
-               return filename.substr ( 0, index );
-}
-
-string
-GetFilename ( const string& filename )
-{
-       size_t index = filename.find_last_of ( cSep );
-       if ( index == string::npos )
-               return filename;
-       else
-               return filename.substr ( index + 1, filename.length () - index );
+       return GetExtension ( file.name );
 }
 
 string
@@ -216,6 +183,11 @@ ToLower ( string filename )
        return filename;
 }
 
+IfableData::IfableData( )
+       : asmFiles ( 0 )
+{
+}
+
 void IfableData::ExtractModules( std::vector<Module*> &modules )
 {
        size_t i;
@@ -269,6 +241,7 @@ Module::Module ( const Project& project,
        : project (project),
          node (moduleNode),
          importLibrary (NULL),
+         metadata (NULL),
          bootstrap (NULL),
          autoRegister(NULL),
          linkerScript (NULL),
@@ -281,13 +254,15 @@ Module::Module ( const Project& project,
                                                  __LINE__,
                                                  "Module created with non-<module> node" );
 
-       xmlbuildFile = Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename () );
+       xmlbuildFile = FixSeparator ( Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename () ) );
 
-       path = FixSeparator ( modulePath );
+       const XMLAttribute* att = moduleNode.GetAttribute ( "name", true );
+       assert(att);
+       name = att->value;
 
        enabled = true;
 
-       const XMLAttribute* att = moduleNode.GetAttribute ( "if", false );
+       att = moduleNode.GetAttribute ( "if", false );
        if ( att != NULL )
                enabled = GetBooleanValue ( project.ResolveProperties ( att->value ) );
 
@@ -295,9 +270,8 @@ Module::Module ( const Project& project,
        if ( att != NULL )
                enabled = !GetBooleanValue ( project.ResolveProperties ( att->value ) );
 
-       att = moduleNode.GetAttribute ( "name", true );
-       assert(att);
-       name = att->value;
+       if ( !enabled && project.configuration.Verbose )
+               printf("Module '%s' has been disabled.\n", name.c_str () );
 
        att = moduleNode.GetAttribute ( "type", true );
        assert(att);
@@ -328,25 +302,6 @@ Module::Module ( const Project& project,
        else
                isUnicode = false;
 
-       att = moduleNode.GetAttribute ( "stdlib", false );
-       if ( att != NULL )
-       {
-               const char* p = att->value.c_str();
-               if ( !stricmp ( p, "host" ) )
-                       useHostStdlib = true;
-               else if ( !stricmp ( p, "default" ) )
-                       useHostStdlib = false;
-               else
-               {
-                       throw InvalidAttributeValueException (
-                               moduleNode.location,
-                               "stdlib",
-                               att->value );
-               }
-       }
-       else
-               useHostStdlib = false;
-
        if (isUnicode)
        {
                // Always define UNICODE and _UNICODE
@@ -448,23 +403,28 @@ Module::Module ( const Project& project,
        if ( att != NULL )
                prefix = att->value;
 
-       att = moduleNode.GetAttribute ( "installbase", false );
-       if ( att != NULL )
-               installBase = att->value;
-       else
-               installBase = "";
-
        att = moduleNode.GetAttribute ( "installname", false );
        if ( att != NULL )
-               installName = att->value;
-       else
-               installName = "";
+       {
+               const XMLAttribute* installbase = moduleNode.GetAttribute ( "installbase", false );
+               install = new FileLocation ( InstallDirectory,
+                                            installbase ? installbase->value : "",
+                                            att->value,
+                                            &moduleNode );
 
-       att = moduleNode.GetAttribute ( "usewrc", false );
-       if ( att != NULL )
-               useWRC = att->value == "true";
+               output = new FileLocation ( GetTargetDirectoryTree (),
+                                           modulePath,
+                                           att->value,
+                                           &moduleNode );
+       }
        else
-               useWRC = true;
+       {
+               install = NULL;
+               output = new FileLocation ( GetTargetDirectoryTree (),
+                                           modulePath,
+                                           name + extension,
+                                           &moduleNode );
+       }
 
        att = moduleNode.GetAttribute ( "allowwarnings", false );
        if ( att == NULL )
@@ -492,6 +452,47 @@ Module::Module ( const Project& project,
                att = moduleNode.GetAttribute ( "payload", true );
                payload = att->value;
        }
+
+       if ( type == BootProgram || type == ElfExecutable )
+       {
+               att = moduleNode.GetAttribute ( "buildtype", false );
+               if ( att != NULL )
+               {
+                       buildtype = att->value;
+               }
+               else
+               {
+                       buildtype = "BOOTPROG";
+               }
+       }
+
+       att = moduleNode.GetAttribute ( "description", false );
+       if (att != NULL )
+       {
+               description = project.ResolveProperties(att->value);
+       }
+       else
+               description = "";
+
+       att = moduleNode.GetAttribute ( "lcid", false );
+       if (type == KeyboardLayout && att != NULL )
+               lcid = att->value;
+       else
+               lcid = "";
+
+       att = moduleNode.GetAttribute ( "layoutid", false );
+       if (type == KeyboardLayout && att != NULL )
+               layoutId = att->value;
+       else
+               layoutId = "";
+
+       att = moduleNode.GetAttribute ( "layoutnameresid", false );
+       if (type == KeyboardLayout && att != NULL )
+               layoutNameResId = att->value;
+       else
+               layoutNameResId = "";
+
+       SetImportLibrary ( NULL );
 }
 
 Module::~Module ()
@@ -511,6 +512,20 @@ Module::~Module ()
                delete linkerScript;
        if ( pch )
                delete pch;
+       if ( install )
+               delete install;
+       if ( metadata )
+               delete metadata;
+       if ( bootstrap )
+               delete bootstrap;
+       if ( importLibrary )
+               delete importLibrary;
+       if ( dependency )
+               delete  dependency;
+       if ( autoRegister )
+               delete autoRegister;
+       if ( output )
+               delete output;          
 }
 
 void
@@ -518,6 +533,7 @@ Module::ProcessXML()
 {
        if ( type == Alias )
        {
+               aliasedModuleName = project.ResolveProperties ( aliasedModuleName );
                if ( aliasedModuleName == name )
                {
                        throw XMLInvalidBuildFileException (
@@ -526,7 +542,7 @@ Module::ProcessXML()
                                name.c_str() );
                }
                const Module* m = project.LocateModule ( aliasedModuleName );
-               if ( !m )
+               if ( !m && enabled )
                {
                        throw XMLInvalidBuildFileException (
                                node.location,
@@ -540,7 +556,7 @@ Module::ProcessXML()
        for ( i = 0; i < node.subElements.size(); i++ )
        {
                ParseContext parseContext;
-               ProcessXMLSubElement ( *node.subElements[i], path, parseContext );
+               ProcessXMLSubElement ( *node.subElements[i], SourceDirectory, output->relative_path, parseContext );
        }
        for ( i = 0; i < invocations.size(); i++ )
                invocations[i]->ProcessXML ();
@@ -563,13 +579,15 @@ Module::ProcessXML()
 
 void
 Module::ProcessXMLSubElement ( const XMLElement& e,
-                               const string& path,
+                               DirectoryLocation directory,
+                                  const string& relative_path,
                                ParseContext& parseContext )
 {
        If* pOldIf = parseContext.ifData;
        CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
        bool subs_invalid = false;
-       string subpath ( path );
+       string subpath ( relative_path );
+       DirectoryLocation subdirectory = SourceDirectory;
        if ( e.name == "file" && e.value.size () > 0 )
        {
                bool first = false;
@@ -600,12 +618,14 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                        else if ( !stricmp ( ext.c_str(), ".cxx" ) )
                                cplusplus = true;
                }
-               File* pFile = new File ( FixSeparator ( path + cSep + e.value ),
+               File* pFile = new File ( directory,
+                                        relative_path,
+                                        e.value,
                                         first,
                                         switches,
                                         false );
                if ( parseContext.compilationUnit )
-                       parseContext.compilationUnit->files.push_back ( pFile );
+                       parseContext.compilationUnit->AddFile ( pFile );
                else
                {
                        CompilationUnit* pCompilationUnit = new CompilationUnit ( pFile );
@@ -613,11 +633,27 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                                parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit );
                        else
                        {
-                               string ext = GetExtension ( e.value );
-                               if ( !stricmp ( ext.c_str(), ".idl" ) )
-                                       non_if_data.compilationUnits.insert ( non_if_data.compilationUnits.begin(), pCompilationUnit );
-                               else
+                               string ext = ToLower ( GetExtension ( e.value ) );
+                               if ( ext == ".idl" )
+                               {
+                                       // put .idl files at the start of the module
+                                       non_if_data.compilationUnits.insert (
+                                               non_if_data.compilationUnits.begin(),
+                                               pCompilationUnit );
+                               }
+                               else if ( ext == ".asm" || ext == ".s" )
+                               {
+                                       // put .asm files at the end of the module
                                        non_if_data.compilationUnits.push_back ( pCompilationUnit );
+                                       non_if_data.asmFiles++;
+                               }
+                               else
+                               {
+                                       // put other files in the middle
+                                       non_if_data.compilationUnits.insert (
+                                               non_if_data.compilationUnits.end() - non_if_data.asmFiles,
+                                               pCompilationUnit );
+                               }
                        }
                }
                if ( parseContext.ifData )
@@ -638,13 +674,27 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        else if ( e.name == "directory" )
        {
                const XMLAttribute* att = e.GetAttribute ( "name", true );
-               const XMLAttribute* base = e.GetAttribute ( "root", false );
+               const XMLAttribute* root = e.GetAttribute ( "root", false );
                assert(att);
-               subpath = GetSubPath ( this->project, e.location, path, base, att->value );
+               if ( root )
+               {
+                       if ( root->value == "intermediate" )
+                               subdirectory = IntermediateDirectory;
+                       else if ( root->value == "output" )
+                               subdirectory = OutputDirectory;
+                       else
+                       {
+                               throw InvalidAttributeValueException (
+                                       e.location,
+                                       "root",
+                                       root->value );
+                       }
+               }
+               subpath = GetSubPath ( this->project, e.location, relative_path, att->value );
        }
        else if ( e.name == "include" )
        {
-               Include* include = new Include ( project, this, &e );
+               Include* include = new Include ( project, &e, this );
                if ( parseContext.ifData )
                        parseContext.ifData->data.includes.push_back ( include );
                else
@@ -660,6 +710,17 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                        non_if_data.defines.push_back ( pDefine );
                subs_invalid = true;
        }
+       else if ( e.name == "metadata" )
+       {
+               if ( parseContext.ifData )
+               {
+                       throw XMLInvalidBuildFileException (
+                               e.location,
+                               "<metadata> is not a valid sub-element of <if>" );
+               }
+               metadata = new Metadata ( e, *this );
+               subs_invalid = false;
+       }
        else if ( e.name == "invoke" )
        {
                if ( parseContext.ifData )
@@ -696,7 +757,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                                e.location,
                                "Only one <importlibrary> is valid per module" );
                }
-               importLibrary = new ImportLibrary ( e, *this );
+               SetImportLibrary ( new ImportLibrary ( project, e, *this ) );
                subs_invalid = true;
        }
        else if ( e.name == "if" )
@@ -733,13 +794,31 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }
        else if ( e.name == "linkerscript" )
        {
+               if ( parseContext.ifData )
+               {
+                       throw XMLInvalidBuildFileException (
+                               e.location,
+                               "<linkerscript> is not a valid sub-element of <if>" );
+               }
                if ( linkerScript )
                {
                        throw XMLInvalidBuildFileException (
                                e.location,
                                "Only one <linkerscript> is valid per module" );
                }
-               linkerScript = new LinkerScript ( project, this, e );
+               size_t pos = e.value.find_last_of ( "/\\" );
+               if ( pos == string::npos )
+               {
+                       linkerScript = new LinkerScript (
+                               e, *this, new FileLocation ( SourceDirectory, relative_path, e.value, &e ) );
+               }
+               else
+               {
+                       string dir = e.value.substr ( 0, pos );
+                       string name = e.value.substr ( pos + 1);
+                       linkerScript = new LinkerScript (
+                               e, *this, new FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) );
+               }
                subs_invalid = true;
        }
        else if ( e.name == "component" )
@@ -772,8 +851,19 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                                e.location,
                                "Only one <pch> is valid per module" );
                }
-               pch = new PchFile (
-                       e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) );
+               size_t pos = e.value.find_last_of ( "/\\" );
+               if ( pos == string::npos )
+               {
+                       pch = new PchFile (
+                               e, *this, new FileLocation ( SourceDirectory, relative_path, e.value, &e ) );
+               }
+               else
+               {
+                       string dir = e.value.substr ( 0, pos );
+                       string name = e.value.substr ( pos + 1);
+                       pch = new PchFile (
+                               e, *this, new FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) );
+               }
                subs_invalid = true;
        }
        else if ( e.name == "compilationunit" )
@@ -809,7 +899,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                        e.name.c_str() );
        }
        for ( size_t i = 0; i < e.subElements.size (); i++ )
-               ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
+               ProcessXMLSubElement ( *e.subElements[i], subdirectory, subpath, parseContext );
        parseContext.ifData = pOldIf;
        parseContext.compilationUnit = pOldCompilationUnit;
 }
@@ -821,6 +911,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
                return BuildTool;
        if ( attribute.value == "staticlibrary" )
                return StaticLibrary;
+       if ( attribute.value == "hoststaticlibrary" )
+               return HostStaticLibrary;
        if ( attribute.value == "objectlibrary" )
                return ObjectLibrary;
        if ( attribute.value == "kernel" )
@@ -833,6 +925,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
                return NativeDLL;
        if ( attribute.value == "nativecui" )
                return NativeCUI;
+       if ( attribute.value == "keyboardlayout" )
+               return KeyboardLayout;
        if ( attribute.value == "win32dll" )
                return Win32DLL;
        if ( attribute.value == "win32ocx" )
@@ -863,17 +957,70 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
                return RpcServer;
        if ( attribute.value == "rpcclient" )
                return RpcClient;
+       if ( attribute.value == "rpcproxy" )
+               return RpcProxy;
        if ( attribute.value == "alias" )
                return Alias;
        if ( attribute.value == "idlheader" )
                return IdlHeader;
        if ( attribute.value == "embeddedtypelib" )
                return EmbeddedTypeLib;
+       if ( attribute.value == "elfexecutable" )
+               return ElfExecutable;
+       if ( attribute.value == "cabinet" )
+               return Cabinet;
        throw InvalidAttributeValueException ( location,
                                               attribute.name,
                                               attribute.value );
 }
 
+DirectoryLocation
+Module::GetTargetDirectoryTree () const
+{
+       switch ( type )
+       {
+               case Kernel:
+               case KernelModeDLL:
+               case KeyboardLayout:
+               case NativeDLL:
+               case Win32DLL:
+               case Win32OCX:
+               case KernelModeDriver:
+               case NativeCUI:
+               case Win32CUI:
+               case Test:
+               case Win32SCR:
+               case Win32GUI:
+               case BuildTool:
+               case BootLoader:
+               case BootSector:
+               case BootProgram:
+               case Iso:
+               case LiveIso:
+               case IsoRegTest:
+               case LiveIsoRegTest:
+               case ElfExecutable:
+               case Cabinet:
+                       return OutputDirectory;
+               case EmbeddedTypeLib:
+               case StaticLibrary:
+               case HostStaticLibrary:
+               case ObjectLibrary:
+               case RpcServer:
+               case RpcClient:
+               case RpcProxy:
+               case Alias:
+               case IdlHeader:
+                       return IntermediateDirectory;
+               case TypeDontCare:
+                       break;
+       }
+       throw InvalidOperationException ( __FILE__,
+                                         __LINE__,
+                                         "Invalid module type %d.",
+                                         type );
+}
+
 string
 Module::GetDefaultModuleExtension () const
 {
@@ -881,7 +1028,9 @@ Module::GetDefaultModuleExtension () const
        {
                case BuildTool:
                        return ExePostfix;
+               case BootProgram:
                case StaticLibrary:
+               case HostStaticLibrary:
                        return ".a";
                case ObjectLibrary:
                        return ".o";
@@ -895,6 +1044,7 @@ Module::GetDefaultModuleExtension () const
 
                case KernelModeDLL:
                case NativeDLL:
+               case KeyboardLayout:
                case Win32DLL:
                        return ".dll";
                case Win32OCX:
@@ -902,6 +1052,8 @@ Module::GetDefaultModuleExtension () const
                case KernelModeDriver:
                case BootLoader:
                        return ".sys";
+               case Cabinet:
+                       return ".cab";
                case BootSector:
                        return ".o";
                case Iso:
@@ -912,15 +1064,17 @@ Module::GetDefaultModuleExtension () const
                case Test:
                        return ".exe";
                case RpcServer:
-                       return ".o";
                case RpcClient:
+               case RpcProxy:
                        return ".o";
                case Alias:
-               case BootProgram:
+               case ElfExecutable:
                case IdlHeader:
                        return "";
                case EmbeddedTypeLib:
                        return ".tlb";
+               case TypeDontCare:
+                       break;
        }
        throw InvalidOperationException ( __FILE__,
                                          __LINE__ );
@@ -932,7 +1086,8 @@ Module::GetDefaultModuleEntrypoint () const
        switch ( type )
        {
                case Kernel:
-                       return "NtProcessStartup";
+                       return "KiSystemStartup";
+               case KeyboardLayout:
                case KernelModeDLL:
                case KernelModeDriver:
                        return "DriverEntry@8";
@@ -957,6 +1112,7 @@ Module::GetDefaultModuleEntrypoint () const
                                return "WinMainCRTStartup";
                case BuildTool:
                case StaticLibrary:
+               case HostStaticLibrary:
                case ObjectLibrary:
                case BootLoader:
                case BootSector:
@@ -966,11 +1122,16 @@ Module::GetDefaultModuleEntrypoint () const
                case LiveIsoRegTest:
                case RpcServer:
                case RpcClient:
+               case RpcProxy:
                case Alias:
                case BootProgram:
                case IdlHeader:
+               case ElfExecutable:
                case EmbeddedTypeLib:
+               case Cabinet:
                        return "";
+               case TypeDontCare:
+                       break;
        }
        throw InvalidOperationException ( __FILE__,
                                          __LINE__ );
@@ -982,7 +1143,7 @@ Module::GetDefaultModuleBaseaddress () const
        switch ( type )
        {
                case Kernel:
-                       return "0x80000000";
+                       return "0x80800000";
                case Win32DLL:
                case Win32OCX:
                        return "0x10000000";
@@ -994,11 +1155,15 @@ Module::GetDefaultModuleBaseaddress () const
                case Win32SCR:
                case Win32GUI:
                        return "0x00400000";
+               case KeyboardLayout:
                case KernelModeDLL:
                case KernelModeDriver:
                        return "0x00010000";
+               case ElfExecutable:
+                       return "0xe00000";
                case BuildTool:
                case StaticLibrary:
+               case HostStaticLibrary:
                case ObjectLibrary:
                case BootLoader:
                case BootSector:
@@ -1008,11 +1173,15 @@ Module::GetDefaultModuleBaseaddress () const
                case LiveIsoRegTest:
                case RpcServer:
                case RpcClient:
+               case RpcProxy:
                case Alias:
                case BootProgram:
                case IdlHeader:
                case EmbeddedTypeLib:
+               case Cabinet:
                        return "";
+               case TypeDontCare:
+                       break;
        }
        throw InvalidOperationException ( __FILE__,
                                          __LINE__ );
@@ -1021,7 +1190,7 @@ Module::GetDefaultModuleBaseaddress () const
 bool
 Module::HasImportLibrary () const
 {
-       return importLibrary != NULL && type != StaticLibrary;
+       return importLibrary != NULL && type != StaticLibrary && type != HostStaticLibrary;
 }
 
 bool
@@ -1032,6 +1201,7 @@ Module::IsDLL () const
                case Kernel:
                case KernelModeDLL:
                case NativeDLL:
+               case KeyboardLayout:
                case Win32DLL:
                case Win32OCX:
                case KernelModeDriver:
@@ -1043,6 +1213,7 @@ Module::IsDLL () const
                case Win32GUI:
                case BuildTool:
                case StaticLibrary:
+               case HostStaticLibrary:
                case ObjectLibrary:
                case BootLoader:
                case BootSector:
@@ -1053,93 +1224,30 @@ Module::IsDLL () const
                case LiveIsoRegTest:
                case RpcServer:
                case RpcClient:
+               case RpcProxy:
                case Alias:
                case IdlHeader:
                case EmbeddedTypeLib:
+               case ElfExecutable:
+               case Cabinet:
                        return false;
+               case TypeDontCare:
+                       break;
        }
        throw InvalidOperationException ( __FILE__,
                                          __LINE__ );
 }
 
-bool
-Module::GenerateInOutputTree () const
-{
-       switch ( type )
-       {
-               case Kernel:
-               case KernelModeDLL:
-               case NativeDLL:
-               case Win32DLL:
-               case Win32OCX:
-               case KernelModeDriver:
-               case NativeCUI:
-               case Win32CUI:
-               case Test:
-               case Win32SCR:
-               case Win32GUI:
-               case BuildTool:
-               case BootLoader:
-               case BootSector:
-               case BootProgram:
-               case Iso:
-               case LiveIso:
-               case IsoRegTest:
-               case LiveIsoRegTest:
-               case EmbeddedTypeLib:
-                       return true;
-               case StaticLibrary:
-               case ObjectLibrary:
-               case RpcServer:
-               case RpcClient:
-               case Alias:
-               case IdlHeader:
-                       return false;
-       }
-       throw InvalidOperationException ( __FILE__,
-                                         __LINE__ );
-}
-
-string
-Module::GetTargetName () const
-{
-       return name + extension;
-}
-
-string
-Module::GetDependencyPath () const
-{
-       if ( HasImportLibrary () )
-               return ReplaceExtension ( GetPathWithPrefix ( "lib" ), ".a" );
-       else
-               return GetPath();
-}
-
-string
-Module::GetBasePath () const
-{
-       return path;
-}
-
-string
-Module::GetPath () const
-{
-       if ( path.length() > 0 )
-               return path + cSep + GetTargetName ();
-       else
-               return GetTargetName ();
-}
-
 string
 Module::GetPathWithPrefix ( const string& prefix ) const
 {
-       return path + cSep + prefix + GetTargetName ();
+       return output->relative_path + cSep + prefix + output->name;
 }
 
 string
 Module::GetPathToBaseDir () const
 {
-       string temp_path = path;
+       string temp_path = output->relative_path;
        string result = "..\\";
        while(temp_path.find ('\\') != string::npos)
        {
@@ -1196,7 +1304,7 @@ Module::InvokeModule () const
        for ( size_t i = 0; i < invocations.size (); i++ )
        {
                Invoke& invoke = *invocations[i];
-               string command = FixSeparatorForSystemCommand(invoke.invokeModule->GetPath ()) + " " + invoke.GetParameters ();
+               string command = FixSeparatorForSystemCommand(invoke.invokeModule->output->relative_path + "/" + invoke.invokeModule->output->name ) + " " + invoke.GetParameters ();
                printf ( "Executing '%s'\n\n", command.c_str () );
                int exitcode = system ( command.c_str () );
                if ( exitcode != 0 )
@@ -1206,22 +1314,61 @@ Module::InvokeModule () const
 }
 
 
-File::File ( const string& _name, bool _first,
-             std::string _switches,
+void
+Module::SetImportLibrary ( ImportLibrary* importLibrary )
+{
+       this->importLibrary = importLibrary;
+       dependency = new FileLocation ( HasImportLibrary () ? IntermediateDirectory : output->directory,
+                                       output->relative_path,
+                                       HasImportLibrary () ? "lib" + name + ".a" : output->name );
+}
+
+
+File::File ( DirectoryLocation directory,
+             const string& relative_path,
+             const string& name,
+             bool _first,
+             const string& _switches,
              bool _isPreCompiledHeader )
-       : name(_name),
+       : file ( directory, relative_path, name ),
          first(_first),
          switches(_switches),
          isPreCompiledHeader(_isPreCompiledHeader)
 {
 }
 
+
 void
 File::ProcessXML()
 {
 }
 
 
+std::string File::GetFullPath () const
+{
+       string directory ( "" );
+       switch ( file.directory )
+       {
+               case SourceDirectory:
+                       break;
+               case IntermediateDirectory:
+                       directory = Environment::GetIntermediatePath () + sSep;
+                       break;
+               default:
+                       throw InvalidOperationException ( __FILE__,
+                                                         __LINE__,
+                                                         "Invalid directory %d.",
+                                                         file.directory );
+       }
+
+       if ( file.relative_path.length () > 0 )
+               directory += file.relative_path + sSep;
+
+
+       return directory + file.name;
+}
+
+
 Library::Library ( const XMLElement& _node,
                    const Module& _module,
                    const string& _name )
@@ -1330,7 +1477,7 @@ Invoke::ProcessXMLSubElementInput ( const XMLElement& e )
        if ( e.name == "inputfile" && e.value.size () > 0 )
        {
                input.push_back ( new InvokeFile (
-                       e, FixSeparator ( module.path + cSep + e.value ) ) );
+                       e, FixSeparator ( module.output->relative_path + cSep + e.value ) ) );
                subs_invalid = true;
        }
        if ( subs_invalid && e.subElements.size() > 0 )
@@ -1349,7 +1496,7 @@ Invoke::ProcessXMLSubElementOutput ( const XMLElement& e )
        if ( e.name == "outputfile" && e.value.size () > 0 )
        {
                output.push_back ( new InvokeFile (
-                       e, FixSeparator ( module.path + cSep + e.value ) ) );
+                       e, FixSeparator ( module.output->relative_path + cSep + e.value ) ) );
                subs_invalid = true;
        }
        if ( subs_invalid && e.subElements.size() > 0 )
@@ -1446,35 +1593,106 @@ Dependency::ProcessXML()
 }
 
 
-ImportLibrary::ImportLibrary ( const XMLElement& _node,
-                               const Module& _module )
+Metadata::Metadata ( const XMLElement& _node,
+                     const Module& _module )
        : node (_node),
          module (_module)
 {
-       const XMLAttribute* att = _node.GetAttribute ( "basename", false );
+       /* The module name */
+       const XMLAttribute* att = _node.GetAttribute ( "name", false );
        if (att != NULL)
-               basename = att->value;
+               name = att->value;
        else
-               basename = module.name;
+               name = module.name;
 
-       att = _node.GetAttribute ( "dllname", false );
+       /* The module description */
+       att = _node.GetAttribute ( "description", false );
        if (att != NULL)
-               dllname = att->value;
+               description = att->value;
        else
-       {
-               if ( _module.type == StaticLibrary )
-               {
-                       throw XMLInvalidBuildFileException (
-                           node.location,
-                           "<importlibrary> dllname attribute required." );
-               }
+               description = "";
 
-               dllname = "";
-       }
+       /* The module version */
+       att = _node.GetAttribute ( "version", false );
+       if (att != NULL)
+               version = att->value;
+       else
+               version = "";
+
+       /* The module copyright */
+       att = _node.GetAttribute ( "copyright", false );
+       if (att != NULL)
+               copyright = att->value;
+       else
+               copyright = "";
+
+       att = _node.GetAttribute ( "url", false );
+       if (att != NULL)
+               url = att->value;
+       else
+               url = "";
 
-       att = _node.GetAttribute ( "definition", true );
-       assert (att);
-       definition = FixSeparator(att->value);
+       /* When was this module updated */
+       att = _node.GetAttribute ( "date", false );
+       if (att != NULL)
+               date = att->value;
+       else
+               date = "?";
+
+       /* When was this module updated */
+       att = _node.GetAttribute ( "owner", false );
+       if (att != NULL)
+               owner = att->value;
+       else
+               owner = "ReactOS";
+}
+
+
+ImportLibrary::~ImportLibrary ()
+{
+       delete source;
+}
+
+
+ImportLibrary::ImportLibrary ( const Project& project,
+                               const XMLElement& node,
+                               const Module& module )
+       : XmlNode ( project, node ),
+         module (module)
+{
+       const XMLAttribute* dllname = node.GetAttribute ( "dllname", false );
+       const XMLAttribute* definition = node.GetAttribute ( "definition", true );
+       assert ( definition );
+
+       if ( dllname )
+               this->dllname = dllname->value;
+       else if ( module.type == StaticLibrary || module.type == HostStaticLibrary )
+               throw XMLInvalidBuildFileException (
+                   node.location,
+                   "<importlibrary> dllname attribute required." );
+
+       DirectoryLocation directory = SourceDirectory;
+       size_t index = definition->value.rfind ( ".spec.def" );
+       if ( index != string::npos )
+               directory = IntermediateDirectory;
+
+       index = definition->value.find_last_of ( "/\\" );
+       if ( index == string::npos )
+       {
+               source = new FileLocation ( directory,
+                                           module.output->relative_path,
+                                           definition->value,
+                                           &node );
+       }
+       else
+       {
+               string dir = definition->value.substr ( 0, index );
+               string name = definition->value.substr ( index + 1);
+               source = new FileLocation ( directory,
+                                           NormalizeFilename ( module.output->relative_path + sSep + dir ),
+                                           name,
+                                           &node );
+       }
 }
 
 
@@ -1509,17 +1727,44 @@ If::ProcessXML()
 Property::Property ( const XMLElement& node_,
                      const Project& project_,
                      const Module* module_ )
-       : node(node_), project(project_), module(module_)
+       : project(project_), module(module_)
 {
        const XMLAttribute* att;
 
-       att = node.GetAttribute ( "name", true );
+       att = node_.GetAttribute ( "name", true );
        assert(att);
-       name = att->value;
+       name = project.ResolveProperties ( att->value );
 
-       att = node.GetAttribute ( "value", true );
+       att = node_.GetAttribute ( "value", true );
        assert(att);
        value = att->value;
+
+       att = node_.GetAttribute ( "internal", false );
+       if ( att != NULL )
+       {
+               const char* p = att->value.c_str();
+               if ( !stricmp ( p, "true" ) || !stricmp ( p, "yes" ) )
+                       isInternal = true;
+               else if ( !stricmp ( p, "false" ) || !stricmp ( p, "no" ) )
+                       isInternal = false;
+               else
+               {
+                       throw InvalidAttributeValueException (
+                               node_.location,
+                               "internal",
+                               att->value );
+               }
+       }
+       else
+               isInternal = false;
+}
+
+Property::Property ( const Project& project_,
+                     const Module* module_,
+                     const std::string& name_,
+                     const std::string& value_ )
+       : project(project_), module(module_), name(name_), value(value_)
+{
 }
 
 void
@@ -1531,101 +1776,17 @@ Property::ProcessXML()
 PchFile::PchFile (
        const XMLElement& node_,
        const Module& module_,
-       const File file_ )
+       const FileLocation *file_ )
        : node(node_), module(module_), file(file_)
 {
 }
 
-void
-PchFile::ProcessXML()
-{
-}
-
-
-AutoRegister::AutoRegister ( const Project& project_,
-                             const Module* module_,
-                             const XMLElement& node_ )
-       : project(project_),
-         module(module_),
-         node(node_)
+PchFile::~PchFile()
 {
-       Initialize();
-}
-
-AutoRegister::~AutoRegister ()
-{
-}
-
-bool
-AutoRegister::IsSupportedModuleType ( ModuleType type )
-{
-       switch ( type )
-       {
-               case Win32DLL:
-               case Win32OCX:
-                       return true;
-               case Kernel:
-               case KernelModeDLL:
-               case NativeDLL:
-               case NativeCUI:
-               case Win32CUI:
-               case Win32GUI:
-               case Win32SCR:
-               case KernelModeDriver:
-               case BootSector:
-               case BootLoader:
-               case BootProgram:
-               case BuildTool:
-               case StaticLibrary:
-               case ObjectLibrary:
-               case Iso:
-               case LiveIso:
-               case IsoRegTest:
-               case LiveIsoRegTest:
-               case Test:
-               case RpcServer:
-               case RpcClient:
-               case Alias:
-               case IdlHeader:
-               case EmbeddedTypeLib:
-                       return false;
-       }
-       throw InvalidOperationException ( __FILE__,
-                                         __LINE__ );
-}
-
-AutoRegisterType
-AutoRegister::GetAutoRegisterType( string type )
-{
-       if ( type == "DllRegisterServer" )
-               return DllRegisterServer;
-       if ( type == "DllInstall" )
-               return DllInstall;
-       if ( type == "Both" )
-               return Both;
-       throw XMLInvalidBuildFileException (
-               node.location,
-               "<autoregister> type attribute must be DllRegisterServer, DllInstall or Both." );
-}
-
-void
-AutoRegister::Initialize ()
-{
-       if ( !IsSupportedModuleType ( module->type ) )
-       {
-               throw XMLInvalidBuildFileException (
-                       node.location,
-                       "<autoregister> is not applicable for this module type." );
-       }
-
-       const XMLAttribute* att = node.GetAttribute ( "infsection", true );
-       infSection = att->value;
-
-       att = node.GetAttribute ( "type", true );
-       type = GetAutoRegisterType ( att->value );
+       delete file;
 }
 
 void
-AutoRegister::ProcessXML()
+PchFile::ProcessXML()
 {
 }