Browse Source

Projucer: Removed old jucerVersion property from .jucer file root and added jucerFormatVersion property for indicating changes to .jucer file format not tied to JUCE version

tags/2021-05-28
ed 5 years ago
parent
commit
91d9679f0b
6 changed files with 31 additions and 24 deletions
  1. +2
    -5
      extras/Projucer/Source/Application/jucer_MainWindow.cpp
  2. +2
    -15
      extras/Projucer/Source/Project/jucer_Project.cpp
  3. +3
    -2
      extras/Projucer/Source/Project/jucer_Project.h
  4. +22
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp
  5. +1
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.h
  6. +1
    -0
      extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h

+ 2
- 5
extras/Projucer/Source/Application/jucer_MainWindow.cpp View File

@@ -253,11 +253,8 @@ void MainWindow::moveProject (File newProjectFileToOpen, OpenInIDE openInIDE)
closeCurrentProject (OpenDocumentManager::SaveIfNeeded::no); closeCurrentProject (OpenDocumentManager::SaveIfNeeded::no);
openFile (newProjectFileToOpen); openFile (newProjectFileToOpen);
if (currentProject != nullptr)
ProjucerApplication::getApp().getCommandManager()
.invokeDirectly (openInIDE == OpenInIDE::yes ? CommandIDs::saveAndOpenInIDE
: CommandIDs::saveProject,
false);
if (currentProject != nullptr && openInIDE == OpenInIDE::yes)
ProjucerApplication::getApp().getCommandManager().invokeDirectly (CommandIDs::openInIDE, false);
} }
void MainWindow::setProject (std::unique_ptr<Project> newProject) void MainWindow::setProject (std::unique_ptr<Project> newProject)


+ 2
- 15
extras/Projucer/Source/Project/jucer_Project.cpp View File

@@ -970,7 +970,8 @@ void Project::saveAndMoveTemporaryProject (bool openInIDE)
auto newDirectory = newParentDirectory.getChildFile (tempDirectory.getFileName()); auto newDirectory = newParentDirectory.getChildFile (tempDirectory.getFileName());
auto oldJucerFileName = getFile().getFileName(); auto oldJucerFileName = getFile().getFileName();
writeProjectFile();
ProjectSaver saver (*this);
saver.save();
tempDirectory.copyDirectoryTo (newDirectory); tempDirectory.copyDirectoryTo (newDirectory);
tempDirectory.deleteRecursively(); tempDirectory.deleteRecursively();
@@ -1091,20 +1092,6 @@ bool Project::updateCachedFileState()
return true; return true;
} }
void Project::writeProjectFile()
{
updateCachedFileState();
auto newSerialisedXml = serialiseProjectXml (getProjectRoot().createXml());
jassert (newSerialisedXml.isNotEmpty());
if (newSerialisedXml != cachedFileState.second)
{
getFile().replaceWithText (newSerialisedXml);
cachedFileState = { getFile().getLastModificationTime(), newSerialisedXml };
}
}
//============================================================================== //==============================================================================
File Project::resolveFilename (String filename) const File Project::resolveFilename (String filename) const
{ {


+ 3
- 2
extras/Projucer/Source/Project/jucer_Project.h View File

@@ -475,7 +475,9 @@ public:
//============================================================================== //==============================================================================
bool updateCachedFileState(); bool updateCachedFileState();
void writeProjectFile();
String getCachedFileStateContent() const noexcept { return cachedFileState.second; }
String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
//============================================================================== //==============================================================================
String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder); String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder);
@@ -566,7 +568,6 @@ private:
std::pair<Time, String> cachedFileState; std::pair<Time, String> cachedFileState;
void saveAndMoveTemporaryProject (bool openInIDE); void saveAndMoveTemporaryProject (bool openInIDE);
String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
//============================================================================== //==============================================================================
friend class Item; friend class Item;


+ 22
- 1
extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp View File

@@ -30,6 +30,8 @@
static constexpr const char* generatedGroupID = "__jucelibfiles"; static constexpr const char* generatedGroupID = "__jucelibfiles";
static constexpr const char* generatedGroupUID = "__generatedcode__"; static constexpr const char* generatedGroupUID = "__generatedcode__";
constexpr int jucerFormatVersion = 1;
//============================================================================== //==============================================================================
ProjectSaver::ProjectSaver (Project& p) ProjectSaver::ProjectSaver (Project& p)
: project (p), : project (p),
@@ -294,7 +296,7 @@ Result ProjectSaver::saveProject (ProjectExporter* specifiedExporterToSave)
writeProjects (modules, specifiedExporterToSave); writeProjects (modules, specifiedExporterToSave);
runPostExportScript(); runPostExportScript();
project.writeProjectFile();
writeProjectFile();
if (generatedCodeFolder.exists()) if (generatedCodeFolder.exists())
{ {
@@ -332,6 +334,25 @@ void ProjectSaver::writePluginDefines (MemoryOutputStream& out) const
<< pluginDefines << newLine; << pluginDefines << newLine;
} }
void ProjectSaver::writeProjectFile()
{
auto root = project.getProjectRoot();
root.removeProperty ("jucerVersion", nullptr);
root.setProperty (Ids::jucerFormatVersion, jucerFormatVersion, nullptr);
project.updateCachedFileState();
auto newSerialisedXml = project.serialiseProjectXml (root.createXml());
jassert (newSerialisedXml.isNotEmpty());
if (newSerialisedXml != project.getCachedFileStateContent())
{
project.getFile().replaceWithText (newSerialisedXml);
project.updateCachedFileState();
}
}
void ProjectSaver::writeAppConfig (MemoryOutputStream& out, const OwnedArray<LibraryModule>& modules, const String& userContent) void ProjectSaver::writeAppConfig (MemoryOutputStream& out, const OwnedArray<LibraryModule>& modules, const String& userContent)
{ {
if (! project.shouldUseAppConfig()) if (! project.shouldUseAppConfig())


+ 1
- 1
extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.h View File

@@ -95,7 +95,7 @@ private:
void writePluginDefines(); void writePluginDefines();
void writeAppConfigFile (const OwnedArray<LibraryModule>& modules, const String& userContent); void writeAppConfigFile (const OwnedArray<LibraryModule>& modules, const String& userContent);
void writeMainProjectFile();
void writeProjectFile();
void writeAppConfig (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules, const String& userContent); void writeAppConfig (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules, const String& userContent);
void writeAppHeader (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules); void writeAppHeader (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules);
void writeAppHeader (const OwnedArray<LibraryModule>& modules); void writeAppHeader (const OwnedArray<LibraryModule>& modules);


+ 1
- 0
extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h View File

@@ -370,6 +370,7 @@ namespace Ids
DECLARE_ID (postExportShellCommandWin); DECLARE_ID (postExportShellCommandWin);
DECLARE_ID (liveBuildEnabled); DECLARE_ID (liveBuildEnabled);
DECLARE_ID (guiEditorEnabled); DECLARE_ID (guiEditorEnabled);
DECLARE_ID (jucerFormatVersion);
const Identifier ID ("id"); const Identifier ID ("id");
const Identifier ID_uppercase ("ID"); const Identifier ID_uppercase ("ID");


Loading…
Cancel
Save