~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Source/cmQTWrapUICommand.cxx

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*=========================================================================
2
2
 
3
 
  Program:   Insight Segmentation & Registration Toolkit
 
3
  Program:   CMake - Cross-Platform Makefile Generator
4
4
  Module:    $RCSfile: cmQTWrapUICommand.cxx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2001/11/21 13:46:59 $
7
 
  Version:   $Revision: 1.3 $
8
 
  Author:    Franck Bettinger.
9
 
 
10
 
Copyright (c) 2001 Insight Consortium
11
 
All rights reserved.
12
 
 
13
 
Redistribution and use in source and binary forms, with or without
14
 
modification, are permitted provided that the following conditions are met:
15
 
 
16
 
 * Redistributions of source code must retain the above copyright notice,
17
 
   this list of conditions and the following disclaimer.
18
 
 
19
 
 * Redistributions in binary form must reproduce the above copyright notice,
20
 
   this list of conditions and the following disclaimer in the documentation
21
 
   and/or other materials provided with the distribution.
22
 
 
23
 
 * The name of the Insight Consortium, nor the names of any consortium members,
24
 
   nor of any contributors, may be used to endorse or promote products derived
25
 
   from this software without specific prior written permission.
26
 
 
27
 
  * Modified source versions must be plainly marked as such, and must not be
28
 
    misrepresented as being the original software.
29
 
 
30
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
31
 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32
 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33
 
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
34
 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35
 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36
 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37
 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38
 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39
 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
6
  Date:      $Date: 2004/07/07 21:09:56 $
 
7
  Version:   $Revision: 1.17.2.1 $
 
8
 
 
9
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
 
10
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
 
11
 
 
12
     This software is distributed WITHOUT ANY WARRANTY; without even 
 
13
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
14
     PURPOSE.  See the above copyright notices for more information.
40
15
 
41
16
=========================================================================*/
42
17
#include "cmQTWrapUICommand.h"
43
18
 
44
19
// cmQTWrapUICommand
45
 
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args)
 
