8be6f969f305a758854ba6a1d63da75e6edcd333
[reactos.git] / reactos / tools / rbuild / bootstrap.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
25 Bootstrap::Bootstrap ( const Project& project_,
26 const Module* module_,
27 const XMLElement& bootstrapNode )
28 : project(project_),
29 module(module_),
30 node(bootstrapNode)
31 {
32 Initialize();
33 }
34
35 Bootstrap::~Bootstrap ()
36 {
37 }
38
39 bool
40 Bootstrap::IsSupportedModuleType ( ModuleType type )
41 {
42 switch ( type )
43 {
44 case Kernel:
45 case KernelModeDLL:
46 case KeyboardLayout:
47 case NativeDLL:
48 case NativeCUI:
49 case Win32DLL:
50 case Win32OCX:
51 case Win32CUI:
52 case Win32SCR:
53 case Win32GUI:
54 case KernelModeDriver:
55 case BootSector:
56 case BootLoader:
57 case BootProgram:
58 case Cabinet:
59 return true;
60 case BuildTool:
61 case StaticLibrary:
62 case HostStaticLibrary:
63 case ObjectLibrary:
64 case Iso:
65 case LiveIso:
66 case IsoRegTest:
67 case LiveIsoRegTest:
68 case Test:
69 case RpcServer:
70 case RpcClient:
71 case RpcProxy:
72 case Alias:
73 case IdlHeader:
74 case IdlInterface:
75 case MessageHeader:
76 case EmbeddedTypeLib:
77 case ElfExecutable:
78 return false;
79 case TypeDontCare:
80 break;
81 }
82 throw InvalidOperationException ( __FILE__,
83 __LINE__ );
84 }
85
86 string
87 Bootstrap::ReplaceVariable ( const string& name,
88 const string& value,
89 string path )
90 {
91 size_t i = path.find ( name );
92 if ( i != string::npos )
93 return path.replace ( i, name.length (), value );
94 else
95 return path;
96 }
97
98 void
99 Bootstrap::Initialize ()
100 {
101 if ( !IsSupportedModuleType ( module->type ) )
102 {
103 throw XMLInvalidBuildFileException (
104 node.location,
105 "<bootstrap> is not applicable for this module type." );
106 }
107
108 const XMLAttribute* att = node.GetAttribute ( "installbase", false );
109 if ( att != NULL )
110 base = ReplaceVariable ( "$(CDOUTPUT)", Environment::GetCdOutputPath (), att->value );
111 else
112 base = "";
113
114 att = node.GetAttribute ( "nameoncd", false );
115 if ( att != NULL )
116 nameoncd = att->value;
117 else
118 nameoncd = module->output->name;
119 }
120
121 void
122 Bootstrap::ProcessXML()
123 {
124 }