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 CompilationUnit::CompilationUnit ( File
* file
)
32 files
.push_back ( file
);
35 CompilationUnit::CompilationUnit ( const Project
* project
,
37 const XMLElement
* node
)
42 const XMLAttribute
* att
= node
->GetAttribute ( "name", true );
44 name
= module
->GetBasePath () + cSep
+ att
->value
;
47 CompilationUnit::~CompilationUnit ()
50 for ( i
= 0; i
< files
.size (); i
++ )
55 CompilationUnit::ProcessXML ()
58 for ( i
= 0; i
< files
.size (); i
++ )
59 files
[i
]->ProcessXML ();
63 CompilationUnit::IsGeneratedFile () const
65 if ( files
.size () != 1 )
67 File
* file
= files
[0];
68 string extension
= GetExtension ( file
->name
);
69 return ( extension
== ".spec" || extension
== ".SPEC" );
73 CompilationUnit::HasFileWithExtension ( const std::string
& extension
) const
76 for ( i
= 0; i
< files
.size (); i
++ )
78 File
& file
= *files
[i
];
79 string fileExtension
= GetExtension ( file
.name
);
80 if ( !stricmp ( fileExtension
.c_str (), extension
.c_str () ) )
87 CompilationUnit::IsFirstFile () const
89 if ( files
.size () == 0 || files
.size () > 1 )
91 File
* file
= files
[0];
96 CompilationUnit::GetFilename ( Directory
* intermediateDirectory
) const
98 if ( files
.size () == 0 || files
.size () > 1 )
99 return new FileLocation ( intermediateDirectory
, name
);
100 File
* file
= files
[0];
101 return new FileLocation ( NULL
, file
->name
);
105 CompilationUnit::GetSwitches () const
107 if ( files
.size () == 0 || files
.size () > 1 )
109 File
* file
= files
[0];
110 return file
->switches
;