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.

114 lines
5.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. struct AudioPluginAppWizard : public NewProjectWizard
  22. {
  23. AudioPluginAppWizard() {}
  24. String getName() const override { return TRANS("Audio Plug-In"); }
  25. String getDescription() const override { return TRANS("Creates a VST/AU/RTAS/AAX audio plug-in. This template features a single window GUI and Audio/MIDI IO functions."); }
  26. const char* getIcon() const override { return BinaryData::wizard_AudioPlugin_svg; }
  27. StringArray getDefaultModules() override
  28. {
  29. StringArray s (NewProjectWizard::getDefaultModules());
  30. s.add ("juce_audio_plugin_client");
  31. s.add ("juce_audio_utils");
  32. return s;
  33. }
  34. bool initialiseProject (Project& project) override
  35. {
  36. createSourceFolder();
  37. String filterClassName = CodeHelpers::makeValidIdentifier (appTitle, true, true, false) + "AudioProcessor";
  38. filterClassName = filterClassName.substring (0, 1).toUpperCase() + filterClassName.substring (1);
  39. String editorClassName = filterClassName + "Editor";
  40. File filterCppFile = getSourceFilesFolder().getChildFile ("PluginProcessor.cpp");
  41. File filterHFile = filterCppFile.withFileExtension (".h");
  42. File editorCppFile = getSourceFilesFolder().getChildFile ("PluginEditor.cpp");
  43. File editorHFile = editorCppFile.withFileExtension (".h");
  44. project.setProjectType (ProjectType_AudioPlugin::getTypeName());
  45. setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
  46. String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), filterCppFile));
  47. String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp")
  48. .replace ("%%filter_headers%%", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile)
  49. + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false)
  50. .replace ("%%filter_class_name%%", filterClassName, false)
  51. .replace ("%%editor_class_name%%", editorClassName, false);
  52. String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h")
  53. .replace ("%%app_headers%%", appHeaders, false)
  54. .replace ("%%filter_class_name%%", filterClassName, false);
  55. String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp")
  56. .replace ("%%editor_cpp_headers%%", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile)
  57. + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false)
  58. .replace ("%%filter_class_name%%", filterClassName, false)
  59. .replace ("%%editor_class_name%%", editorClassName, false);
  60. String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h")
  61. .replace ("%%editor_headers%%", appHeaders + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false)
  62. .replace ("%%filter_class_name%%", filterClassName, false)
  63. .replace ("%%editor_class_name%%", editorClassName, false);
  64. if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp))
  65. failedFiles.add (filterCppFile.getFullPathName());
  66. if (! FileHelpers::overwriteFileWithNewDataIfDifferent (filterHFile, filterH))
  67. failedFiles.add (filterHFile.getFullPathName());
  68. if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp))
  69. failedFiles.add (editorCppFile.getFullPathName());
  70. if (! FileHelpers::overwriteFileWithNewDataIfDifferent (editorHFile, editorH))
  71. failedFiles.add (editorHFile.getFullPathName());
  72. Project::Item sourceGroup (createSourceGroup (project));
  73. sourceGroup.addFileAtIndex (filterCppFile, -1, true);
  74. sourceGroup.addFileAtIndex (filterHFile, -1, false);
  75. sourceGroup.addFileAtIndex (editorCppFile, -1, true);
  76. sourceGroup.addFileAtIndex (editorHFile, -1, false);
  77. project.getConfigFlag ("JUCE_VST3_CAN_REPLACE_VST2") = 0;
  78. return true;
  79. }
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginAppWizard)
  81. };