20
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn)
46
21
{
47
 
  if(args.size() < 4 )
 
22
  if(argsIn.size() < 4 )
48
23
    {
49
24
    this->SetError("called with incorrect number of arguments");
50
25
    return false;
51
26
    }
52
 
 
53
 
  // Now check and see if the value has been stored in the cache
54
 
  // already, if so use that value and don't look for the program
55
 
  const char* QT_WRAP_UI_value = m_Makefile->GetDefinition("QT_WRAP_UI");
56
 
  if (QT_WRAP_UI_value==0)
57
 
    {
58
 
    this->SetError("called with QT_WRAP_UI undefined");
59
 
    return false;
60
 
    }
61
 
  
62
 
  if(cmSystemTools::IsOff(QT_WRAP_UI_value))
63
 
    {
64
 
    this->SetError("called with QT_WRAP_UI off : ");
65
 
    return false;
66
 
    }
 
27
  std::vector<std::string> args;
 
28
  m_Makefile->ExpandSourceListArguments(argsIn, args, 3);
67
29
 
68
30
  // what is the current source dir
69
31
  std::string cdir = m_Makefile->GetCurrentDirectory();
72
34
  m_LibraryName = args[0];
73
35
  m_HeaderList = args[1];
74
36
  m_SourceList = args[2];
 
37
  std::string sourceListValue;
 
38
  std::string headerListValue;
 
39
  const char *def = m_Makefile->GetDefinition(m_SourceList.c_str());  
 
40
  if (def)
 
41
    {
 
42
    sourceListValue = def;
 
43
    }
75
44
 
76
45
  // get the list of classes for this library
77
 
  cmMakefile::SourceMap &Classes = m_Makefile->GetSources();
78
 
 
79
 
 
80
 
  for(std::vector<std::string>::const_iterator j = (args.begin() + 3);
 
46
  for(std::vector<std::string>::iterator j = (args.begin() + 3);
81
47
      j != args.end(); ++j)
82
 
    {  
83
 
    cmMakefile::SourceMap::iterator l = Classes.find(*j);
84
 
    if (l == Classes.end())
85
 
      {
86
 
      this->SetError("bad source list passed to QTWrapUICommand");
87
 
      return false;
88
 
      }
89
 
    for(std::vector<cmSourceFile>::iterator i = l->second.begin(); 
90
 
        i != l->second.end(); i++)
91
 
      {
92
 
      cmSourceFile &curr = *i;
93
 
      // if we should wrap the class
94
 
      if (!curr.GetWrapExclude())
95
 
        {
96
 
        cmSourceFile header_file;
97
 
        cmSourceFile source_file;
98
 
        cmSourceFile moc_file;
99
 
        header_file.SetName(curr.GetSourceName().c_str(), 
100
 
                    m_Makefile->GetCurrentOutputDirectory(),
101
 
                     "h",false);
102
 
        source_file.SetName(curr.GetSourceName().c_str(), 
103
 
                    m_Makefile->GetCurrentOutputDirectory(),
104
 
                     "cxx",false);
105
 
        std::string moc_source_name("moc_");
106
 
        moc_source_name = moc_source_name + curr.GetSourceName().c_str();
107
 
        moc_file.SetName(moc_source_name.c_str(), 
108
 
                    m_Makefile->GetCurrentOutputDirectory(),
109
 
                     "cxx",false);
110
 
        std::string origname = cdir + "/" + curr.GetSourceName() + "." +
111
 
            curr.GetSourceExtension();
112
 
        std::string hname = header_file.GetFullPath();
113
 
        m_WrapUserInterface.push_back(origname);
114
 
        // add starting depends
115
 
        moc_file.GetDepends().push_back(hname);
116
 
        source_file.GetDepends().push_back(hname);
117
 
        source_file.GetDepends().push_back(origname);
118
 
        header_file.GetDepends().push_back(origname);
119
 
        m_WrapHeadersClasses.push_back(header_file);
120
 
        m_WrapSourcesClasses.push_back(source_file);
121
 
        m_WrapMocClasses.push_back(moc_file);
122
 
        m_Makefile->AddSource(header_file,
123
 
            m_HeaderList.c_str());
124
 
        m_Makefile->AddSource(source_file,
125
 
            m_SourceList.c_str());
126
 
        m_Makefile->AddSource(moc_file,
127
 
            m_SourceList.c_str());
128
 
        }
 
48
    {   
 
49
    cmSourceFile *curr = m_Makefile->GetSource(j->c_str());
 
50
    
 
51
    // if we should wrap the class
 
52
    if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
 
53
      {
 
54
      cmSourceFile header_file;
 
55
      cmSourceFile source_file;
 
56
      cmSourceFile moc_file;
 
57
      std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
 
58
      header_file.SetName(srcName.c_str(), 
 
59
                          m_Makefile->GetCurrentOutputDirectory(),
 
60
                          "h",false);
 
61
      source_file.SetName(srcName.c_str(), 
 
62
                          m_Makefile->GetCurrentOutputDirectory(),
 
63
                          "cxx",false);
 
64
      std::string moc_source_name("moc_");
 
65
      moc_source_name = moc_source_name + srcName;
 
66
      moc_file.SetName(moc_source_name.c_str(), 
 
67
                       m_Makefile->GetCurrentOutputDirectory(),
 
68
                       "cxx",false);
 
69
      std::string origname;
 
70
      if ( (*j)[0] == '/' || (*j)[1] == ':' )
 
71
        {
 
72
        origname = *j;
 
73
        }
 
74
      else
 
75
        {
 
76
        if ( curr && curr->GetPropertyAsBool("GENERATED") )
 
77
          {
 
78
          origname = std::string( m_Makefile->GetCurrentOutputDirectory() ) + "/" + *j;
 
79
          }
 
80
        else
 
81
          {
 
82
          origname = cdir + "/" + *j;
 
83
          }
 
84
        }
 
85
      std::string hname = header_file.GetFullPath();
 
86
      m_WrapUserInterface.push_back(origname);
 
87
      // add starting depends
 
88
      moc_file.GetDepends().push_back(hname);
 
89
      source_file.GetDepends().push_back(hname);
 
90
      source_file.GetDepends().push_back(origname);
 
91
      header_file.GetDepends().push_back(origname);
 
92
      m_WrapHeadersClasses.push_back(header_file);
 
93
      m_WrapSourcesClasses.push_back(source_file);
 
94
      m_WrapMocClasses.push_back(moc_file);
 
95
      m_Makefile->AddSource(header_file);
 
96
      m_Makefile->AddSource(source_file);
 
97
      m_Makefile->AddSource(moc_file);
 
98
      
 
99
      // create the list of headers 
 
100
      if (headerListValue.size() > 0)
 
101
        {
 
102
        headerListValue += ";";
 
103
        }
 
104
      headerListValue += header_file.GetFullPath();
 
105
      
 
106
      // create the list of sources
 
107
      if (sourceListValue.size() > 0)
 
108
        {
 
109
        sourceListValue += ";";
 
110
        }
 
111
      sourceListValue += source_file.GetFullPath();
 
112
      sourceListValue += ";";
 
113
      sourceListValue += moc_file.GetFullPath();
129
114
      }
130
115
    }
131
116
  
 
117
  m_Makefile->AddDefinition(m_SourceList.c_str(), sourceListValue.c_str());  
 
118
  m_Makefile->AddDefinition(m_HeaderList.c_str(), headerListValue.c_str());  
132
119
  return true;
133
120
}
134
121
 
136
123
{
137
124
 
138
125
  // first we add the rules for all the .ui to .h and .cxx files
139
 
  int lastHeadersClass = m_WrapHeadersClasses.size();
 
126
  size_t lastHeadersClass = m_WrapHeadersClasses.size();
140
127
  std::vector<std::string> depends;
141
 
  std::string uic_exe = "${QT_UIC_EXE}";
142
 
  std::string moc_exe = "${QT_MOC_EXE}";
 
128
  std::string uic_exe = "${QT_UIC_EXECUTABLE}";
 
129
  std::string moc_exe = "${QT_MOC_EXECUTABLE}";
143
130
 
144
131
 
145
132
  // wrap all the .h files
153
140
    ui_list=ui_list+GENERATED_QT_FILES_value;
154
141
    } 
155
142
 
156
 
  for(int classNum = 0; classNum < lastHeadersClass; classNum++)
 
143
  for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
157
144
    {
158
145
    // set up .ui to .h and .cxx command
159
146
 
191
178
    mocargs.push_back(mocres);
192
179
    mocargs.push_back(hres);
193
180
 
194
 
    m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
195
 
                                 uic_exe.c_str(), hargs, depends, 
196
 
                                 hres.c_str(), m_LibraryName.c_str());
197
 
 
198
 
    depends.push_back(hres);
199
 
 
200
 
    m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
201
 
                                 uic_exe.c_str(), cxxargs, depends, 
202
 
                                 cxxres.c_str(), m_LibraryName.c_str());
203
 
 
204
 
    depends.clear();
205
 
    depends.push_back(moc_exe);
206
 
 
207
 
    m_Makefile->AddCustomCommand(hres.c_str(),
208
 
                                 moc_exe.c_str(), mocargs, depends, 
209
 
                                 mocres.c_str(), m_LibraryName.c_str());
 
181
    depends.clear();
 
182
    depends.push_back(m_WrapUserInterface[classNum]);
 
183
    m_Makefile->AddCustomCommandToOutput(
 
184
      hres.c_str(),
 
185
      uic_exe.c_str(), hargs, 0,
 
186
      depends);
 
187
 
 
188
    depends.push_back(hres);
 
189
 
 
190
    m_Makefile->AddCustomCommandToOutput(
 
191
      cxxres.c_str(),
 
192
      uic_exe.c_str(), cxxargs, 0, depends);
 
193
 
 
194
 
 
195
 
 
196
    depends.clear();
 
197
    depends.push_back(hres);
 
198
 
 
199
    m_Makefile->AddCustomCommandToOutput(
 
200
      mocres.c_str(),
 
201
      moc_exe.c_str(), mocargs, 0, depends);
210
202
 
211
203
    }
212
204