1
0

cmSourceFilesRemoveCommand.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmSourceFilesRemoveCommand.h"
  14. // cmSourceFilesRemoveCommand
  15. bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. int generated = 0;
  23. for(std::vector<std::string>::const_iterator i = (args.begin() + 1);
  24. i != args.end(); ++i)
  25. {
  26. std::string copy = *i;
  27. if ( copy == "GENERATED" )
  28. {
  29. generated = 1;
  30. continue;
  31. }
  32. cmSourceFile file;
  33. if ( generated )
  34. {
  35. // This file will be generated, so we should not check
  36. // if it exist.
  37. std::string ext = cmSystemTools::GetFilenameExtension(copy);
  38. std::string path = cmSystemTools::GetFilenamePath(copy);
  39. std::string name_no_ext = cmSystemTools::GetFilenameName(copy.c_str());
  40. name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
  41. if ( ext.length() && ext[0] == '.' )
  42. {
  43. ext = ext.substr(1);
  44. }
  45. if((path.size() && path[0] == '/') ||
  46. (path.size() > 1 && path[1] == ':'))
  47. {
  48. file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
  49. }
  50. else
  51. {
  52. file.SetName(name_no_ext.c_str(), m_Makefile->GetCurrentOutputDirectory(),
  53. ext.c_str(), false);
  54. }
  55. }
  56. else
  57. {
  58. file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory(),
  59. m_Makefile->GetSourceExtensions(),
  60. m_Makefile->GetHeaderExtensions());
  61. }
  62. m_Makefile->RemoveSource(file, args[0].c_str());
  63. }
  64. return true;
  65. }