fix compile problems with msvc6
[reactos.git] / reactos / tools / rbuild / include.cpp
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #include "pch.h"
19 #include <assert.h>
20
21 #include "rbuild.h"
22
23 using std::string;
24 using std::vector;
25
26 Include::Include ( const Project& project,
27 const XMLElement* includeNode )
28 : project ( project ),
29 module ( NULL ),
30 node ( includeNode ),
31 baseModule ( NULL )
32 {
33 }
34
35 Include::Include ( const Project& project,
36 const Module* module,
37 const XMLElement* includeNode )
38 : project ( project ),
39 module ( module ),
40 node ( includeNode ),
41 baseModule ( NULL )
42 {
43 }
44
45 Include::Include ( const Project& project,
46 string directory,
47 string basePath )
48 : project ( project ),
49 module ( NULL ),
50 node ( NULL ),
51 baseModule ( NULL )
52 {
53 this->directory = NormalizeFilename ( basePath + SSEP + directory );
54 this->basePath = NormalizeFilename ( basePath );
55 }
56
57 Include::~Include ()
58 {
59 }
60
61 void
62 Include::ProcessXML()
63 {
64 const XMLAttribute* att;
65 att = node->GetAttribute ( "base",
66 false );
67 if ( att )
68 {
69 if ( !module )
70 throw InvalidBuildFileException (
71 node->location,
72 "'base' attribute illegal from global <include>" );
73 bool referenceResolved = false;
74 if ( att->value == project.name )
75 {
76 basePath = ".";
77 referenceResolved = true;
78 }
79 else
80 {
81 const Module* base = project.LocateModule ( att->value );
82 if ( base != NULL )
83 {
84 baseModule = base;
85 basePath = base->GetBasePath ();
86 referenceResolved = true;
87 }
88 }
89 if ( !referenceResolved )
90 throw InvalidBuildFileException (
91 node->location,
92 "<include> attribute 'base' references non-existant project or module '%s'",
93 att->value.c_str() );
94 directory = NormalizeFilename ( basePath + SSEP + node->value );
95 }
96 else
97 directory = NormalizeFilename ( node->value );
98 }