@@ -133,6 +133,8 @@ public: | |||
File moduleFile, moduleFolder; | |||
private: | |||
mutable Array<File> sourceFiles; | |||
File getInclude() const | |||
{ | |||
return moduleFolder.getChildFile (moduleInfo ["include"]); | |||
@@ -171,11 +173,10 @@ private: | |||
Array<File> tempList; | |||
FileSorter sorter; | |||
while (iter.next()) | |||
tempList.add (iter.getFile()); | |||
tempList.addSorted (sorter, iter.getFile()); | |||
FileSorter sorter; | |||
tempList.sort (sorter); | |||
result.addArray (tempList); | |||
} | |||
@@ -202,7 +203,7 @@ private: | |||
else | |||
{ | |||
if (! group.findItemForFile (file).isValid()) | |||
group.addFile (file, -1, false); | |||
group.addFileUnchecked (file, -1, false); | |||
} | |||
} | |||
@@ -255,15 +256,15 @@ private: | |||
void addIncludedCode (ProjectExporter& exporter, const Array<File>& compiled) const | |||
{ | |||
Array<File> files; | |||
getAllSourceFiles (files); | |||
if (sourceFiles.size() == 0) | |||
getAllSourceFiles (sourceFiles); | |||
Project::Item sourceGroup (Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID())); | |||
int i; | |||
for (i = 0; i < files.size(); ++i) | |||
addFileWithGroups (sourceGroup, files.getReference(i), | |||
files.getReference(i).getRelativePathFrom (moduleFolder)); | |||
for (i = 0; i < sourceFiles.size(); ++i) | |||
addFileWithGroups (sourceGroup, sourceFiles.getReference(i), | |||
sourceFiles.getReference(i).getRelativePathFrom (moduleFolder)); | |||
sourceGroup.addFile (moduleFile, -1, false); | |||
sourceGroup.addFile (getInclude(), -1, false); | |||
@@ -716,19 +716,7 @@ bool Project::Item::addFile (const File& file, int insertIndex, const bool shoul | |||
else if (file.existsAsFile()) | |||
{ | |||
if (! getProject().getMainGroup().findItemForFile (file).isValid()) | |||
{ | |||
Item item (getProject(), ValueTree (Tags::file)); | |||
item.initialiseNodeValues(); | |||
item.getName() = file.getFileName(); | |||
item.getShouldCompileValue() = shouldCompile && file.hasFileExtension ("cpp;mm;c;m;cc;cxx;r"); | |||
item.getShouldAddToResourceValue() = getProject().shouldBeAddedToBinaryResourcesByDefault (file); | |||
if (canContain (item)) | |||
{ | |||
item.setFile (file); | |||
addChild (item, insertIndex); | |||
} | |||
} | |||
addFileUnchecked (file, insertIndex, shouldCompile); | |||
} | |||
else | |||
{ | |||
@@ -738,6 +726,21 @@ bool Project::Item::addFile (const File& file, int insertIndex, const bool shoul | |||
return true; | |||
} | |||
void Project::Item::addFileUnchecked (const File& file, int insertIndex, const bool shouldCompile) | |||
{ | |||
Item item (getProject(), ValueTree (Tags::file)); | |||
item.initialiseNodeValues(); | |||
item.getName() = file.getFileName(); | |||
item.getShouldCompileValue() = shouldCompile && file.hasFileExtension ("cpp;mm;c;m;cc;cxx;r"); | |||
item.getShouldAddToResourceValue() = getProject().shouldBeAddedToBinaryResourcesByDefault (file); | |||
if (canContain (item)) | |||
{ | |||
item.setFile (file); | |||
addChild (item, insertIndex); | |||
} | |||
} | |||
bool Project::Item::addRelativeFile (const RelativePath& file, int insertIndex, bool shouldCompile) | |||
{ | |||
Item item (getProject(), ValueTree (Tags::file)); | |||
@@ -858,6 +861,14 @@ void Project::removeModule (const String& moduleID) | |||
modules.removeChild (i, getUndoManagerFor (modules)); | |||
} | |||
void Project::createRequiredModules (const ModuleList& availableModules, OwnedArray<LibraryModule>& modules) const | |||
{ | |||
for (int i = 0; i < availableModules.modules.size(); ++i) | |||
if (isModuleEnabled (availableModules.modules.getUnchecked(i)->uid)) | |||
modules.add (availableModules.modules.getUnchecked(i)->create()); | |||
} | |||
//============================================================================== | |||
ValueTree Project::getConfigurations() const | |||
{ | |||
@@ -29,6 +29,8 @@ | |||
#include "../jucer_Headers.h" | |||
class ProjectExporter; | |||
class ProjectType; | |||
class ModuleList; | |||
class LibraryModule; | |||
//============================================================================== | |||
class Project : public FileBasedDocument, | |||
@@ -162,6 +164,7 @@ public: | |||
Item getOrCreateSubGroup (const String& name); | |||
void addChild (const Item& newChild, int insertIndex); | |||
bool addFile (const File& file, int insertIndex, bool shouldCompile); | |||
void addFileUnchecked (const File& file, int insertIndex, bool shouldCompile); | |||
bool addRelativeFile (const RelativePath& file, int insertIndex, bool shouldCompile); | |||
void removeItemFromProject(); | |||
void sortAlphabetically (bool keepGroupsAtStart); | |||
@@ -271,6 +274,8 @@ public: | |||
void addModule (const String& moduleID); | |||
void removeModule (const String& moduleID); | |||
void createRequiredModules (const ModuleList& availableModules, OwnedArray<LibraryModule>& modules) const; | |||
//============================================================================== | |||
String getFileTemplate (const String& templateName); | |||
@@ -210,7 +210,7 @@ void ProjectExporter::createPropertyEditors (Array <PropertyComponent*>& props) | |||
props.getLast()->setTooltip ("The location of the Juce library folder that the " + name + " project will use to when compiling. This can be an absolute path, or relative to the jucer project folder, but it must be valid on the filesystem of the machine you use to actually do the compiling."); | |||
OwnedArray<LibraryModule> modules; | |||
project.getProjectType().createRequiredModules (project, ModuleList::getInstance(), modules); | |||
project.createRequiredModules (ModuleList::getInstance(), modules); | |||
for (int i = 0; i < modules.size(); ++i) | |||
modules.getUnchecked(i)->createPropertyEditors (*this, props); | |||
@@ -18,6 +18,7 @@ | |||
//[CppHeaders] You can add your own extra header files here... | |||
#include "jucer_ProjectExporter.h" | |||
#include "jucer_Module.h" | |||
//[/CppHeaders] | |||
#include "jucer_ProjectInformationComponent.h" | |||
@@ -27,6 +27,7 @@ | |||
#define __JUCER_PROJECTSAVER_JUCEHEADER__ | |||
#include "jucer_ResourceFile.h" | |||
#include "jucer_Module.h" | |||
//============================================================================== | |||
@@ -214,7 +215,7 @@ private: | |||
<< "*/" << newLine << newLine; | |||
OwnedArray<LibraryModule> modules; | |||
project.getProjectType().createRequiredModules (project, ModuleList::getInstance(), modules); | |||
project.createRequiredModules (ModuleList::getInstance(), modules); | |||
bool anyFlags = false; | |||
for (int j = 0; j < modules.size(); ++j) | |||
@@ -291,7 +292,7 @@ private: | |||
{ | |||
OwnedArray<LibraryModule> modules; | |||
project.getProjectType().createRequiredModules (project, ModuleList::getInstance(), modules); | |||
project.createRequiredModules (ModuleList::getInstance(), modules); | |||
for (int i = 0; i < modules.size(); ++i) | |||
modules.getUnchecked(i)->writeIncludes (project, out); | |||
@@ -384,7 +385,7 @@ private: | |||
const ValueTree originalGeneratedGroup (generatedFilesGroup.getNode().createCopy()); | |||
OwnedArray<LibraryModule> modules; | |||
project.getProjectType().createRequiredModules (project, ModuleList::getInstance(), modules); | |||
project.createRequiredModules (ModuleList::getInstance(), modules); | |||
for (int i = project.getNumExporters(); --i >= 0;) | |||
{ | |||
@@ -400,7 +401,6 @@ private: | |||
modules.getUnchecked(j)->prepareExporter (*exporter, *this); | |||
sortGroupRecursively (generatedFilesGroup); | |||
exporter->groups.add (generatedFilesGroup); | |||
try | |||
@@ -59,13 +59,6 @@ const ProjectType* ProjectType::findType (const String& typeCode) | |||
return nullptr; | |||
} | |||
void ProjectType::createRequiredModules (Project& project, const ModuleList& availableModules, OwnedArray<LibraryModule>& modules) const | |||
{ | |||
for (int i = 0; i < availableModules.modules.size(); ++i) | |||
if (project.isModuleEnabled (availableModules.modules.getUnchecked(i)->uid)) | |||
modules.add (availableModules.modules.getUnchecked(i)->create()); | |||
} | |||
//============================================================================== | |||
class ProjectType_GUIApp : public ProjectType | |||
{ | |||
@@ -27,8 +27,8 @@ | |||
#define __JUCER_PROJECTTYPE_JUCEHEADER__ | |||
#include "../jucer_Headers.h" | |||
#include "jucer_Module.h" | |||
class Project; | |||
class ProjectExporter; | |||
//============================================================================== | |||
class ProjectType | |||
@@ -58,8 +58,6 @@ public: | |||
virtual void setMissingProjectProperties (Project&) const = 0; | |||
virtual void createPropertyEditors (const Project&, Array <PropertyComponent*>&) const = 0; | |||
virtual void prepareExporter (ProjectExporter&) const = 0; | |||
virtual void createRequiredModules (Project&, const ModuleList& availableModules, | |||
OwnedArray<LibraryModule>& modules) const; | |||
protected: | |||
ProjectType (const String& type, const String& desc); | |||
@@ -30,6 +30,16 @@ | |||
//============================================================================== | |||
namespace FileHelpers | |||
{ | |||
int64 calculateMemoryHashCode (const void* data, const int numBytes) | |||
{ | |||
int64 t = 0; | |||
for (int i = 0; i < numBytes; ++i) | |||
t = t * 65599 + static_cast <const uint8*> (data)[i]; | |||
return t; | |||
} | |||
int64 calculateStreamHashCode (InputStream& in) | |||
{ | |||
int64 t = 0; | |||
@@ -60,18 +70,14 @@ namespace FileHelpers | |||
bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes) | |||
{ | |||
if (file.getSize() == numBytes) | |||
{ | |||
MemoryInputStream newStream (data, numBytes, false); | |||
if (calculateStreamHashCode (newStream) == calculateFileHashCode (file)) | |||
return true; | |||
} | |||
TemporaryFile temp (file); | |||
return temp.getFile().appendData (data, numBytes) | |||
&& temp.overwriteTargetFileWithTemporary(); | |||
if (file.getSize() == numBytes | |||
&& calculateMemoryHashCode (data, numBytes) == calculateFileHashCode (file)) | |||
return true; | |||
if (file.exists()) | |||
return file.replaceWithData (data, numBytes); | |||
else | |||
return file.appendData (data, numBytes); | |||
} | |||
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData) | |||
@@ -144,8 +150,7 @@ namespace FileHelpers | |||
bool isJuceFolder (const File& folder) | |||
{ | |||
return folder.getFileName().containsIgnoreCase ("juce") | |||
&& folder.getChildFile ("juce.h").exists() | |||
&& folder.getChildFile ("modules").exists(); | |||
&& folder.getChildFile ("modules").isDirectory(); | |||
} | |||
static File lookInFolderForJuceFolder (const File& folder) | |||
@@ -689,12 +689,10 @@ bool File::appendData (const void* const dataToAppend, | |||
{ | |||
if (numberOfBytes > 0) | |||
{ | |||
const ScopedPointer <FileOutputStream> out (createOutputStream()); | |||
FileOutputStream out (*this, 8192); | |||
if (out == 0) | |||
return false; | |||
out->write (dataToAppend, numberOfBytes); | |||
return (! out.failedToOpen()) | |||
&& out.write (dataToAppend, numberOfBytes); | |||
} | |||
return true; | |||