-Add a new module type 'cabinet' to handle .cab files generation
[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 NativeDLL:
47 case NativeCUI:
48 case Win32DLL:
49 case Win32OCX:
50 case Win32CUI:
51 case Win32SCR:
52 case Win32GUI:
53 case KernelModeDriver:
54 case BootSector:
55 case BootLoader:
56 case BootProgram:
57 case Cabinet:
58 return true;
59 case BuildTool:
60 case StaticLibrary:
61 case HostStaticLibrary:
62 case ObjectLibrary:
63 case Iso:
64 case LiveIso:
65 case IsoRegTest:
66 case LiveIsoRegTest:
67 case Test:
68 case RpcServer:
69 case RpcClient:
70 case RpcProxy:
71 case Alias:
72 case IdlHeader:
73 case EmbeddedTypeLib:
74 case ElfExecutable:
75 return false;
76 case TypeDontCare:
77 break;
78 }
79 throw InvalidOperationException ( __FILE__,
80 __LINE__ );
81 }
82
83 string
84 Bootstrap::ReplaceVariable ( const string& name,
85 const string& value,
86 string path )
87 {
88 size_t i = path.find ( name );
89 if ( i != string::npos )
90 return path.replace ( i, name.length (), value );
91 else
92 return path;
93 }
94
95 void
96 Bootstrap::Initialize ()
97 {
98 if ( !IsSupportedModuleType ( module->type ) )
99 {
100 throw XMLInvalidBuildFileException (
101 node.location,
102 "<bootstrap> is not applicable for this module type." );
103 }
104
105 const XMLAttribute* att = node.GetAttribute ( "installbase", false );
106 if ( att != NULL )
107 base = ReplaceVariable ( "$(CDOUTPUT)", Environment::GetCdOutputPath (), att->value );
108 else
109 base = "";
110
111 att = node.GetAttribute ( "nameoncd", false );
112 if ( att != NULL )
113 nameoncd = att->value;
114 else
115 nameoncd = module->output->name;
116 }
117
118 void
119 Bootstrap::ProcessXML()
120 {
121 }