1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Updated CLion and Linux Code::Blocks exporter code for optional webkit and gtk packages

This commit is contained in:
ed 2020-07-21 15:50:14 +01:00
parent 00ed43e29a
commit 6a9f9cd550
5 changed files with 90 additions and 88 deletions

View file

@ -452,13 +452,8 @@ private:
out << "find_package (PkgConfig REQUIRED)" << newLine;
StringArray cmakePkgconfigPackages;
for (auto& package : exporter.getPackages())
{
cmakePkgconfigPackages.add (package.toUpperCase());
out << "pkg_search_module (" << cmakePkgconfigPackages.strings.getLast() << " REQUIRED " << package << ")" << newLine;
}
for (auto& package : exporter.getCompilePackages())
out << "pkg_search_module (" << package.toUpperCase() << " REQUIRED " << package << ")" << newLine;
out << newLine;
@ -497,8 +492,8 @@ private:
for (auto& path : exporter.getHeaderSearchPaths (config))
out << " " << path.quoted() << newLine;
for (auto& package : cmakePkgconfigPackages)
out << " ${" << package << "_INCLUDE_DIRS}" << newLine;
for (auto& package : exporter.getCompilePackages())
out << " ${" << package.toUpperCase() << "_INCLUDE_DIRS}" << newLine;
out << ")" << newLine << newLine;
@ -578,8 +573,8 @@ private:
for (auto& lib : cmakeFoundLibraries)
out << " " << lib << newLine;
for (auto& package : cmakePkgconfigPackages)
out << " ${" << package << "_LIBRARIES}" << newLine;
for (auto& package : exporter.getLinkPackages())
out << " ${" << package.toUpperCase() << "_LIBRARIES}" << newLine;
out << ")" << newLine << newLine;

View file

