From: Casper Hornstrup Date: Wed, 23 Nov 2005 03:12:52 +0000 (+0000) Subject: Option to disable compilation units X-Git-Tag: backups/ros-branch-0_2_9@19949~451 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=4758974147db735715df37f347ef1753ba7bf723 Option to disable compilation units svn path=/trunk/; revision=19477 --- diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 42876579cc9..0a17635d189 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -527,10 +527,13 @@ MingwBackend::GenerateTestSupportCode () void MingwBackend::GenerateCompilationUnitSupportCode () { - printf ( "Generating compilation unit support code..." ); - CompilationUnitSupportCode compilationUnitSupportCode ( ProjectNode ); - compilationUnitSupportCode.Generate ( configuration.Verbose ); - printf ( "done\n" ); + if ( configuration.CompilationUnitsEnabled ) + { + printf ( "Generating compilation unit support code..." ); + CompilationUnitSupportCode compilationUnitSupportCode ( ProjectNode ); + compilationUnitSupportCode.Generate ( configuration.Verbose ); + printf ( "done\n" ); + } } string diff --git a/reactos/tools/rbuild/compilationunitsupportcode.cpp b/reactos/tools/rbuild/compilationunitsupportcode.cpp index c7541abdad6..7bb8cd805c1 100644 --- a/reactos/tools/rbuild/compilationunitsupportcode.cpp +++ b/reactos/tools/rbuild/compilationunitsupportcode.cpp @@ -83,12 +83,12 @@ CompilationUnitSupportCode::WriteCompilationUnitFile ( Module& module, s = s + sprintf ( s, "/* This file is automatically generated. */\n" ); s = s + sprintf ( s, "#define ONE_COMPILATION_UNIT\n" ); if ( module.pch ) - s = s + sprintf ( s, "#include <%s>\n", NormalizeFilename ( module.pch->file.name ).c_str () ); + s = s + sprintf ( s, "#include <%s>\n", ChangeSeparator ( module.pch->file.name, '\\', '/' ).c_str () ); for ( size_t i = 0; i < compilationUnit.files.size () ; i++ ) { File& file = *compilationUnit.files[i]; - s = s + sprintf ( s, "#include \"%s\"\n", file.name.c_str () ); + s = s + sprintf ( s, "#include <%s>\n", ChangeSeparator ( file.name, '\\', '/' ).c_str () ); } s = s + sprintf ( s, "\n" ); diff --git a/reactos/tools/rbuild/configuration.cpp b/reactos/tools/rbuild/configuration.cpp index 6964d410075..f384f181bc2 100644 --- a/reactos/tools/rbuild/configuration.cpp +++ b/reactos/tools/rbuild/configuration.cpp @@ -26,6 +26,7 @@ Configuration::Configuration () CleanAsYouGo = false; AutomaticDependencies = true; CheckDependenciesForModuleOnly = false; + CompilationUnitsEnabled = true; MakeHandlesInstallDirectories = false; GenerateProxyMakefilesInSourceTree = false; } diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 8ada94d8da1..7c1a710d013 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -52,18 +52,26 @@ Replace ( const string& s, const string& find, const string& with ) } string -FixSeparator ( const string& s ) +ChangeSeparator ( const string& s, + const char fromSeparator, + const char toSeparator ) { string s2(s); - char* p = strchr ( &s2[0], cBadSep ); + char* p = strchr ( &s2[0], fromSeparator ); while ( p ) { - *p++ = cSep; - p = strchr ( p, cBadSep ); + *p++ = toSeparator; + p = strchr ( p, fromSeparator ); } return s2; } +string +FixSeparator ( const string& s ) +{ + return ChangeSeparator ( s, cBadSep, cSep ); +} + string FixSeparatorForSystemCommand ( const string& s ) { @@ -627,12 +635,15 @@ Module::ProcessXMLSubElement ( const XMLElement& e, } else if ( e.name == "compilationunit" ) { - CompilationUnit* pCompilationUnit = new CompilationUnit ( &project, this, &e ); - if ( parseContext.ifData ) - parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit ); - else - non_if_data.compilationUnits.push_back ( pCompilationUnit ); - parseContext.compilationUnit = pCompilationUnit; + if ( project.configuration.CompilationUnitsEnabled ) + { + CompilationUnit* pCompilationUnit = new CompilationUnit ( &project, this, &e ); + if ( parseContext.ifData ) + parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit ); + else + non_if_data.compilationUnits.push_back ( pCompilationUnit ); + parseContext.compilationUnit = pCompilationUnit; + } subs_invalid = false; } if ( subs_invalid && e.subElements.size() > 0 ) diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index e796dd84674..bb215c72618 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -81,11 +81,13 @@ FileLocation::FileLocation ( Directory* directory, } -Project::Project ( const string& filename ) +Project::Project ( const Configuration& configuration, + const string& filename ) : xmlfile (filename), node (NULL), - head (NULL) -{ + head (NULL), + configuration (configuration) +{ ReadXml(); } diff --git a/reactos/tools/rbuild/rbuild.cpp b/reactos/tools/rbuild/rbuild.cpp index 00e685b6b6c..0b041c710bd 100644 --- a/reactos/tools/rbuild/rbuild.cpp +++ b/reactos/tools/rbuild/rbuild.cpp @@ -61,6 +61,22 @@ ParseAutomaticDependencySwitch ( char switchChar2, return true; } +bool +ParseCompilationUnitSwitch ( char switchChar2, + char* switchStart ) +{ + switch ( switchChar2 ) + { + case 'd': + configuration.CompilationUnitsEnabled = false; + break; + default: + printf ( "Unknown switch -u%c\n", + switchChar2 ); + return false; + } + return true; +} bool ParseVCProjectSwitch ( char switchChar2, @@ -148,6 +164,9 @@ ParseSwitch ( int argc, char** argv, int index ) case 'd': return ParseAutomaticDependencySwitch ( switchChar2, argv[index] ); + case 'u': + return ParseCompilationUnitSwitch ( switchChar2, + argv[index] ); case 'r': RootXmlFile = string(&argv[index][2]); break; @@ -196,9 +215,10 @@ main ( int argc, char** argv ) printf ( " -v Be verbose.\n" ); printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" ); printf ( " needed anymore.\n" ); + printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" ); printf ( " -dd Disable automatic dependencies.\n" ); printf ( " -dm{module} Check only automatic dependencies for this module.\n" ); - printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" ); + printf ( " -ud Disable multiple source files per compilation unit.\n" ); printf ( " -mi Let make handle creation of install directories. Rbuild will\n" ); printf ( " not generate the directories.\n" ); printf ( " -ps Generate proxy makefiles in source tree instead of the output.\n" ); @@ -215,7 +235,7 @@ main ( int argc, char** argv ) { string projectFilename ( RootXmlFile ); printf ( "Reading build files..." ); - Project project ( projectFilename ); + Project project ( configuration, projectFilename ); printf ( "done\n" ); project.WriteConfigurationFile (); project.ExecuteInvocations (); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index e3d9c4d0f5c..80357cf516b 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -133,6 +133,7 @@ public: bool CleanAsYouGo; bool AutomaticDependencies; bool CheckDependenciesForModuleOnly; + bool CompilationUnitsEnabled; std::string CheckDependenciesForModuleOnlyModule; std::string VSProjectVersion; bool MakeHandlesInstallDirectories; @@ -189,6 +190,7 @@ class Project std::string xmlfile; XMLElement *node, *head; public: + const Configuration& configuration; std::string name; std::string makefile; XMLIncludes xmlbuildfiles; @@ -198,7 +200,8 @@ public: std::vector installfiles; IfableData non_if_data; - Project ( const std::string& filename ); + Project ( const Configuration& configuration, + const std::string& filename ); ~Project (); void WriteConfigurationFile (); void ExecuteInvocations (); @@ -872,6 +875,11 @@ Right ( const std::string& s, size_t n ); extern std::string Replace ( const std::string& s, const std::string& find, const std::string& with ); +extern std::string +ChangeSeparator ( const std::string& s, + const char fromSeparator, + const char toSeparator ); + extern std::string FixSeparator ( const std::string& s );