* Implement <autoregister>
[reactos.git] / reactos / tools / rbuild / linkerscript.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 LinkerScript::LinkerScript ( const Project& project,
27 const Module* module,
28 const XMLElement& node )
29 : project ( project ),
30 module ( module ),
31 node ( node ),
32 baseModule ( NULL )
33 {
34 }
35
36 LinkerScript::~LinkerScript ()
37 {
38 }
39
40 void
41 LinkerScript::ProcessXML()
42 {
43 const XMLAttribute* att;
44 att = node.GetAttribute ( "base",
45 false );
46 if ( att )
47 {
48 bool referenceResolved = false;
49 if ( att->value == project.name )
50 {
51 basePath = ".";
52 referenceResolved = true;
53 }
54 else
55 {
56 const Module* base = project.LocateModule ( att->value );
57 if ( base != NULL )
58 {
59 baseModule = base;
60 basePath = base->GetBasePath ();
61 referenceResolved = true;
62 }
63 }
64 if ( !referenceResolved )
65 throw InvalidBuildFileException (
66 node.location,
67 "<linkerscript> attribute 'base' references non-existant project or module '%s'",
68 att->value.c_str() );
69 directory = NormalizeFilename ( basePath + sSep + node.value );
70 }
71 else
72 directory = NormalizeFilename ( node.value );
73 }