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.

82 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. //==============================================================================
  15. struct ConsoleAppWizard : public NewProjectWizard
  16. {
  17. ConsoleAppWizard() {}
  18. String getName() const override { return TRANS("Console Application"); }
  19. String getDescription() const override { return TRANS("Creates a command-line application without GUI support."); }
  20. const char* getIcon() const override { return BinaryData::wizard_ConsoleApp_svg; }
  21. StringArray getFileCreationOptions() override
  22. {
  23. return { "Create a Main.cpp file",
  24. "Don't create any files" };
  25. }
  26. Result processResultsFromSetupItems (WizardComp& setupComp) override
  27. {
  28. createMainCpp = false;
  29. switch (setupComp.getFileCreationComboID())
  30. {
  31. case 0: createMainCpp = true; break;
  32. case 1: break;
  33. default: jassertfalse; break;
  34. }
  35. return Result::ok();
  36. }
  37. bool initialiseProject (Project& project) override
  38. {
  39. createSourceFolder();
  40. project.setProjectType (build_tools::ProjectType_ConsoleApp::getTypeName());
  41. Project::Item sourceGroup (createSourceGroup (project));
  42. setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
  43. if (createMainCpp)
  44. {
  45. File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
  46. String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp")
  47. .replace ("%%app_headers%%", CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename()), false);
  48. if (!build_tools::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
  49. failedFiles.add (mainCppFile.getFullPathName());
  50. sourceGroup.addFileAtIndex (mainCppFile, -1, true);
  51. }
  52. return true;
  53. }
  54. private:
  55. bool createMainCpp;
  56. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConsoleAppWizard)
  57. };