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.

106 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 AudioPluginAppWizard : public NewProjectWizard
  16. {
  17. AudioPluginAppWizard() {}
  18. String getName() const override { return TRANS("Audio Plug-In"); }
  19. 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."); }
  20. const char* getIcon() const override { return BinaryData::wizard_AudioPlugin_svg; }
  21. StringArray getDefaultModules() override
  22. {
  23. StringArray s (NewProjectWizard::getDefaultModules());
  24. s.add ("juce_audio_plugin_client");
  25. s.add ("juce_audio_utils");
  26. return s;
  27. }
  28. bool initialiseProject (Project& project) override
  29. {
  30. createSourceFolder();
  31. String filterClassName = build_tools::makeValidIdentifier (appTitle, true, true, false) + "AudioProcessor";
  32. filterClassName = filterClassName.substring (0, 1).toUpperCase() + filterClassName.substring (1);
  33. String editorClassName = filterClassName + "Editor";
  34. File filterCppFile = getSourceFilesFolder().getChildFile ("PluginProcessor.cpp");
  35. File filterHFile = filterCppFile.withFileExtension (".h");
  36. File editorCppFile = getSourceFilesFolder().getChildFile ("PluginEditor.cpp");
  37. File editorHFile = editorCppFile.withFileExtension (".h");
  38. project.setProjectType (build_tools::ProjectType_AudioPlugin::getTypeName());
  39. setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
  40. auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
  41. String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp")
  42. .replace ("%%filter_headers%%", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile)
  43. + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false)
  44. .replace ("%%filter_class_name%%", filterClassName, false)
  45. .replace ("%%editor_class_name%%", editorClassName, false);
  46. String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h")
  47. .replace ("%%app_headers%%", juceHeaderInclude, false)
  48. .replace ("%%filter_class_name%%", filterClassName, false);
  49. String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp")
  50. .replace ("%%editor_cpp_headers%%", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile)
  51. + newLine + CodeHelpers::createIncludeStatement (editorHFile, filterCppFile), false)
  52. .replace ("%%filter_class_name%%", filterClassName, false)
  53. .replace ("%%editor_class_name%%", editorClassName, false);
  54. String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h")
  55. .replace ("%%editor_headers%%", juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false)
  56. .replace ("%%filter_class_name%%", filterClassName, false)
  57. .replace ("%%editor_class_name%%", editorClassName, false);
  58. if (!build_tools::overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp))
  59. failedFiles.add (filterCppFile.getFullPathName());
  60. if (!build_tools::overwriteFileWithNewDataIfDifferent (filterHFile, filterH))
  61. failedFiles.add (filterHFile.getFullPathName());
  62. if (!build_tools::overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp))
  63. failedFiles.add (editorCppFile.getFullPathName());
  64. if (!build_tools::overwriteFileWithNewDataIfDifferent (editorHFile, editorH))
  65. failedFiles.add (editorHFile.getFullPathName());
  66. Project::Item sourceGroup (createSourceGroup (project));
  67. sourceGroup.addFileAtIndex (filterCppFile, -1, true);
  68. sourceGroup.addFileAtIndex (filterHFile, -1, false);
  69. sourceGroup.addFileAtIndex (editorCppFile, -1, true);
  70. sourceGroup.addFileAtIndex (editorHFile, -1, false);
  71. project.getConfigFlag ("JUCE_VST3_CAN_REPLACE_VST2") = 0;
  72. return true;
  73. }
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginAppWizard)
  75. };