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.

88 lines
3.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. struct ConsoleAppWizard : public NewProjectWizard
  18. {
  19. ConsoleAppWizard() {}
  20. String getName() const override { return TRANS("Console Application"); }
  21. String getDescription() const override { return TRANS("Creates a command-line application without GUI support."); }
  22. const char* getIcon() const override { return BinaryData::wizard_ConsoleApp_svg; }
  23. void addSetupItems (Component& setupComp, OwnedArray<Component>& itemsCreated) override
  24. {
  25. const String fileOptions[] = { TRANS("Create a Main.cpp file"),
  26. TRANS("Don't create any files") };
  27. createFileCreationOptionComboBox (setupComp, itemsCreated,
  28. StringArray (fileOptions, numElementsInArray (fileOptions)));
  29. }
  30. Result processResultsFromSetupItems (WizardComp& setupComp) override
  31. {
  32. createMainCpp = false;
  33. switch (getFileCreationComboResult (setupComp))
  34. {
  35. case 0: createMainCpp = true; break;
  36. case 1: break;
  37. default: jassertfalse; break;
  38. }
  39. return Result::ok();
  40. }
  41. bool initialiseProject (Project& project) override
  42. {
  43. createSourceFolder();
  44. project.getProjectTypeValue() = ProjectType_ConsoleApp::getTypeName();
  45. Project::Item sourceGroup (createSourceGroup (project));
  46. setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
  47. if (createMainCpp)
  48. {
  49. File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
  50. String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
  51. String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp")
  52. .replace ("APPHEADERS", appHeaders, false);
  53. if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
  54. failedFiles.add (mainCppFile.getFullPathName());
  55. sourceGroup.addFileAtIndex (mainCppFile, -1, true);
  56. }
  57. return true;
  58. }
  59. private:
  60. bool createMainCpp;
  61. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConsoleAppWizard)
  62. };