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
)
36 Include::Include ( const Project
& project
,
37 const XMLElement
* includeNode
,
38 const Module
* module
)
47 Include::Include ( const Project
& project
,
48 DirectoryLocation root
,
49 const std::string
& relative_path
)
50 : project ( project
),
53 directory
= new FileLocation ( root
, relative_path
, "" );
63 Include::ProcessXML ()
65 DirectoryLocation root
= SourceDirectory
;
66 const Module
*base
= module
;
69 const XMLAttribute
* att
= node
->GetAttribute ( "base", false );
73 throw XMLInvalidBuildFileException (
75 "'base' attribute illegal from global <include>" );
77 if ( att
->value
== project
.name
)
81 base
= project
.LocateModule ( att
->value
);
83 throw XMLInvalidBuildFileException (
85 "<include> attribute 'base' references non-existant project or module '%s'",
87 root
= GetDefaultDirectoryTree ( base
);
93 relative_path
= base
->output
->relative_path
;
94 if ( node
->value
.length () > 0 && node
->value
!= "." )
95 relative_path
+= sSep
+ node
->value
;
98 relative_path
= node
->value
;
100 att
= node
->GetAttribute ( "root", false );
103 if ( att
->value
== "intermediate" )
104 root
= IntermediateDirectory
;
105 else if ( att
->value
== "output" )
106 root
= OutputDirectory
;
108 throw InvalidAttributeValueException ( node
->location
,
113 directory
= new FileLocation ( root
,
120 Include::GetDefaultDirectoryTree ( const Module
* module
) const
122 if ( module
!= NULL
&&
123 ( module
->type
== RpcServer
||
124 module
->type
== RpcClient
||
125 module
->type
== RpcProxy
||
126 module
->type
== IdlHeader
||
127 module
->type
== IdlInterface
) )
128 return IntermediateDirectory
;
130 return SourceDirectory
;
134 Include::Initialize ()
136 ParseCompilers ( *node
, "cpp" );