Author: hpoussin Date: Mon Aug 6 13:19:25 2007 New Revision: 28188
URL: http://svn.reactos.org/svn/reactos?rev=28188&view=rev Log: Add -D option to add variables in generated file
Modified: trunk/reactos/tools/rbuild/module.cpp trunk/reactos/tools/rbuild/project.cpp trunk/reactos/tools/rbuild/rbuild.cpp trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/tools/rbuild/module.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?rev... ============================================================================== --- trunk/reactos/tools/rbuild/module.cpp (original) +++ trunk/reactos/tools/rbuild/module.cpp Mon Aug 6 13:19:25 2007 @@ -1509,17 +1509,25 @@ 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;
- att = node.GetAttribute ( "value", true ); + att = node_.GetAttribute ( "value", true ); assert(att); value = att->value; +} + +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
Modified: trunk/reactos/tools/rbuild/project.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/project.cpp?re... ============================================================================== --- trunk/reactos/tools/rbuild/project.cpp (original) +++ trunk/reactos/tools/rbuild/project.cpp Mon Aug 6 13:19:25 2007 @@ -103,13 +103,29 @@
Project::Project ( const Configuration& configuration, - const string& filename ) + const string& filename, + const std::map<std::string, std::string>* properties ) : xmlfile (filename), node (NULL), head (NULL), configuration (configuration) { _backend = NULL; + + if ( properties ) + { + std::map<string, string>::const_iterator it; + for (it = properties->begin (); it != properties->end (); it++) + { + const Property *existing = LookupProperty( it->first ); + if ( !existing ) + { + Property* property = new Property ( *this, NULL, it->first, it->second ); + non_if_data.properties.push_back (property ); + } + } + } + ReadXml(); }
Modified: trunk/reactos/tools/rbuild/rbuild.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.cpp?rev... ============================================================================== --- trunk/reactos/tools/rbuild/rbuild.cpp (original) +++ trunk/reactos/tools/rbuild/rbuild.cpp Mon Aug 6 13:19:25 2007 @@ -35,6 +35,7 @@ static string BuildSystem; static string RootXmlFile; static Configuration configuration; +static std::map<string, string> properties;
bool ParseAutomaticDependencySwitch ( @@ -164,6 +165,28 @@ switchChar2 ); return false; } + return true; +} + +bool +ParseDefineSwitch ( char* switchStart ) +{ + string s = string ( switchStart + 2 ); + string::size_type separator = s.find ( '=' ); + if ( separator == string::npos || separator == 0 ) + { + printf ( "Invalid define switch: '%s'\n", switchStart ); + return false; + } + if ( s.find ( '=', separator + 1 ) != string::npos ) + { + printf ( "Invalid define switch: '%s'\n", switchStart ); + return false; + } + + string var = s.substr ( 0, separator ); + string val = s.substr ( separator + 1 ); + properties.insert ( std::pair<string, string> ( var, val ) ); return true; }
@@ -202,6 +225,8 @@ return ParseMakeSwitch ( switchChar2 ); case 'p': return ParseProxyMakefileSwitch ( switchChar2 ); + case 'D': + return ParseDefineSwitch ( argv[index] ); default: printf ( "Unknown switch -%c\n", @@ -253,6 +278,7 @@ printf ( " tree.\n" ); printf ( " -vs{version} Version of MS VS project files. Default is %s.\n", MS_VS_DEF_VERSION ); printf ( " -vo{version|configuration} Adds subdirectory path to the default Intermediate-Outputdirectory.\n" ); + printf ( " -Dvar=val Set the value of 'var' variable to 'val'.\n" ); printf ( "\n" ); printf ( " buildsystem Target build system. Can be one of:\n" );
@@ -272,7 +298,7 @@ string projectFilename ( RootXmlFile );
printf ( "Reading build files..." ); - Project project ( configuration, projectFilename ); + Project project ( configuration, projectFilename, &properties ); printf ( "done\n" );
project.SetBackend ( Backend::Factory::Create (
Modified: trunk/reactos/tools/rbuild/rbuild.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=2... ============================================================================== --- trunk/reactos/tools/rbuild/rbuild.h (original) +++ trunk/reactos/tools/rbuild/rbuild.h Mon Aug 6 13:19:25 2007 @@ -215,7 +215,8 @@ IfableData non_if_data;
Project ( const Configuration& configuration, - const std::string& filename ); + const std::string& filename, + const std::map<std::string, std::string>* properties = NULL ); ~Project (); void SetBackend ( Backend* backend ) { _backend = backend; } Backend& GetBackend() { return *_backend; } @@ -590,7 +591,6 @@ class Property { public: - const XMLElement& node; const Project& project; const Module* module; std::string name, value; @@ -598,6 +598,11 @@ Property ( const XMLElement& node_, const Project& project_, const Module* module_ ); + + Property ( const Project& project_, + const Module* module_, + const std::string& name_, + const std::string& value_ );
void ProcessXML(); };