1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-13 00:04:19 +00:00

Projucer: Moved some methods into MiscUtilities

This commit is contained in:
ed 2018-03-12 15:16:26 +00:00
parent 6261424cc8
commit 58c02823c5
9 changed files with 72 additions and 62 deletions

View file

@ -744,7 +744,7 @@ void LatestVersionChecker::askUserForLocationToDownload (URL& newVersionToDownlo
{
File targetFolder (EnabledModuleList::findGlobalModulesFolder());
if (isJuceModulesFolder (targetFolder))
if (isJUCEModulesFolder (targetFolder))
targetFolder = targetFolder.getParentDirectory();
FileChooser chooser (TRANS("Please select the location into which you'd like to install the new version"),
@ -754,7 +754,7 @@ void LatestVersionChecker::askUserForLocationToDownload (URL& newVersionToDownlo
{
targetFolder = chooser.getResult();
if (isJuceModulesFolder (targetFolder))
if (isJUCEModulesFolder (targetFolder))
targetFolder = targetFolder.getParentDirectory();
if (targetFolder.getChildFile ("JUCE").isDirectory())
@ -772,7 +772,7 @@ void LatestVersionChecker::askUserForLocationToDownload (URL& newVersionToDownlo
return;
}
if (isJuceFolder (targetFolder))
if (isJUCEFolder (targetFolder))
{
if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("Overwrite existing JUCE folder?"),

View file

@ -99,14 +99,6 @@ namespace
return files;
}
static String joinLinesIntoSourceFile (StringArray& lines)
{
while (lines.size() > 10 && lines [lines.size() - 1].isEmpty())
lines.remove (lines.size() - 1);
return lines.joinIntoString (getLineEnding()) + getLineEnding();
}
static void replaceFile (const File& file, const String& newText, const String& message)
{
std::cout << message << file.getFullPathName() << std::endl;
@ -371,7 +363,7 @@ namespace
for (int i = 0; i < lines.size(); ++i)
{
String& line = lines.getReference(i);
String& line = lines.getReference (i);
if (options.removeTabs && line.containsChar ('\t'))
{
@ -380,6 +372,7 @@ namespace
for (;;)
{
const int tabPos = line.indexOfChar ('\t');
if (tabPos < 0)
break;
@ -761,7 +754,7 @@ namespace
{
hideDockIcon();
const String appName (JUCEApplication::getInstance()->getApplicationName());
auto appName = JUCEApplication::getInstance()->getApplicationName();
std::cout << appName << std::endl
<< std::endl

View file

@ -111,7 +111,7 @@ public:
void refreshModuleInfoIfCurrentlyShowing (bool juceModulePathChanged)
{
auto isJuceModule = EnabledModuleList::isJuceModule (moduleID);
auto isJuceModule = isJUCEModule (moduleID);
auto shouldRefresh = (juceModulePathChanged && isJuceModule) || (! juceModulePathChanged && ! isJuceModule);
if (! shouldRefresh)
@ -170,8 +170,8 @@ private:
if (exporter->isCLion())
continue;
auto key = modules.isJuceModule (moduleID) ? Ids::defaultJuceModulePath
: Ids::defaultUserModulePath;
auto key = isJUCEModule (moduleID) ? Ids::defaultJuceModulePath
: Ids::defaultUserModulePath;
Value src (modulePathValueSources.add (new DependencyPathValueSource (exporter->getPathForModuleValue (moduleID),
key, exporter->getTargetOSForExporter())));

View file

@ -30,11 +30,6 @@
#include "../ProjectSaving/jucer_ProjectExport_Xcode.h"
//==============================================================================
static String trimCommentCharsFromStartOfLine (const String& line)
{
return line.trimStart().trimCharactersAtStart ("*/").trimStart();
}
static var parseModuleDesc (const StringArray& lines)
{
DynamicObject* o = new DynamicObject();
@ -735,7 +730,7 @@ File EnabledModuleList::getModuleFolder (const String& moduleID)
{
if (shouldUseGlobalPath (moduleID))
{
if (isJuceModule (moduleID))
if (isJUCEModule (moduleID))
return getModuleFolderFromPathIfItExists (getAppSettings().getStoredPath (Ids::defaultJuceModulePath).toString(), moduleID, project);
return findUserModuleFolder (getAppSettings().getStoredPath (Ids::defaultUserModulePath).toString(), moduleID);
@ -940,36 +935,6 @@ File EnabledModuleList::findDefaultModulesFolder (Project& project)
return File::getCurrentWorkingDirectory();
}
bool EnabledModuleList::isJuceModule (const String& moduleID)
{
static StringArray juceModuleIds =
{
"juce_analytics",
"juce_audio_basics",
"juce_audio_devices",
"juce_audio_formats",
"juce_audio_plugin_client",
"juce_audio_processors",
"juce_audio_utils",
"juce_blocks_basics",
"juce_box2d",
"juce_core",
"juce_cryptography",
"juce_data_structures",
"juce_dsp",
"juce_events",
"juce_graphics",
"juce_gui_basics",
"juce_gui_extra",
"juce_opengl",
"juce_osc",
"juce_product_unlocking",
"juce_video"
};
return juceModuleIds.contains (moduleID);
}
void EnabledModuleList::addModuleFromUserSelectedFile()
{
static auto lastLocation = findDefaultModulesFolder (project);
@ -1030,12 +995,12 @@ void EnabledModuleList::addModuleOfferingToCopy (const File& f, bool isFromUserS
: areMostModulesUsingGlobalPath());
}
bool isJuceFolder (const File& f)
bool isJUCEFolder (const File& f)
{
return isJuceModulesFolder (f.getChildFile ("modules"));
return isJUCEModulesFolder (f.getChildFile ("modules"));
}
bool isJuceModulesFolder (const File& f)
bool isJUCEModulesFolder (const File& f)
{
return f.isDirectory() && f.getChildFile ("juce_core").isDirectory();
}

View file

@ -31,8 +31,8 @@ class ProjectExporter;
class ProjectSaver;
//==============================================================================
bool isJuceModulesFolder (const File&);
bool isJuceFolder (const File&);
bool isJUCEModulesFolder (const File&);
bool isJUCEFolder (const File&);
//==============================================================================
struct ModuleDescription
@ -140,7 +140,6 @@ public:
static File findGlobalModulesFolder();
static File findDefaultModulesFolder (Project&);
static bool isJuceModule (const String& moduleID);
bool isModuleEnabled (const String& moduleID) const;

View file

@ -516,8 +516,8 @@ String ProjectExporter::getPathForModuleString (const String& moduleID) const
if (exporterPath.isEmpty() || project.getModules().shouldUseGlobalPath (moduleID))
{
auto id = EnabledModuleList::isJuceModule (moduleID) ? Ids::defaultJuceModulePath
: Ids::defaultUserModulePath;
auto id = isJUCEModule (moduleID) ? Ids::defaultJuceModulePath
: Ids::defaultUserModulePath;
if (TargetOS::getThisOS() != getTargetOSForExporter())
return getAppSettings().getFallbackPathForOS (id, getTargetOSForExporter()).toString();

View file

@ -27,6 +27,21 @@
#include "../../Application/jucer_Headers.h"
//==============================================================================
const char* getLineEnding() { return "\r\n"; }
String joinLinesIntoSourceFile (StringArray& lines)
{
while (lines.size() > 10 && lines [lines.size() - 1].isEmpty())
lines.remove (lines.size() - 1);
return lines.joinIntoString (getLineEnding()) + getLineEnding();
}
String trimCommentCharsFromStartOfLine (const String& line)
{
return line.trimStart().trimCharactersAtStart ("*/").trimStart();
}
String createAlphaNumericUID()
{
String uid;
@ -275,3 +290,34 @@ bool fileNeedsCppSyntaxHighlighting (const File& file)
return CharPointer_UTF8::isValidString (fileStart, sizeof (fileStart))
&& String (fileStart).trimStart().startsWith ("// -*- C++ -*-");
}
//==============================================================================
bool isJUCEModule (const String& moduleID) noexcept
{
static StringArray juceModuleIds =
{
"juce_analytics",
"juce_audio_basics",
"juce_audio_devices",
"juce_audio_formats",
"juce_audio_plugin_client",
"juce_audio_processors",
"juce_audio_utils",
"juce_blocks_basics",
"juce_box2d",
"juce_core",
"juce_cryptography",
"juce_data_structures",
"juce_dsp",
"juce_events",
"juce_graphics",
"juce_gui_basics",
"juce_gui_extra",
"juce_opengl",
"juce_osc",
"juce_product_unlocking",
"juce_video"
};
return juceModuleIds.contains (moduleID);
}

View file

@ -28,6 +28,11 @@
//==============================================================================
const char* getLineEnding();
String joinLinesIntoSourceFile (StringArray& lines);
String trimCommentCharsFromStartOfLine (const String& line);
String hexString8Digits (int value);
String createAlphaNumericUID();
@ -53,6 +58,8 @@ void addPlistDictionaryKeyInt (XmlElement* xml, const String& key, int value);
bool fileNeedsCppSyntaxHighlighting (const File& file);
bool isJUCEModule (const String& moduleID) noexcept;
//==============================================================================
int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);

View file

@ -91,7 +91,7 @@ public:
if (! fc.browseForDirectory())
return false;
if (isJuceModulesFolder (fc.getResult()))
if (isJUCEModulesFolder (fc.getResult()))
{
result = fc.getResult();
return true;
@ -406,7 +406,7 @@ public:
wizard->modulesFolder = modulesPathBox.isUsingGlobalPaths ? File (getAppSettings().getStoredPath (Ids::defaultJuceModulePath).toString())
: modulesPathBox.modulesFolder;
if (! isJuceModulesFolder (wizard->modulesFolder))
if (! isJUCEModulesFolder (wizard->modulesFolder))
{
if (modulesPathBox.isUsingGlobalPaths)
AlertWindow::showMessageBox (AlertWindow::AlertIconType::WarningIcon, "Invalid Global Path",