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
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 Include::Include ( const Project
& project
,
27 const XMLElement
* includeNode
)
35 Include::Include ( const Project
& project
,
36 const XMLElement
* includeNode
,
37 const Module
* module
)
45 Include::Include ( const Project
& project
,
46 DirectoryLocation root
,
47 const std::string
& relative_path
)
48 : project ( project
),
51 directory
= new FileLocation ( root
, relative_path
, "" );
61 Include::ProcessXML ()
63 DirectoryLocation root
= SourceDirectory
;
64 const Module
*base
= module
;
67 const XMLAttribute
* att
= node
->GetAttribute ( "base", false );
71 throw XMLInvalidBuildFileException (
73 "'base' attribute illegal from global <include>" );
75 if ( att
->value
== project
.name
)
79 base
= project
.LocateModule ( att
->value
);
81 throw XMLInvalidBuildFileException (
83 "<include> attribute 'base' references non-existant project or module '%s'",
85 root
= GetDefaultDirectoryTree ( base
);
91 relative_path
= base
->output
->relative_path
;
92 if ( node
->value
.length () > 0 && node
->value
!= "." )
93 relative_path
+= sSep
+ node
->value
;
96 relative_path
= node
->value
;
98 att
= node
->GetAttribute ( "root", false );
101 if ( att
->value
== "intermediate" )
102 root
= IntermediateDirectory
;
103 else if ( att
->value
== "output" )
104 root
= OutputDirectory
;
106 throw InvalidAttributeValueException ( node
->location
,
111 directory
= new FileLocation ( root
,
118 Include::GetDefaultDirectoryTree ( const Module
* module
) const
120 if ( module
!= NULL
&&
121 ( module
->type
== RpcServer
||
122 module
->type
== RpcClient
||
123 module
->type
== RpcProxy
||
124 module
->type
== IdlHeader
) )
125 return IntermediateDirectory
;
127 return SourceDirectory
;