@ -299,28 +299,6 @@ private:
};
//==============================================================================
StringArray getPackages() const
{
auto result = linuxPackages;
if (project.getEnabledModules().isModuleEnabled ("juce_gui_extra")
&& project.isConfigFlagEnabled ("JUCE_WEB_BROWSER", true))
{
result.add ("webkit2gtk-4.0");
result.add ("gtk+-x11-3.0");
}
if (project.getEnabledModules().isModuleEnabled ("juce_core")
&& project.isConfigFlagEnabled ("JUCE_USE_CURL", true)
&& ! project.isConfigFlagEnabled ("JUCE_LOAD_CURL_SYMBOLS_LAZILY", false))
result.add ("libcurl");
result.removeDuplicates (false);
return result;
}
void addVersion (XmlElement& xml) const
{
auto* fileVersion = xml.createNewChildElement ("FileVersion");
@ -422,19 +400,20 @@ private:
if (target.isDynamicLibrary() || getProject().isAudioPluginProject())
flags.add ("-fPIC");
auto packages = getPackages();
auto packages = config.exporter.getLinuxPackages (PackageDependencyType::compile);
if (packages.size() > 0)
if (! packages.isEmpty())
{
auto pkgconfigFlags = String ("`pkg-config --cflags");
for (auto p : packages)
for (auto& p : packages)
pkgconfigFlags << " " << p;
pkgconfigFlags << "`";
flags.add (pkgconfigFlags);
}
if (linuxLibs.contains("pthread"))
if (linuxLibs.contains ("pthread"))
flags.add ("-pthread");
}
@ -456,14 +435,14 @@ private:
flags.addTokens (replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim(), " \n", "\"'");
auto packages = getPackages();
if (config.exporter.isLinux())
{
if (target.isDynamicLibrary())
flags.add ("-shared");
if (packages.size() > 0)
auto packages = config.exporter.getLinuxPackages (PackageDependencyType::link);
if (! packages.isEmpty())
{
String pkgconfigLibs ("`pkg-config --libs");

View file

@ -379,8 +379,6 @@ public:
static String getValueTreeTypeName() { return "LINUX_MAKE"; }
static String getTargetFolderName() { return "LinuxMakefile"; }
String getExtraPkgConfigString() const { return extraPkgConfigValue.get(); }
static MakefileProjectExporter* createForSettings (Project& projectToUse, const ValueTree& settingsToUse)
{
if (settingsToUse.hasType (getValueTreeTypeName()))
@ -521,45 +519,46 @@ private:
return result;
}
StringArray getPackages() const
StringArray getExtraPkgConfigPackages() const
{
StringArray packages;
packages.addTokens (getExtraPkgConfigString(), " ", "\"'");
auto packages = StringArray::fromTokens (extraPkgConfigValue.get().toString(), " ", "\"'");
packages.removeEmptyStrings();
packages.addArray (linuxPackages);
return packages;
}
// don't add libcurl if curl symbols are loaded at runtime
if (isCurlEnabled() && ! isLoadCurlSymbolsLazilyEnabled())
packages.add ("libcurl");
StringArray getCompilePackages() const
{
auto packages = getLinuxPackages (PackageDependencyType::compile);
packages.addArray (getExtraPkgConfigPackages());
packages.removeDuplicates (false);
return packages;
}
StringArray getLinkPackages() const
{
auto packages = getLinuxPackages (PackageDependencyType::link);
packages.addArray (getExtraPkgConfigPackages());
return packages;
}
String getPreprocessorPkgConfigFlags() const
{
auto packages = getPackages();
auto compilePackages = getCompilePackages();
if (isWebBrowserComponentEnabled())
{
packages.add ("webkit2gtk-4.0");
packages.add ("gtk+-x11-3.0");
}
if (packages.size() > 0)
return "$(shell pkg-config --cflags " + packages.joinIntoString (" ") + ")";
if (compilePackages.size() > 0)
return "$(shell pkg-config --cflags " + compilePackages.joinIntoString (" ") + ")";
return {};
}
String getLinkerPkgConfigFlags() const
{
auto packages = getPackages();
auto linkPackages = getLinkPackages();
if (packages.size() > 0)
return "$(shell pkg-config --libs " + packages.joinIntoString (" ") + ")";
if (linkPackages.size() > 0)
return "$(shell pkg-config --libs " + linkPackages.joinIntoString (" ") + ")";
return {};
}
@ -568,7 +567,7 @@ private:
{
StringArray result;
if (linuxLibs.contains("pthread"))
if (linuxLibs.contains ("pthread"))
result.add ("-pthread");
return result;
@ -673,30 +672,6 @@ private:
return result;
}
bool isWebBrowserComponentEnabled() const
{
static String guiExtrasModule ("juce_gui_extra");
return (project.getEnabledModules().isModuleEnabled (guiExtrasModule)
&& project.isConfigFlagEnabled ("JUCE_WEB_BROWSER", true));
}
bool isCurlEnabled() const
{
static String juceCoreModule ("juce_core");
return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
&& project.isConfigFlagEnabled ("JUCE_USE_CURL", true));
}
bool isLoadCurlSymbolsLazilyEnabled() const
{
static String juceCoreModule ("juce_core");
return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
&& project.isConfigFlagEnabled ("JUCE_LOAD_CURL_SYMBOLS_LAZILY", false));
}
//==============================================================================
void writeDefineFlags (OutputStream& out, const MakeBuildConfiguration& config) const
{
@ -991,7 +966,7 @@ private:
out << getPhonyTargetLine() << newLine << newLine;
writeTargetLines (out, getPackages());
writeTargetLines (out, getLinkPackages());
for (auto target : targets)
target->addFiles (out, getFilesForTarget (filesToCompile, target, project));

View file

@ -487,6 +487,51 @@ Project::Item& ProjectExporter::getModulesGroup()
return *modulesGroup;
}
//==============================================================================
static bool isWebBrowserComponentEnabled (Project& project)
{
static String guiExtrasModule ("juce_gui_extra");
return (project.getEnabledModules().isModuleEnabled (guiExtrasModule)
&& project.isConfigFlagEnabled ("JUCE_WEB_BROWSER", true));
}
static bool isCurlEnabled (Project& project)
{
static String juceCoreModule ("juce_core");
return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
&& project.isConfigFlagEnabled ("JUCE_USE_CURL", true));
}
static bool isLoadCurlSymbolsLazilyEnabled (Project& project)
{
static String juceCoreModule ("juce_core");
return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
&& project.isConfigFlagEnabled ("JUCE_LOAD_CURL_SYMBOLS_LAZILY", false));
}
StringArray ProjectExporter::getLinuxPackages (PackageDependencyType type) const
{
auto packages = linuxPackages;
// don't add libcurl if curl symbols are loaded at runtime
if (isCurlEnabled (project) && ! isLoadCurlSymbolsLazilyEnabled (project))
packages.add ("libcurl");
if (isWebBrowserComponentEnabled (project) && type == PackageDependencyType::compile)
{
packages.add ("webkit2gtk-4.0");
packages.add ("gtk+-x11-3.0");
}
packages.removeEmptyStrings();
packages.removeDuplicates (false);
return packages;
}
void ProjectExporter::addProjectPathToBuildPathList (StringArray& pathList,
const build_tools::RelativePath& pathFromProjectFolder,
int index) const

View file

@ -189,6 +189,14 @@ public:
//==============================================================================
StringArray linuxLibs, linuxPackages, makefileExtraLinkerFlags;
enum class PackageDependencyType
{
compile,
link
};
StringArray getLinuxPackages (PackageDependencyType type) const;
//==============================================================================
StringPairArray msvcExtraPreprocessorDefs;
String msvcDelayLoadedDLLs;