The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
7.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "jucer_ProjectExporter.h"
  19. #include "jucer_ProjectExport_Make.h"
  20. #include "jucer_ProjectExport_MSVC.h"
  21. #include "jucer_ProjectExport_XCode.h"
  22. //==============================================================================
  23. ProjectExporter::ProjectExporter (Project& project_, const ValueTree& settings_)
  24. : project (project_), settings (settings_)
  25. {
  26. }
  27. ProjectExporter::~ProjectExporter()
  28. {
  29. }
  30. //==============================================================================
  31. int ProjectExporter::getNumExporters()
  32. {
  33. return 6;
  34. }
  35. const StringArray ProjectExporter::getExporterNames()
  36. {
  37. StringArray s;
  38. s.add (XCodeProjectExporter::getNameMac());
  39. s.add (XCodeProjectExporter::getNameiPhone());
  40. s.add (MSVCProjectExporter::getNameVC6());
  41. s.add (MSVCProjectExporter::getName2005());
  42. s.add (MSVCProjectExporter::getName2008());
  43. s.add (MakefileProjectExporter::getNameLinux());
  44. return s;
  45. }
  46. ProjectExporter* ProjectExporter::createNewExporter (Project& project, const int index)
  47. {
  48. ProjectExporter* exp = 0;
  49. switch (index)
  50. {
  51. case 0: exp = new XCodeProjectExporter (project, ValueTree (XCodeProjectExporter::getValueTreeTypeName (false)), false); break;
  52. case 1: exp = new XCodeProjectExporter (project, ValueTree (XCodeProjectExporter::getValueTreeTypeName (true)), true); break;
  53. case 2: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio6)), MSVCProjectExporter::visualStudio6); break;
  54. case 3: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2005)), MSVCProjectExporter::visualStudio2005); break;
  55. case 4: exp = new MSVCProjectExporter (project, ValueTree (MSVCProjectExporter::getValueTreeTypeName (MSVCProjectExporter::visualStudio2008)), MSVCProjectExporter::visualStudio2008); break;
  56. case 5: exp = new MakefileProjectExporter (project, ValueTree (MakefileProjectExporter::getValueTreeTypeName())); break;
  57. default: jassertfalse; return 0;
  58. }
  59. File juceFolder (StoredSettings::getInstance()->getLastKnownJuceFolder());
  60. File target (exp->getTargetFolder());
  61. if (shouldPathsBeRelative (juceFolder.getFullPathName(), project.getFile().getFullPathName()))
  62. exp->getJuceFolder() = juceFolder.getRelativePathFrom (project.getFile().getParentDirectory());
  63. else
  64. exp->getJuceFolder() = juceFolder.getFullPathName();
  65. return exp;
  66. }
  67. ProjectExporter* ProjectExporter::createExporter (Project& project, const ValueTree& settings)
  68. {
  69. ProjectExporter* exp = MSVCProjectExporter::createForSettings (project, settings);
  70. if (exp == 0)
  71. exp = XCodeProjectExporter::createForSettings (project, settings);
  72. if (exp == 0)
  73. exp = MakefileProjectExporter::createForSettings (project, settings);
  74. jassert (exp != 0);
  75. return exp;
  76. }
  77. ProjectExporter* ProjectExporter::createPlatformDefaultExporter (Project& project)
  78. {
  79. for (int i = 0; i < project.getNumExporters(); ++i)
  80. {
  81. ScopedPointer <ProjectExporter> exp (project.createExporter (i));
  82. if (exp->isDefaultFormatForCurrentOS())
  83. return exp.release();
  84. }
  85. return 0;
  86. }
  87. const File ProjectExporter::getTargetFolder() const
  88. {
  89. return project.resolveFilename (getTargetLocation().toString());
  90. }
  91. const RelativePath ProjectExporter::getJucePathFromTargetFolder() const
  92. {
  93. RelativePath juceFolder (getJuceFolder().toString(), RelativePath::projectFolder);
  94. return juceFolder.rebased (project.getFile().getParentDirectory(), getTargetFolder(), RelativePath::buildTargetFolder);
  95. }
  96. bool ProjectExporter::shouldFileBeCompiledByDefault (const RelativePath& file) const
  97. {
  98. return file.hasFileExtension ("cpp;c");
  99. }
  100. void ProjectExporter::createPropertyEditors (Array <PropertyComponent*>& props)
  101. {
  102. props.add (new TextPropertyComponent (getTargetLocation(), "Target Project Folder", 1024, false));
  103. props.getLast()->setTooltip ("The location of the folder in which the " + name + " project will be created. This path can be absolute, but it's much more sensible to make it relative to the jucer project directory.");
  104. props.add (new TextPropertyComponent (getJuceFolder(), "Juce Location", 1024, false));
  105. props.getLast()->setTooltip ("The location of the Juce library folder that the " + name + " project will use to when compiling. This can be an absolute path, or relative to the jucer project folder, but it must be valid on the filesystem of the machine you use to actually do the compiling.");
  106. if (project.isAudioPlugin())
  107. {
  108. if (project.shouldAddVSTFolderToPath())
  109. {
  110. props.add (new TextPropertyComponent (getVSTFolder(), "VST Folder", 1024, false));
  111. props.getLast()->setTooltip ("If you're building a VST, this must be the folder containing the VST SDK. This should be an absolute path.");
  112. }
  113. if (isRTAS())
  114. {
  115. props.add (new TextPropertyComponent (getRTASFolder(), "RTAS Folder", 1024, false));
  116. props.getLast()->setTooltip ("If you're building an RTAS, this must be the folder containing the RTAS SDK. This should be an absolute path.");
  117. }
  118. }
  119. props.add (new TextPropertyComponent (getExtraCompilerFlags(), "Extra compiler flags", 2048, false));
  120. props.getLast()->setTooltip ("Extra command-line flags to be passed to the compiler");
  121. props.add (new TextPropertyComponent (getExtraLinkerFlags(), "Extra linker flags", 2048, false));
  122. props.getLast()->setTooltip ("Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries");
  123. }
  124. const Array<RelativePath> ProjectExporter::getVSTFilesRequired() const
  125. {
  126. Array<RelativePath> s;
  127. if (isVST())
  128. {
  129. const char* files[] = { "extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp",
  130. "extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm" };
  131. for (int i = 0; i < numElementsInArray (files); ++i)
  132. s.add (getJucePathFromTargetFolder().getChildFile (files[i]));
  133. }
  134. return s;
  135. }