-
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
#include "pch.h"
#include <assert.h>
return NULL;
}
+string
+Project::ResolveNextProperty ( string& s ) const
+{
+ size_t i = s.find ( "${" );
+ if ( i == string::npos )
+ i = s.find ( "$(" );
+ if ( i != string::npos )
+ {
+ string endCharacter;
+ if ( s[i + 1] == '{' )
+ endCharacter = "}";
+ else
+ endCharacter = ")";
+ size_t j = s.find ( endCharacter );
+ if ( j != string::npos )
+ {
+ int propertyNameLength = j - i - 2;
+ string propertyName = s.substr ( i + 2, propertyNameLength );
+ const Property* property = LookupProperty ( propertyName );
+ if ( property != NULL )
+ return s.replace ( i, propertyNameLength + 3, property->value );
+ }
+ }
+ return s;
+}
+
+string
+Project::ResolveProperties ( const string& s ) const
+{
+ string s2 = s;
+ string s3;
+ do
+ {
+ s3 = s2;
+ s2 = ResolveNextProperty ( s3 );
+ } while ( s2 != s3 );
+ return s2;
+}
+
void
Project::SetConfigurationOption ( char* s,
- string name,
- string* alternativeName )
+ string name,
+ string* alternativeName )
{
const Property* property = LookupProperty ( name );
if ( property != NULL && property->value.length () > 0 )
s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
- FileSupportCode::WriteIfChanged ( buf, "include" SSEP "roscfg.h" );
+ FileSupportCode::WriteIfChanged ( buf, "include" + sSep + "roscfg.h" );
free ( buf );
}
}
}
+ if (node == NULL)
+ node = head->subElements[0];
+
throw InvalidBuildFileException (
node->location,
"Document contains no 'project' tag." );
}
else if ( e.name == "include" )
{
- Include* include = new Include ( *this, e );
+ Include* include = new Include ( *this, &e );
if ( pIf )
pIf->data.includes.push_back ( include );
else
non_if_data.ifs.push_back ( pIf );
subs_invalid = false;
}
+ else if ( e.name == "ifnot" )
+ {
+ If* pOldIf = pIf;
+ pIf = new If ( e, *this, NULL, true );
+ if ( pOldIf )
+ pOldIf->data.ifs.push_back ( pIf );
+ else
+ non_if_data.ifs.push_back ( pIf );
+ subs_invalid = false;
+ }
else if ( e.name == "property" )
{
Property* property = new Property ( e, *this, NULL );