mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-30 02:50:05 +00:00
Introjucer: cleaned up some binarydata code.
This commit is contained in:
parent
fd90a9d449
commit
0358e95dc9
6 changed files with 33 additions and 20 deletions
|
|
@ -39,7 +39,8 @@ public:
|
|||
: project (p),
|
||||
projectFile (file),
|
||||
generatedCodeFolder (project.getGeneratedCodeFolder()),
|
||||
generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__"))
|
||||
generatedFilesGroup (Project::Item::createGroup (project, getJuceCodeGroupName(), "__generatedcode__")),
|
||||
hasBinaryData (false)
|
||||
{
|
||||
generatedFilesGroup.setID (getGeneratedGroupID());
|
||||
}
|
||||
|
|
@ -222,8 +223,9 @@ private:
|
|||
StringArray errors;
|
||||
CriticalSection errorLock;
|
||||
|
||||
File appConfigFile, binaryDataCpp;
|
||||
File appConfigFile;
|
||||
SortedSet<File> filesCreated;
|
||||
bool hasBinaryData;
|
||||
|
||||
// Recursively clears out any files in a folder that we didn't create, but avoids
|
||||
// any folders containing hidden files that might be used by version-control systems.
|
||||
|
|
@ -431,8 +433,8 @@ private:
|
|||
for (int i = 0; i < modules.size(); ++i)
|
||||
modules.getUnchecked(i)->writeIncludes (*this, out);
|
||||
|
||||
if (binaryDataCpp.exists())
|
||||
out << CodeHelpers::createIncludeStatement (binaryDataCpp.withFileExtension (".h"), appConfigFile) << newLine;
|
||||
if (hasBinaryData)
|
||||
out << CodeHelpers::createIncludeStatement (project.getBinaryDataHeaderFile(), appConfigFile) << newLine;
|
||||
|
||||
out << newLine
|
||||
<< "#if ! DONT_SET_USING_JUCE_NAMESPACE" << newLine
|
||||
|
|
@ -460,8 +462,7 @@ private:
|
|||
|
||||
void writeBinaryDataFiles()
|
||||
{
|
||||
binaryDataCpp = project.getBinaryDataCppFile();
|
||||
const File binaryDataH (binaryDataCpp.withFileExtension (".h"));
|
||||
const File binaryDataH (project.getBinaryDataHeaderFile());
|
||||
|
||||
ResourceFile resourceFile (project);
|
||||
|
||||
|
|
@ -471,8 +472,10 @@ private:
|
|||
|
||||
Array<File> binaryDataFiles;
|
||||
|
||||
if (resourceFile.write (binaryDataCpp, binaryDataFiles))
|
||||
if (resourceFile.write (binaryDataFiles))
|
||||
{
|
||||
hasBinaryData = true;
|
||||
|
||||
for (int i = 0; i < binaryDataFiles.size(); ++i)
|
||||
{
|
||||
const File& f = binaryDataFiles.getReference(i);
|
||||
|
|
@ -483,12 +486,15 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
addError ("Can't create binary resources file: " + binaryDataCpp.getFullPathName());
|
||||
addError ("Can't create binary resources file: "
|
||||
+ project.getBinaryDataCppFile(0).getFullPathName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
binaryDataCpp.deleteFile();
|
||||
for (int i = 20; --i >= 0;)
|
||||
project.getBinaryDataCppFile (i).deleteFile();
|
||||
|
||||
binaryDataH.deleteFile();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,9 +251,9 @@ bool ResourceFile::writeCpp (MemoryOutputStream& cpp, const File& headerFile, in
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ResourceFile::write (const File& cppFile, Array<File>& filesCreated)
|
||||
bool ResourceFile::write (Array<File>& filesCreated)
|
||||
{
|
||||
const File headerFile (cppFile.withFileExtension (".h"));
|
||||
const File headerFile (project.getBinaryDataHeaderFile());
|
||||
|
||||
{
|
||||
MemoryOutputStream mo;
|
||||
|
|
@ -268,11 +268,7 @@ bool ResourceFile::write (const File& cppFile, Array<File>& filesCreated)
|
|||
|
||||
for (;;)
|
||||
{
|
||||
File cpp (cppFile);
|
||||
|
||||
if (fileIndex > 0)
|
||||
cpp = cpp.getSiblingFile (cppFile.getFileNameWithoutExtension() + String (fileIndex + 1))
|
||||
.withFileExtension (cppFile.getFileExtension());
|
||||
File cpp (project.getBinaryDataCppFile (fileIndex));
|
||||
|
||||
MemoryOutputStream mo;
|
||||
if (! (writeCpp (mo, headerFile, i) && FileHelpers::overwriteFileWithNewDataIfDifferent (cpp, mo)))
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
int getNumFiles() const { return files.size(); }
|
||||
int64 getTotalDataSize() const;
|
||||
|
||||
bool write (const File& cppFile, Array<File>& filesCreated);
|
||||
bool write (Array<File>& filesCreated);
|
||||
|
||||
//==============================================================================
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -217,6 +217,17 @@ bool Project::isAudioPluginModuleMissing() const
|
|||
&& ! isModuleEnabled ("juce_audio_plugin_client");
|
||||
}
|
||||
|
||||
File Project::getBinaryDataCppFile (int index) const
|
||||
{
|
||||
const File cpp (getGeneratedCodeFolder().getChildFile ("BinaryData.cpp"));
|
||||
|
||||
if (index > 0)
|
||||
return cpp.getSiblingFile (cpp.getFileNameWithoutExtension() + String (index + 1))
|
||||
.withFileExtension (cpp.getFileExtension());
|
||||
|
||||
return cpp;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void registerRecentFile (const File& file)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ public:
|
|||
//==============================================================================
|
||||
File getGeneratedCodeFolder() const { return getFile().getSiblingFile ("JuceLibraryCode"); }
|
||||
File getAppIncludeFile() const { return getGeneratedCodeFolder().getChildFile (getJuceSourceHFilename()); }
|
||||
File getBinaryDataCppFile() const { return getGeneratedCodeFolder().getChildFile ("BinaryData.cpp"); }
|
||||
File getBinaryDataHeaderFile() const { return getBinaryDataCppFile().withFileExtension (".h"); }
|
||||
File getBinaryDataCppFile (int index) const;
|
||||
File getBinaryDataHeaderFile() const { return getBinaryDataCppFile (0).withFileExtension (".h"); }
|
||||
|
||||
//==============================================================================
|
||||
String getAmalgamatedHeaderFileName() const { return "juce_amalgamated.h"; }
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<array>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Juce Demo Plugin</string>
|
||||
<string>Raw Material Software: Juce Demo Plugin</string>
|
||||
<key>description</key>
|
||||
<string>Juce Demo Plugin</string>
|
||||
<key>factoryFunction</key>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue