1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-05 03:50:07 +00:00

Projucer: Updated all project templates to use include search path when including JuceHeader.h

This commit is contained in:
ed 2020-01-21 16:25:33 +00:00
parent 7d330ab782
commit 7484ac3dd3
19 changed files with 60 additions and 64 deletions

View file

@ -6174,7 +6174,7 @@ static const unsigned char temp_binary_data_35[] =
"#pragma once\r\n"
"\r\n"
"//[Headers] -- You can add your own extra header files here --\r\n"
"%%include_juce_header%%\r\n"
"%%include_juce%%\r\n"
"//[/Headers]\r\n"
"\r\n"
"%%include_files_h%%\r\n"
@ -7204,7 +7204,7 @@ static const unsigned char temp_binary_data_53[] =
" ==============================================================================\r\n"
"*/\r\n"
"\r\n"
"#include \"../JuceLibraryCode/JuceHeader.h\"\r\n"
"%%include_juce%%\r\n"
"#include \"%%filename%%\"\r\n"
"\r\n"
"%%component_begin%%\r\n"
@ -7846,7 +7846,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
case 0x51b49ac5: numBytes = 6036; return jucer_AudioPluginFilterTemplate_cpp;
case 0x488afa0a: numBytes = 2272; return jucer_AudioPluginFilterTemplate_h;
case 0xabad7041: numBytes = 2126; return jucer_ComponentTemplate_cpp;
case 0xfc72fe86: numBytes = 2051; return jucer_ComponentTemplate_h;
case 0xfc72fe86: numBytes = 2044; return jucer_ComponentTemplate_h;
case 0x1657b643: numBytes = 1693; return jucer_ContentCompSimpleTemplate_h;
case 0x0b66646c: numBytes = 1190; return jucer_ContentCompTemplate_cpp;
case 0x6fa10171: numBytes = 1071; return jucer_ContentCompTemplate_h;
@ -7864,7 +7864,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
case 0x7fbac252: numBytes = 1665; return jucer_OpenGLComponentTemplate_cpp;
case 0x491fa0d7: numBytes = 1263; return jucer_OpenGLComponentTemplate_h;
case 0xbc050edc: numBytes = 4926; return jucer_PIPAudioProcessorTemplate_h;
case 0xf4ca9e9a: numBytes = 2447; return jucer_PIPMain_cpp;
case 0xf4ca9e9a: numBytes = 2421; return jucer_PIPMain_cpp;
case 0x0b16e320: numBytes = 517; return jucer_PIPTemplate_h;
case 0xcd472557: numBytes = 6433; return jucer_UnityPluginGUIScript_cs;
case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml;

View file

@ -114,7 +114,7 @@ namespace BinaryData
const int jucer_ComponentTemplate_cppSize = 2126;
extern const char* jucer_ComponentTemplate_h;
const int jucer_ComponentTemplate_hSize = 2051;
const int jucer_ComponentTemplate_hSize = 2044;
extern const char* jucer_ContentCompSimpleTemplate_h;
const int jucer_ContentCompSimpleTemplate_hSize = 1693;
@ -168,7 +168,7 @@ namespace BinaryData
const int jucer_PIPAudioProcessorTemplate_hSize = 4926;
extern const char* jucer_PIPMain_cpp;
const int jucer_PIPMain_cppSize = 2447;
const int jucer_PIPMain_cppSize = 2421;
extern const char* jucer_PIPTemplate_h;
const int jucer_PIPTemplate_hSize = 517;

View file

@ -20,7 +20,7 @@
#pragma once
//[Headers] -- You can add your own extra header files here --
%%include_juce_header%%
%%include_juce%%
//[/Headers]
%%include_files_h%%

View file

@ -6,7 +6,7 @@
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
%%include_juce%%
#include "%%filename%%"
%%component_begin%%

View file

@ -319,10 +319,7 @@ static void copyAcrossUserSections (String& dest, const String& src)
}
//==============================================================================
void GeneratedCode::applyToCode (String& code,
const File& targetFile,
const String& oldFileWithUserData,
Project* project) const
void GeneratedCode::applyToCode (String& code, const File& targetFile, const String& oldFileWithUserData) const
{
replaceTemplate (code, "version", JUCEApplicationBase::getInstance()->getApplicationVersion());
replaceTemplate (code, "creationTime", Time::getCurrentTime().toString (true, true, true));
@ -337,11 +334,8 @@ void GeneratedCode::applyToCode (String& code,
replaceTemplate (code, "method_definitions", getCallbackDefinitions());
File juceHeaderFile = project != nullptr ? project->getAppIncludeFile()
: targetFile.getSiblingFile ("JuceHeader.h");
replaceTemplate (code, "include_juce_header", CodeHelpers::createIncludeStatement (juceHeaderFile, targetFile));
replaceTemplate (code, "include_juce", CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename()));
replaceTemplate (code, "include_files_h", getIncludeFileCode (includeFilesH, targetFile));
replaceTemplate (code, "include_files_cpp", getIncludeFileCode (includeFilesCPP, targetFile));

View file

@ -41,11 +41,7 @@ public:
~GeneratedCode();
//==============================================================================
void applyToCode (String& code,
const File& targetFile,
const String& oldFileWithUserData,
Project* project) const;
void applyToCode (String& code, const File& targetFile, const String& oldFileWithUserData) const;
int getUniqueSuffix();
//==============================================================================

View file

@ -532,11 +532,8 @@ bool JucerDocument::flushChangesToDocuments (Project* project, bool isInitial)
String existingHeader (header->getCodeDocument().getAllContent());
String existingCpp (cpp->getCodeDocument().getAllContent());
generated.applyToCode (headerTemplate, headerFile,
existingHeader, project);
generated.applyToCode (cppTemplate, headerFile.withFileExtension (".cpp"),
existingCpp, project);
generated.applyToCode (headerTemplate, headerFile, existingHeader);
generated.applyToCode (cppTemplate, headerFile.withFileExtension (".cpp"), existingCpp);
if (isInitial)
{

View file

@ -67,9 +67,8 @@ public:
File getBinaryDataCppFile (int index) const;
File getBinaryDataHeaderFile() const { return getBinaryDataCppFile (0).withFileExtension (".h"); }
String getAppConfigFilename() const { return "AppConfig.h"; }
String getJuceSourceFilenameRoot() const { return "JuceLibraryCode"; }
String getJuceSourceHFilename() const { return "JuceHeader.h"; }
static String getAppConfigFilename() { return "AppConfig.h"; }
static String getJuceSourceHFilename() { return "JuceHeader.h"; }
//==============================================================================
template <class FileType>

View file

@ -348,7 +348,7 @@ private:
return longest;
}
File getAppConfigFile() const { return generatedCodeFolder.getChildFile (project.getAppConfigFilename()); }
File getAppConfigFile() const { return generatedCodeFolder.getChildFile (Project::getAppConfigFilename()); }
String loadUserContentFromAppConfig() const
{
@ -525,7 +525,7 @@ private:
mem.setNewLineString (projectLineFeed);
writeAppConfig (mem, modules, userContent);
saveGeneratedFile (project.getAppConfigFilename(), mem);
saveGeneratedFile (Project::getAppConfigFilename(), mem);
}
void writeAppHeader (MemoryOutputStream& out, const OwnedArray<LibraryModule>& modules)
@ -542,7 +542,7 @@ private:
out << "#pragma once" << newLine << newLine;
if (appConfigFile.exists())
out << CodeHelpers::createIncludeStatement (project.getAppConfigFilename()) << newLine;
out << CodeHelpers::createIncludeStatement (Project::getAppConfigFilename()) << newLine;
if (modules.size() > 0)
{
@ -590,7 +590,7 @@ private:
mem.setNewLineString (projectLineFeed);
writeAppHeader (mem, modules);
saveGeneratedFile (project.getJuceSourceHFilename(), mem);
saveGeneratedFile (Project::getJuceSourceHFilename(), mem);
}
void writeModuleCppWrappers (const OwnedArray<LibraryModule>& modules)
@ -606,7 +606,7 @@ private:
mem << "*/" << newLine
<< newLine
<< "#include " << project.getAppConfigFilename().quoted() << newLine
<< "#include " << Project::getAppConfigFilename().quoted() << newLine
<< "#include <";
if (cu.file.getFileExtension() != ".r") // .r files are included without the path

View file

@ -135,6 +135,11 @@ namespace CodeHelpers
return "#include \"" + includePath + "\"";
}
String createIncludePathIncludeStatement (const String& includedFilename)
{
return "#include <" + includedFilename + ">";
}
String makeBinaryDataIdentifierName (const File& file)
{
return makeValidIdentifier (file.getFileName()

View file

@ -34,9 +34,11 @@ namespace CodeHelpers
String unindent (const String& code, int numSpaces);
String makeValidIdentifier (String s, bool capitalise, bool removeColons,
bool allowTemplates, bool allowAsterisks = false);
String makeBinaryDataIdentifierName (const File& file);
String createIncludeStatement (const File& includedFile, const File& targetFile);
String createIncludeStatement (const String& includePath);
String makeBinaryDataIdentifierName (const File& file);
String createIncludePathIncludeStatement (const String& includedFilename);
String stringLiteral (const String& text, int maxLineLength = -1);
String floatLiteral (double value, int numDecPlaces);

View file

@ -425,10 +425,16 @@ String PIPGenerator::getMainFileTextForType()
{
String mainTemplate (BinaryData::jucer_PIPMain_cpp);
mainTemplate = mainTemplate.replace ("%%filename%%", useLocalCopy ? pipFile.getFileName()
: isTemp ? pipFile.getFullPathName()
: RelativePath (pipFile, outputDirectory.getChildFile ("Source"),
RelativePath::unknown).toUnixStyle());
auto includeFilename = [&]
{
if (useLocalCopy) return pipFile.getFileName();
if (isTemp) return pipFile.getFullPathName();
return RelativePath (pipFile, outputDirectory.getChildFile ("Source"), RelativePath::unknown).toUnixStyle();
}();
mainTemplate = mainTemplate.replace ("%%filename%%", includeFilename)
.replace ("%%include_juce%%", CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename()));
auto type = metadata[Ids::type].toString();

View file

@ -170,7 +170,7 @@ public:
{
auto content = fillInBasicTemplateFields (newFile, parent, templateName)
.replace ("%%component_class%%", className)
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (parent.project.getAppIncludeFile(), newFile));
.replace ("%%include_juce%%", CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename()));
content = replaceLineFeeds (content, parent.project.getProjectLineFeed());

View file

@ -71,14 +71,13 @@ struct AnimatedAppWizard : public NewProjectWizard
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
auto appHeaders = juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
// create main window
appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
String windowH = project.getFileTemplate (createCppFile ? "jucer_AnimatedComponentTemplate_h"
: "jucer_AnimatedComponentSimpleTemplate_h")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%content_component_class%%", contentCompName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
@ -89,7 +88,7 @@ struct AnimatedAppWizard : public NewProjectWizard
if (createCppFile)
{
String windowCpp = project.getFileTemplate ("jucer_AnimatedComponentTemplate_cpp")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%include_corresponding_header%%", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
.replace ("%%content_component_class%%", contentCompName, false);

View file

@ -71,14 +71,13 @@ struct AudioAppWizard : public NewProjectWizard
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
auto appHeaders = juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
// create main window
appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
String windowH = project.getFileTemplate (createCppFile ? "jucer_AudioComponentTemplate_h"
: "jucer_AudioComponentSimpleTemplate_h")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%content_component_class%%", contentCompName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
@ -89,7 +88,7 @@ struct AudioAppWizard : public NewProjectWizard
if (createCppFile)
{
String windowCpp = project.getFileTemplate ("jucer_AudioComponentTemplate_cpp")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%include_corresponding_header%%", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
.replace ("%%content_component_class%%", contentCompName, false);

View file

@ -62,7 +62,7 @@ struct AudioPluginAppWizard : public NewProjectWizard
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), filterCppFile));
auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp")
.replace ("%%filter_headers%%", CodeHelpers::createIncludeStatement (filterHFile, filterCppFile)
@ -71,7 +71,7 @@ struct AudioPluginAppWizard : public NewProjectWizard
.replace ("%%editor_class_name%%", editorClassName, false);
String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h")
.replace ("%%app_headers%%", appHeaders, false)
.replace ("%%app_headers%%", juceHeaderInclude, false)
.replace ("%%filter_class_name%%", filterClassName, false);
String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp")
@ -81,7 +81,7 @@ struct AudioPluginAppWizard : public NewProjectWizard
.replace ("%%editor_class_name%%", editorClassName, false);
String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h")
.replace ("%%editor_headers%%", appHeaders + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false)
.replace ("%%editor_headers%%", juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (filterHFile, filterCppFile), false)
.replace ("%%filter_class_name%%", filterClassName, false)
.replace ("%%editor_class_name%%", editorClassName, false);

View file

@ -69,10 +69,9 @@ struct ConsoleAppWizard : public NewProjectWizard
if (createMainCpp)
{
File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp")
.replace ("%%app_headers%%", appHeaders, false);
.replace ("%%app_headers%%", CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename()), false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
failedFiles.add (mainCppFile.getFullPathName());

View file

@ -75,7 +75,8 @@ struct GUIAppWizard : public NewProjectWizard
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
auto appHeaders = juceHeaderInclude;
if (createWindow)
{
@ -83,7 +84,7 @@ struct GUIAppWizard : public NewProjectWizard
String windowH = project.getFileTemplate (createCppFile ? "jucer_ContentCompTemplate_h"
: "jucer_ContentCompSimpleTemplate_h")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%content_component_class%%", contentCompName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
@ -94,7 +95,7 @@ struct GUIAppWizard : public NewProjectWizard
if (createCppFile)
{
String windowCpp = project.getFileTemplate ("jucer_ContentCompTemplate_cpp")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%include_corresponding_header%%", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
.replace ("%%content_component_class%%", contentCompName, false);

View file

@ -71,14 +71,13 @@ struct OpenGLAppWizard : public NewProjectWizard
setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
String appHeaders (CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
auto appHeaders = juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
// create main window
appHeaders << newLine << CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
String windowH = project.getFileTemplate (createCppFile ? "jucer_OpenGLComponentTemplate_h"
: "jucer_OpenGLComponentSimpleTemplate_h")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompH), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%content_component_class%%", contentCompName, false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
@ -89,7 +88,7 @@ struct OpenGLAppWizard : public NewProjectWizard
if (createCppFile)
{
String windowCpp = project.getFileTemplate ("jucer_OpenGLComponentTemplate_cpp")
.replace ("%%include_juce%%", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false)
.replace ("%%include_juce%%", juceHeaderInclude)
.replace ("%%include_corresponding_header%%", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
.replace ("%%content_component_class%%", contentCompName, false);