mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 09:50:02 +00:00
Parse <compilationunit>
svn path=/trunk/; revision=19411
This commit is contained in:
parent
76eec82fec
commit
34baac2c5c
13 changed files with 323 additions and 104 deletions
42
reactos/tools/rbuild/compilationunit.cpp
Normal file
42
reactos/tools/rbuild/compilationunit.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
#include "rbuild.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
CompilationUnit::CompilationUnit ( const Project& project,
|
||||||
|
const Module* module,
|
||||||
|
const XMLElement& node )
|
||||||
|
: project(project),
|
||||||
|
module(module),
|
||||||
|
node(node)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilationUnit::~CompilationUnit ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CompilationUnit::ProcessXML ()
|
||||||
|
{
|
||||||
|
}
|
|
@ -129,7 +129,7 @@ Value:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
Elements:
|
Elements:
|
||||||
bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, linkerscript, property.
|
bootstrap, component, compilationunit, define, dependency, directory, file, if, importlibrary, include, invoke, library, linkerscript, property.
|
||||||
|
|
||||||
|
|
||||||
Module types
|
Module types
|
||||||
|
@ -190,6 +190,25 @@ Elements:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
CompilationUnit element
|
||||||
|
-----------------------
|
||||||
|
A compilationunit element specifies that one or more source code files are to be compiled as a single compilation unit.
|
||||||
|
|
||||||
|
Syntax:
|
||||||
|
<compilationunit>
|
||||||
|
...
|
||||||
|
</compilationunit>
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
None.
|
||||||
|
|
||||||
|
Value:
|
||||||
|
None.
|
||||||
|
|
||||||
|
Elements:
|
||||||
|
directory, file, if.
|
||||||
|
|
||||||
|
|
||||||
Component element
|
Component element
|
||||||
-----------------
|
-----------------
|
||||||
A component element specifies that imports from a library are to be stubbed so tests can be run without actually calling the functions in the library. This element can only be used for modules of type test.
|
A component element specifies that imports from a library are to be stubbed so tests can be run without actually calling the functions in the library. This element can only be used for modules of type test.
|
||||||
|
@ -313,7 +332,7 @@ Value:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
Elements:
|
Elements:
|
||||||
compilerflag, define, directory, file, if, include, property.
|
compilationunit, compilerflag, define, directory, file, if, include, property.
|
||||||
|
|
||||||
|
|
||||||
Importlibrary element
|
Importlibrary element
|
||||||
|
|
70
reactos/tools/rbuild/global.cpp
Normal file
70
reactos/tools/rbuild/global.cpp
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* 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 "rbuild.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
string ExePrefix;
|
||||||
|
string ExePostfix;
|
||||||
|
string sSep;
|
||||||
|
string sBadSep;
|
||||||
|
char cSep;
|
||||||
|
char cBadSep;
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InitializeEnvironment ()
|
||||||
|
{
|
||||||
|
char *SepValue, *ExePostfixValue, *ExePrefixValue;;
|
||||||
|
|
||||||
|
SepValue = getenv ( "SEP" );
|
||||||
|
if ( SepValue && ( 0 == strcmp ( SepValue, DEF_SSEP ) || 0 == strcmp ( SepValue, DEF_SBAD_SEP ) ) )
|
||||||
|
{
|
||||||
|
cSep = SepValue[0];
|
||||||
|
sSep = SepValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cSep = DEF_CSEP;
|
||||||
|
sSep = DEF_SSEP;
|
||||||
|
}
|
||||||
|
if ( cSep == DEF_CSEP )
|
||||||
|
{
|
||||||
|
cBadSep = DEF_CBAD_SEP;
|
||||||
|
sBadSep = DEF_SBAD_SEP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cBadSep = DEF_CSEP;
|
||||||
|
sBadSep = DEF_SSEP;
|
||||||
|
}
|
||||||
|
ExePostfixValue = getenv ( "EXEPOSTFIX" );
|
||||||
|
ExePrefixValue = getenv ( "EXEPREFIX" );
|
||||||
|
if ( ( ExePostfixValue == NULL || 0 == strlen ( ExePostfixValue ) ) &&
|
||||||
|
( ExePrefixValue == NULL || 0 == strlen ( ExePrefixValue ) ) )
|
||||||
|
{
|
||||||
|
ExePostfix = DEF_EXEPOSTFIX;
|
||||||
|
ExePrefix = DEF_EXEPREFIX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExePostfix = ExePostfixValue ? ExePostfixValue : "";
|
||||||
|
ExePrefix = ExePrefixValue ? ExePrefixValue : "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -182,20 +182,22 @@ GetBooleanValue ( const string& value )
|
||||||
IfableData::~IfableData()
|
IfableData::~IfableData()
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for ( i = 0; i < files.size(); i++ )
|
for ( i = 0; i < files.size (); i++ )
|
||||||
delete files[i];
|
delete files[i];
|
||||||
for ( i = 0; i < includes.size(); i++ )
|
for ( i = 0; i < includes.size (); i++ )
|
||||||
delete includes[i];
|
delete includes[i];
|
||||||
for ( i = 0; i < defines.size(); i++ )
|
for ( i = 0; i < defines.size (); i++ )
|
||||||
delete defines[i];
|
delete defines[i];
|
||||||
for ( i = 0; i < libraries.size(); i++ )
|
for ( i = 0; i < libraries.size (); i++ )
|
||||||
delete libraries[i];
|
delete libraries[i];
|
||||||
for ( i = 0; i < properties.size(); i++ )
|
for ( i = 0; i < properties.size (); i++ )
|
||||||
delete properties[i];
|
delete properties[i];
|
||||||
for ( i = 0; i < compilerFlags.size(); i++ )
|
for ( i = 0; i < compilerFlags.size (); i++ )
|
||||||
delete compilerFlags[i];
|
delete compilerFlags[i];
|
||||||
for ( i = 0; i < ifs.size(); i++ )
|
for ( i = 0; i < ifs.size (); i++ )
|
||||||
delete ifs[i];
|
delete ifs[i];
|
||||||
|
for ( i = 0; i < compilationUnits.size (); i++ )
|
||||||
|
delete compilationUnits[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfableData::ProcessXML ()
|
void IfableData::ProcessXML ()
|
||||||
|
@ -215,6 +217,8 @@ void IfableData::ProcessXML ()
|
||||||
compilerFlags[i]->ProcessXML ();
|
compilerFlags[i]->ProcessXML ();
|
||||||
for ( i = 0; i < ifs.size (); i++ )
|
for ( i = 0; i < ifs.size (); i++ )
|
||||||
ifs[i]->ProcessXML ();
|
ifs[i]->ProcessXML ();
|
||||||
|
for ( i = 0; i < compilationUnits.size (); i++ )
|
||||||
|
compilationUnits[i]->ProcessXML ();
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module ( const Project& project,
|
Module::Module ( const Project& project,
|
||||||
|
@ -413,7 +417,10 @@ Module::ProcessXML()
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for ( i = 0; i < node.subElements.size(); i++ )
|
for ( i = 0; i < node.subElements.size(); i++ )
|
||||||
ProcessXMLSubElement ( *node.subElements[i], path );
|
{
|
||||||
|
ParseContext parseContext;
|
||||||
|
ProcessXMLSubElement ( *node.subElements[i], path, parseContext );
|
||||||
|
}
|
||||||
for ( i = 0; i < invocations.size(); i++ )
|
for ( i = 0; i < invocations.size(); i++ )
|
||||||
invocations[i]->ProcessXML ();
|
invocations[i]->ProcessXML ();
|
||||||
for ( i = 0; i < dependencies.size(); i++ )
|
for ( i = 0; i < dependencies.size(); i++ )
|
||||||
|
@ -434,7 +441,7 @@ Module::ProcessXML()
|
||||||
void
|
void
|
||||||
Module::ProcessXMLSubElement ( const XMLElement& e,
|
Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const string& path,
|
const string& path,
|
||||||
If* pIf /*= NULL*/ )
|
ParseContext& parseContext )
|
||||||
{
|
{
|
||||||
bool subs_invalid = false;
|
bool subs_invalid = false;
|
||||||
string subpath ( path );
|
string subpath ( path );
|
||||||
|
@ -470,17 +477,19 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
first,
|
first,
|
||||||
switches,
|
switches,
|
||||||
false );
|
false );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.files.push_back ( pFile );
|
parseContext.ifData->data.files.push_back ( pFile );
|
||||||
else
|
else
|
||||||
non_if_data.files.push_back ( pFile );
|
non_if_data.files.push_back ( pFile );
|
||||||
|
if ( parseContext.compilationUnit )
|
||||||
|
parseContext.compilationUnit->files.push_back ( pFile );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
}
|
}
|
||||||
else if ( e.name == "library" && e.value.size () )
|
else if ( e.name == "library" && e.value.size () )
|
||||||
{
|
{
|
||||||
Library* pLibrary = new Library ( e, *this, e.value );
|
Library* pLibrary = new Library ( e, *this, e.value );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.libraries.push_back ( pLibrary );
|
parseContext.ifData->data.libraries.push_back ( pLibrary );
|
||||||
else
|
else
|
||||||
non_if_data.libraries.push_back ( pLibrary );
|
non_if_data.libraries.push_back ( pLibrary );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -494,8 +503,8 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "include" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
Include* include = new Include ( project, this, &e );
|
Include* include = new Include ( project, this, &e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.includes.push_back ( include );
|
parseContext.ifData->data.includes.push_back ( include );
|
||||||
else
|
else
|
||||||
non_if_data.includes.push_back ( include );
|
non_if_data.includes.push_back ( include );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -503,15 +512,15 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "define" )
|
else if ( e.name == "define" )
|
||||||
{
|
{
|
||||||
Define* pDefine = new Define ( project, this, e );
|
Define* pDefine = new Define ( project, this, e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.defines.push_back ( pDefine );
|
parseContext.ifData->data.defines.push_back ( pDefine );
|
||||||
else
|
else
|
||||||
non_if_data.defines.push_back ( pDefine );
|
non_if_data.defines.push_back ( pDefine );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
}
|
}
|
||||||
else if ( e.name == "invoke" )
|
else if ( e.name == "invoke" )
|
||||||
{
|
{
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<invoke> is not a valid sub-element of <if>" );
|
"<invoke> is not a valid sub-element of <if>" );
|
||||||
|
@ -520,7 +529,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "dependency" )
|
else if ( e.name == "dependency" )
|
||||||
{
|
{
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<dependency> is not a valid sub-element of <if>" );
|
"<dependency> is not a valid sub-element of <if>" );
|
||||||
|
@ -529,7 +538,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "importlibrary" )
|
else if ( e.name == "importlibrary" )
|
||||||
{
|
{
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<importlibrary> is not a valid sub-element of <if>" );
|
"<importlibrary> is not a valid sub-element of <if>" );
|
||||||
|
@ -542,29 +551,29 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "if" )
|
else if ( e.name == "if" )
|
||||||
{
|
{
|
||||||
If* pOldIf = pIf;
|
If* pOldIf = parseContext.ifData;
|
||||||
pIf = new If ( e, project, this );
|
parseContext.ifData = new If ( e, project, this );
|
||||||
if ( pOldIf )
|
if ( pOldIf )
|
||||||
pOldIf->data.ifs.push_back ( pIf );
|
pOldIf->data.ifs.push_back ( parseContext.ifData );
|
||||||
else
|
else
|
||||||
non_if_data.ifs.push_back ( pIf );
|
non_if_data.ifs.push_back ( parseContext.ifData );
|
||||||
subs_invalid = false;
|
subs_invalid = false;
|
||||||
}
|
}
|
||||||
else if ( e.name == "ifnot" )
|
else if ( e.name == "ifnot" )
|
||||||
{
|
{
|
||||||
If* pOldIf = pIf;
|
If* pOldIf = parseContext.ifData;
|
||||||
pIf = new If ( e, project, this, true );
|
parseContext.ifData = new If ( e, project, this, true );
|
||||||
if ( pOldIf )
|
if ( pOldIf )
|
||||||
pOldIf->data.ifs.push_back ( pIf );
|
pOldIf->data.ifs.push_back ( parseContext.ifData );
|
||||||
else
|
else
|
||||||
non_if_data.ifs.push_back ( pIf );
|
non_if_data.ifs.push_back ( parseContext.ifData );
|
||||||
subs_invalid = false;
|
subs_invalid = false;
|
||||||
}
|
}
|
||||||
else if ( e.name == "compilerflag" )
|
else if ( e.name == "compilerflag" )
|
||||||
{
|
{
|
||||||
CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
|
CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.compilerFlags.push_back ( pCompilerFlag );
|
parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
|
||||||
else
|
else
|
||||||
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -601,7 +610,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "pch" )
|
else if ( e.name == "pch" )
|
||||||
{
|
{
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<pch> is not a valid sub-element of <if>" );
|
"<pch> is not a valid sub-element of <if>" );
|
||||||
|
@ -613,13 +622,23 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) );
|
e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
subs_invalid = false;
|
||||||
|
}
|
||||||
if ( subs_invalid && e.subElements.size() > 0 )
|
if ( subs_invalid && e.subElements.size() > 0 )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<%s> cannot have sub-elements",
|
"<%s> cannot have sub-elements",
|
||||||
e.name.c_str() );
|
e.name.c_str() );
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||||
ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );
|
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleType
|
ModuleType
|
||||||
|
|
|
@ -66,6 +66,11 @@ Environment::GetInstallPath ()
|
||||||
"reactos" );
|
"reactos" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParseContext::ParseContext ()
|
||||||
|
: ifData (NULL),
|
||||||
|
compilationUnit (NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Project::Project ( const string& filename )
|
Project::Project ( const string& filename )
|
||||||
: xmlfile (filename),
|
: xmlfile (filename),
|
||||||
|
@ -254,7 +259,10 @@ Project::ProcessXML ( const string& path )
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for ( i = 0; i < node->subElements.size (); i++ )
|
for ( i = 0; i < node->subElements.size (); i++ )
|
||||||
ProcessXMLSubElement ( *node->subElements[i], path );
|
{
|
||||||
|
ParseContext parseContext;
|
||||||
|
ProcessXMLSubElement ( *node->subElements[i], path, parseContext );
|
||||||
|
}
|
||||||
for ( i = 0; i < modules.size (); i++ )
|
for ( i = 0; i < modules.size (); i++ )
|
||||||
modules[i]->ProcessXML ();
|
modules[i]->ProcessXML ();
|
||||||
for ( i = 0; i < linkerFlags.size (); i++ )
|
for ( i = 0; i < linkerFlags.size (); i++ )
|
||||||
|
@ -269,13 +277,13 @@ Project::ProcessXML ( const string& path )
|
||||||
void
|
void
|
||||||
Project::ProcessXMLSubElement ( const XMLElement& e,
|
Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const string& path,
|
const string& path,
|
||||||
If* pIf )
|
ParseContext& parseContext )
|
||||||
{
|
{
|
||||||
bool subs_invalid = false;
|
bool subs_invalid = false;
|
||||||
string subpath(path);
|
string subpath(path);
|
||||||
if ( e.name == "module" )
|
if ( e.name == "module" )
|
||||||
{
|
{
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
e.location,
|
e.location,
|
||||||
"<module> is not a valid sub-element of <if>" );
|
"<module> is not a valid sub-element of <if>" );
|
||||||
|
@ -310,8 +318,8 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "include" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
Include* include = new Include ( *this, &e );
|
Include* include = new Include ( *this, &e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.includes.push_back ( include );
|
parseContext.ifData->data.includes.push_back ( include );
|
||||||
else
|
else
|
||||||
non_if_data.includes.push_back ( include );
|
non_if_data.includes.push_back ( include );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -319,8 +327,8 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "define" )
|
else if ( e.name == "define" )
|
||||||
{
|
{
|
||||||
Define* define = new Define ( *this, e );
|
Define* define = new Define ( *this, e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.defines.push_back ( define );
|
parseContext.ifData->data.defines.push_back ( define );
|
||||||
else
|
else
|
||||||
non_if_data.defines.push_back ( define );
|
non_if_data.defines.push_back ( define );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -328,8 +336,8 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "compilerflag" )
|
else if ( e.name == "compilerflag" )
|
||||||
{
|
{
|
||||||
CompilerFlag* pCompilerFlag = new CompilerFlag ( *this, e );
|
CompilerFlag* pCompilerFlag = new CompilerFlag ( *this, e );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.compilerFlags.push_back ( pCompilerFlag );
|
parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
|
||||||
else
|
else
|
||||||
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
non_if_data.compilerFlags.push_back ( pCompilerFlag );
|
||||||
subs_invalid = true;
|
subs_invalid = true;
|
||||||
|
@ -341,29 +349,29 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "if" )
|
else if ( e.name == "if" )
|
||||||
{
|
{
|
||||||
If* pOldIf = pIf;
|
If* pOldIf = parseContext.ifData;
|
||||||
pIf = new If ( e, *this, NULL );
|
parseContext.ifData = new If ( e, *this, NULL );
|
||||||
if ( pOldIf )
|
if ( pOldIf )
|
||||||
pOldIf->data.ifs.push_back ( pIf );
|
pOldIf->data.ifs.push_back ( parseContext.ifData );
|
||||||
else
|
else
|
||||||
non_if_data.ifs.push_back ( pIf );
|
non_if_data.ifs.push_back ( parseContext.ifData );
|
||||||
subs_invalid = false;
|
subs_invalid = false;
|
||||||
}
|
}
|
||||||
else if ( e.name == "ifnot" )
|
else if ( e.name == "ifnot" )
|
||||||
{
|
{
|
||||||
If* pOldIf = pIf;
|
If* pOldIf = parseContext.ifData;
|
||||||
pIf = new If ( e, *this, NULL, true );
|
parseContext.ifData = new If ( e, *this, NULL, true );
|
||||||
if ( pOldIf )
|
if ( pOldIf )
|
||||||
pOldIf->data.ifs.push_back ( pIf );
|
pOldIf->data.ifs.push_back ( parseContext.ifData );
|
||||||
else
|
else
|
||||||
non_if_data.ifs.push_back ( pIf );
|
non_if_data.ifs.push_back ( parseContext.ifData );
|
||||||
subs_invalid = false;
|
subs_invalid = false;
|
||||||
}
|
}
|
||||||
else if ( e.name == "property" )
|
else if ( e.name == "property" )
|
||||||
{
|
{
|
||||||
Property* property = new Property ( e, *this, NULL );
|
Property* property = new Property ( e, *this, NULL );
|
||||||
if ( pIf )
|
if ( parseContext.ifData )
|
||||||
pIf->data.properties.push_back ( property );
|
parseContext.ifData->data.properties.push_back ( property );
|
||||||
else
|
else
|
||||||
non_if_data.properties.push_back ( property );
|
non_if_data.properties.push_back ( property );
|
||||||
}
|
}
|
||||||
|
@ -373,7 +381,7 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
"<%s> cannot have sub-elements",
|
"<%s> cannot have sub-elements",
|
||||||
e.name.c_str() );
|
e.name.c_str() );
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||||
ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );
|
ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
Module*
|
Module*
|
||||||
|
@ -405,5 +413,3 @@ Project::GetProjectFilename () const
|
||||||
{
|
{
|
||||||
return xmlfile;
|
return xmlfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,6 @@ static string BuildSystem;
|
||||||
static string RootXmlFile = "ReactOS.xml";
|
static string RootXmlFile = "ReactOS.xml";
|
||||||
static Configuration configuration;
|
static Configuration configuration;
|
||||||
|
|
||||||
string ExePrefix;
|
|
||||||
string ExePostfix;
|
|
||||||
string sSep;
|
|
||||||
string sBadSep;
|
|
||||||
char cSep;
|
|
||||||
char cBadSep;
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ParseAutomaticDependencySwitch ( char switchChar2,
|
ParseAutomaticDependencySwitch ( char switchChar2,
|
||||||
char* switchStart )
|
char* switchStart )
|
||||||
|
@ -193,42 +186,7 @@ ParseArguments ( int argc, char** argv )
|
||||||
int
|
int
|
||||||
main ( int argc, char** argv )
|
main ( int argc, char** argv )
|
||||||
{
|
{
|
||||||
char *SepValue, *ExePostfixValue, *ExePrefixValue;;
|
InitializeEnvironment ();
|
||||||
|
|
||||||
SepValue = getenv("SEP");
|
|
||||||
if (SepValue && (0 == strcmp(SepValue, DEF_SSEP) || 0 == strcmp(SepValue, DEF_SBAD_SEP)))
|
|
||||||
{
|
|
||||||
cSep = SepValue[0];
|
|
||||||
sSep = SepValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cSep = DEF_CSEP;
|
|
||||||
sSep = DEF_SSEP;
|
|
||||||
}
|
|
||||||
if (cSep == DEF_CSEP)
|
|
||||||
{
|
|
||||||
cBadSep = DEF_CBAD_SEP;
|
|
||||||
sBadSep = DEF_SBAD_SEP;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cBadSep = DEF_CSEP;
|
|
||||||
sBadSep = DEF_SSEP;
|
|
||||||
}
|
|
||||||
ExePostfixValue = getenv("EXEPOSTFIX");
|
|
||||||
ExePrefixValue = getenv("EXEPREFIX");
|
|
||||||
if ((ExePostfixValue == NULL || 0 == strlen(ExePostfixValue)) &&
|
|
||||||
(ExePrefixValue == NULL || 0 == strlen(ExePrefixValue)))
|
|
||||||
{
|
|
||||||
ExePostfix = DEF_EXEPOSTFIX;
|
|
||||||
ExePrefix = DEF_EXEPREFIX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ExePostfix = ExePostfixValue ? ExePostfixValue : "";
|
|
||||||
ExePrefix = ExePrefixValue ? ExePrefixValue : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !ParseArguments ( argc, argv ) )
|
if ( !ParseArguments ( argc, argv ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,6 +91,7 @@ class InstallFile;
|
||||||
class PchFile;
|
class PchFile;
|
||||||
class StubbedComponent;
|
class StubbedComponent;
|
||||||
class StubbedSymbol;
|
class StubbedSymbol;
|
||||||
|
class CompilationUnit;
|
||||||
|
|
||||||
class SourceFileTest;
|
class SourceFileTest;
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ public:
|
||||||
const std::string& defaultValue );
|
const std::string& defaultValue );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class FileSupportCode
|
class FileSupportCode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -128,9 +130,20 @@ public:
|
||||||
std::string filename );
|
std::string filename );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ParseContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
If* ifData;
|
||||||
|
CompilationUnit* compilationUnit;
|
||||||
|
ParseContext ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class IfableData
|
class IfableData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
std::vector<CompilationUnit*> compilationUnits;
|
||||||
std::vector<File*> files;
|
std::vector<File*> files;
|
||||||
std::vector<Include*> includes;
|
std::vector<Include*> includes;
|
||||||
std::vector<Define*> defines;
|
std::vector<Define*> defines;
|
||||||
|
@ -177,7 +190,7 @@ private:
|
||||||
void ReadXml ();
|
void ReadXml ();
|
||||||
void ProcessXMLSubElement ( const XMLElement& e,
|
void ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
If* pIf = NULL );
|
ParseContext& parseContext );
|
||||||
|
|
||||||
// disable copy semantics
|
// disable copy semantics
|
||||||
Project ( const Project& );
|
Project ( const Project& );
|
||||||
|
@ -277,7 +290,7 @@ private:
|
||||||
std::string GetDefaultModuleBaseaddress () const;
|
std::string GetDefaultModuleBaseaddress () const;
|
||||||
void ProcessXMLSubElement ( const XMLElement& e,
|
void ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
If* pIf = NULL );
|
ParseContext& parseContext );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -771,6 +784,26 @@ private:
|
||||||
std::string StripSymbol ( std::string symbol );
|
std::string StripSymbol ( std::string symbol );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CompilationUnit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const Project& project;
|
||||||
|
const Module* module;
|
||||||
|
const XMLElement& node;
|
||||||
|
std::vector<File*> files;
|
||||||
|
|
||||||
|
CompilationUnit ( const Project& project,
|
||||||
|
const Module* module,
|
||||||
|
const XMLElement& node );
|
||||||
|
~CompilationUnit ();
|
||||||
|
void ProcessXML();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern VOID
|
||||||
|
InitializeEnvironment ();
|
||||||
|
|
||||||
extern std::string
|
extern std::string
|
||||||
Right ( const std::string& s, size_t n );
|
Right ( const std::string& s, size_t n );
|
||||||
|
|
||||||
|
|
|
@ -152,9 +152,11 @@ RBUILD_BACKEND_SOURCES = \
|
||||||
RBUILD_COMMON_SOURCES = \
|
RBUILD_COMMON_SOURCES = \
|
||||||
$(RBUILD_BACKEND_SOURCES) \
|
$(RBUILD_BACKEND_SOURCES) \
|
||||||
$(addprefix $(RBUILD_BASE_), \
|
$(addprefix $(RBUILD_BASE_), \
|
||||||
|
global.cpp \
|
||||||
automaticdependency.cpp \
|
automaticdependency.cpp \
|
||||||
bootstrap.cpp \
|
bootstrap.cpp \
|
||||||
cdfile.cpp \
|
cdfile.cpp \
|
||||||
|
compilationunit.cpp \
|
||||||
compilerflag.cpp \
|
compilerflag.cpp \
|
||||||
configuration.cpp \
|
configuration.cpp \
|
||||||
define.cpp \
|
define.cpp \
|
||||||
|
@ -219,6 +221,7 @@ RBUILD_HEADERS = \
|
||||||
|
|
||||||
RBUILD_TESTS = \
|
RBUILD_TESTS = \
|
||||||
tests$(SEP)cdfiletest.cpp \
|
tests$(SEP)cdfiletest.cpp \
|
||||||
|
tests$(SEP)compilationunittest.cpp \
|
||||||
tests$(SEP)definetest.cpp \
|
tests$(SEP)definetest.cpp \
|
||||||
tests$(SEP)functiontest.cpp \
|
tests$(SEP)functiontest.cpp \
|
||||||
tests$(SEP)iftest.cpp \
|
tests$(SEP)iftest.cpp \
|
||||||
|
@ -256,6 +259,10 @@ $(RBUILD_TARGET): $(RBUILD_OBJECTS) | $(RBUILD_OUT)
|
||||||
$(ECHO_LD)
|
$(ECHO_LD)
|
||||||
${host_gpp} $(RBUILD_OBJECTS) $(RBUILD_HOST_LFLAGS) -o $@
|
${host_gpp} $(RBUILD_OBJECTS) $(RBUILD_HOST_LFLAGS) -o $@
|
||||||
|
|
||||||
|
$(RBUILD_INT_)global.o: $(RBUILD_BASE_)global.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_INT_)automaticdependency.o: $(RBUILD_BASE_)automaticdependency.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
$(RBUILD_INT_)automaticdependency.o: $(RBUILD_BASE_)automaticdependency.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
@ -268,6 +275,10 @@ $(RBUILD_INT_)cdfile.o: $(RBUILD_BASE_)cdfile.cpp $(RBUILD_HEADERS) | $(RBUILD_I
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(RBUILD_INT_)compilationunit.o: $(RBUILD_BASE_)compilationunit.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_INT_)compilerflag.o: $(RBUILD_BASE_)compilerflag.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
$(RBUILD_INT_)compilerflag.o: $(RBUILD_BASE_)compilerflag.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
@ -380,6 +391,10 @@ $(RBUILD_TESTS_INT_)cdfiletest.o: $(RBUILD_TESTS_BASE_)cdfiletest.cpp $(RBUILD_H
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(RBUILD_TESTS_INT_)compilationunittest.o: $(RBUILD_TESTS_BASE_)compilationunittest.cpp $(RBUILD_HEADERS) | $(RBUILD_TESTS_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_TESTS_INT_)definetest.o: $(RBUILD_TESTS_BASE_)definetest.cpp $(RBUILD_HEADERS) | $(RBUILD_TESTS_INT)
|
$(RBUILD_TESTS_INT_)definetest.o: $(RBUILD_TESTS_BASE_)definetest.cpp $(RBUILD_HEADERS) | $(RBUILD_TESTS_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "rbuild.h"
|
#include "rbuild.h"
|
||||||
#include "backend/mingw/mingw.h"
|
#include "backend/mingw/mingw.h"
|
||||||
|
|
||||||
|
#define SSEP DEF_SSEP
|
||||||
|
|
||||||
#define RBUILD_BASE "tools" SSEP "rbuild" SSEP
|
#define RBUILD_BASE "tools" SSEP "rbuild" SSEP
|
||||||
|
|
||||||
class BaseTest
|
class BaseTest
|
||||||
|
@ -153,4 +155,10 @@ public:
|
||||||
void Run ();
|
void Run ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CompilationUnitTest : public BaseTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Run ();
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __TEST_H */
|
#endif /* __TEST_H */
|
||||||
|
|
|
@ -196,6 +196,7 @@ private:
|
||||||
tests.push_back(new SourceFileTest());
|
tests.push_back(new SourceFileTest());
|
||||||
tests.push_back(new CDFileTest());
|
tests.push_back(new CDFileTest());
|
||||||
tests.push_back(new SymbolTest());
|
tests.push_back(new SymbolTest());
|
||||||
|
tests.push_back(new CompilationUnitTest());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,6 +204,7 @@ private:
|
||||||
int main(int argc,
|
int main(int argc,
|
||||||
char** argv)
|
char** argv)
|
||||||
{
|
{
|
||||||
|
InitializeEnvironment ();
|
||||||
TestDispatcher testDispatcher;
|
TestDispatcher testDispatcher;
|
||||||
testDispatcher.Run();
|
testDispatcher.Run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
36
reactos/tools/rbuild/tests/compilationunittest.cpp
Normal file
36
reactos/tools/rbuild/tests/compilationunittest.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 "test.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
void CompilationUnitTest::Run()
|
||||||
|
{
|
||||||
|
string projectFilename ( RBUILD_BASE "tests/data/compilationunit.xml" );
|
||||||
|
Project project ( projectFilename );
|
||||||
|
ARE_EQUAL ( 1, project.modules.size () );
|
||||||
|
|
||||||
|
Module& module1 = *project.modules[0];
|
||||||
|
IS_TRUE ( module1.type == BuildTool );
|
||||||
|
|
||||||
|
ARE_EQUAL ( 2, module1.non_if_data.files.size());
|
||||||
|
ARE_EQUAL ( 1, module1.non_if_data.compilationUnits.size () );
|
||||||
|
|
||||||
|
CompilationUnit& compilationUnit1 = *module1.non_if_data.compilationUnits[0];
|
||||||
|
ARE_EQUAL ( 2, compilationUnit1.files.size () );
|
||||||
|
}
|
11
reactos/tools/rbuild/tests/data/compilationunit.xml
Normal file
11
reactos/tools/rbuild/tests/data/compilationunit.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
|
<project name="Project" makefile="Makefile">
|
||||||
|
<directory name="dir1">
|
||||||
|
<module name="module1" type="buildtool">
|
||||||
|
<compilationunit>
|
||||||
|
<file>file1.c</file>
|
||||||
|
<file>file2.c</file>
|
||||||
|
</compilationunit>
|
||||||
|
</module>
|
||||||
|
</directory>
|
||||||
|
</project>
|
|
@ -5,9 +5,9 @@ TOOLS_INT_ = $(TOOLS_INT)$(SEP)
|
||||||
TOOLS_OUT = $(OUTPUT_)$(TOOLS_BASE)
|
TOOLS_OUT = $(OUTPUT_)$(TOOLS_BASE)
|
||||||
TOOLS_OUT_ = $(TOOLS_OUT)$(SEP)
|
TOOLS_OUT_ = $(TOOLS_OUT)$(SEP)
|
||||||
|
|
||||||
TOOLS_CFLAGS = -Wall -Wpointer-arith -Wno-strict-aliasing
|
TOOLS_CFLAGS = $(CFLAGS) -Wall -Wpointer-arith -Wno-strict-aliasing
|
||||||
TOOLS_CPPFLAGS = -Wall -Wpointer-arith
|
TOOLS_CPPFLAGS = $(CPPFLAGS) -Wall -Wpointer-arith
|
||||||
TOOLS_LFLAGS =
|
TOOLS_LFLAGS = $(LFLAGS)
|
||||||
|
|
||||||
$(TOOLS_INT): | $(INTERMEDIATE)
|
$(TOOLS_INT): | $(INTERMEDIATE)
|
||||||
$(ECHO_MKDIR)
|
$(ECHO_MKDIR)
|
||||||
|
|
Loading…
Reference in a new issue