Set svn:eol-style=native
[reactos.git] / reactos / tools / rbuild / include.cpp
1 #include "pch.h"
2 #include <assert.h>
3
4 #include "rbuild.h"
5
6 using std::string;
7 using std::vector;
8
9 Include::Include ( const Project& project_,
10 const XMLElement& includeNode )
11 : project (project_),
12 module (NULL),
13 node (includeNode)
14 {
15 Initialize();
16 }
17
18 Include::Include ( const Project& project_,
19 const Module* module_,
20 const XMLElement& includeNode )
21 : project (project_),
22 module (module_),
23 node (includeNode)
24 {
25 Initialize();
26 }
27
28 Include::~Include ()
29 {
30 }
31
32 void
33 Include::Initialize()
34 {
35 }
36
37 void
38 Include::ProcessXML()
39 {
40 const XMLAttribute* att;
41 att = node.GetAttribute ( "base",
42 false );
43 if ( att )
44 {
45 if ( !module )
46 throw InvalidBuildFileException (
47 node.location,
48 "'base' attribute illegal from global <include>" );
49 bool referenceResolved = false;
50 if ( att->value == project.name )
51 {
52 basePath = ".";
53 referenceResolved = true;
54 }
55 else
56 {
57 const Module* base = project.LocateModule ( att->value );
58 if ( base != NULL )
59 {
60 basePath = base->GetBasePath ();
61 referenceResolved = true;
62 }
63 }
64 if ( !referenceResolved )
65 throw InvalidBuildFileException (
66 node.location,
67 "<include> attribute 'base' references non-existant project or module '%s'",
68 att->value.c_str() );
69 directory = FixSeparator ( basePath + "/" + node.value );
70 }
71 else
72 directory = FixSeparator ( node.value );
73 }