Move some more autogenerated files to intermediate directory
[reactos.git] / reactos / tools / rbuild / project.cpp
index a705c30..d68d4ac 100644 (file)
@@ -49,24 +49,44 @@ Environment::GetEnvironmentVariablePathOrDefault ( const string& name,
 /* static */ string
 Environment::GetIntermediatePath ()
 {
+       string defaultIntermediate =
+               string( "obj-" ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "i386" );
        return GetEnvironmentVariablePathOrDefault ( "ROS_INTERMEDIATE",
-                                                    "obj-i386" );
+                                                    defaultIntermediate );
 }
 
 /* static */ string
 Environment::GetOutputPath ()
 {
+       string defaultOutput =
+               string( "output-" ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "i386" );
        return GetEnvironmentVariablePathOrDefault ( "ROS_OUTPUT",
-                                                    "output-i386" );
+                                                    defaultOutput );
 }
 
 /* static */ string
 Environment::GetInstallPath ()
 {
+       string defaultInstall =
+               string( "reactos." ) + GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT", "" );
        return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
+                                                    defaultInstall );
+}
+
+/* static */ string
+Environment::GetCdOutputPath ()
+{
+       return GetEnvironmentVariablePathOrDefault ( "ROS_CDOUTPUT",
                                                     "reactos" );
 }
 
+/* static */ string
+Environment::GetAutomakeFile ( const std::string& defaultFile )
+{
+       return GetEnvironmentVariablePathOrDefault ( "ROS_AUTOMAKE",
+                                                    defaultFile );
+}
+
 ParseContext::ParseContext ()
        : ifData (NULL),
          compilationUnit (NULL)
@@ -89,6 +109,7 @@ Project::Project ( const Configuration& configuration,
          head (NULL),
          configuration (configuration)
 {
+       _backend = NULL;
        ReadXml();
 }
 
@@ -219,7 +240,7 @@ Project::WriteConfigurationFile ()
 
        s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
 
-       FileSupportCode::WriteIfChanged ( buf, "include" + sSep + "roscfg.h" );
+       FileSupportCode::WriteIfChanged ( buf, Environment::GetIntermediatePath() + sSep + "include" + sSep + "roscfg.h" );
 
        free ( buf );
 }
@@ -227,7 +248,6 @@ Project::WriteConfigurationFile ()
 void
 Project::ExecuteInvocations ()
 {
-       fprintf( stderr, "ExecuteInvocations\n" );
        for ( size_t i = 0; i < modules.size (); i++ )
                modules[i]->InvokeModule ();
 }
@@ -244,7 +264,7 @@ Project::ReadXml ()
                {
                        node = head->subElements[i];
                        string path;
-                       this->ProcessXML ( path );
+                       ProcessXML ( path );
                        return;
                }
        }
@@ -272,7 +292,7 @@ Project::ProcessXML ( const string& path )
 
        att = node->GetAttribute ( "makefile", true );
        assert(att);
-       makefile = att->value;
+       makefile = Environment::GetAutomakeFile ( att->value );
 
        size_t i;
        for ( i = 0; i < node->subElements.size (); i++ )
@@ -303,6 +323,7 @@ Project::ProcessXML ( const string& path )
                        If * if_data = non_if_data.ifs[i];
                        non_if_data.ifs.erase ( non_if_data.ifs.begin () + i );
                        delete if_data;
+                       i--;
                }
        }
        for ( i = 0; i < linkerFlags.size (); i++ )
@@ -354,8 +375,9 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
        else if ( e.name == "directory" )
        {
                const XMLAttribute* att = e.GetAttribute ( "name", true );
+               const XMLAttribute* base = e.GetAttribute ( "root", false );
                assert(att);
-               subpath = GetSubPath ( e.location, path, att->value );
+               subpath = GetSubPath ( *this, e.location, path, base, att->value );
        }
        else if ( e.name == "include" )
        {
@@ -452,7 +474,7 @@ Project::LocateModule ( const string& name ) const
        return NULL;
 }
 
-std::string
+const std::string&
 Project::GetProjectFilename () const
 {
        return xmlfile;