2 * Copyright (C) 2005 Casper S. Hornstrup
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.
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.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "../rbuild.h"
27 map
<string
,Backend::Factory
*>*
28 Backend::Factory::factories
= NULL
;
30 Backend::Factory::ref
= 0;
32 Backend::Factory::Factory ( const std::string
& name_
, const std::string
& description_
)
37 factories
= new map
<string
,Factory
*>;
38 (*factories
)[name
] = this;
40 m_description
= description_
;
43 Backend::Factory::~Factory ()
53 Backend::Factory::Create ( const string
& name
,
55 Configuration
& configuration
)
57 string
sname ( name
);
59 if ( !factories
|| !factories
->size () )
60 throw InvalidOperationException ( __FILE__
,
62 "No registered factories" );
63 Backend::Factory
* f
= (*factories
)[sname
];
66 throw UnknownBackendException ( sname
);
69 return (*f
) ( project
, configuration
);
72 Backend::Backend ( Project
& project
,
73 Configuration
& configuration
)
74 : ProjectNode ( project
),
75 configuration ( configuration
)
84 Backend::GetFullPath ( const FileLocation
& file
) const
87 switch ( file
.directory
)
92 case IntermediateDirectory
:
93 directory
= Environment::GetIntermediatePath ();
96 directory
= Environment::GetOutputPath ();
98 case InstallDirectory
:
99 directory
= Environment::GetInstallPath ();
102 throw InvalidOperationException ( __FILE__
,
104 "Invalid directory %d.",
108 if ( file
.relative_path
.length () > 0 )
110 if ( directory
.length () > 0 )
112 directory
+= file
.relative_path
;
118 Backend::GetFullName ( const FileLocation
& file
) const
120 string directory
= GetFullPath ( file
);
122 if ( directory
.length () > 0 )
125 return directory
+ file
.name
;