disabled warning 4214
[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", false );
66 if ( att )
67 {
68 if ( !module )
69 throw XMLInvalidBuildFileException (
70 node->location,
71 "'base' attribute illegal from global <include>" );
72 bool referenceResolved = false;
73 if ( att->value == project.name )
74 {
75 basePath = ".";
76 referenceResolved = true;
77 }
78 else
79 {
80 const Module* base = project.LocateModule ( att->value );
81 if ( base != NULL )
82 {
83 baseModule = base;
84 basePath = base->GetBasePath ();
85 referenceResolved = true;
86 }
87 }
88 if ( !referenceResolved )
89 throw XMLInvalidBuildFileException (
90 node->location,
91 "<include> attribute 'base' references non-existant project or module '%s'",
92 att->value.c_str() );
93 directory = NormalizeFilename ( basePath + sSep + node->value );
94 }
95 else
96 directory = NormalizeFilename ( node->value );
97 }