mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Projucer: Add embedded Linux subprocess for WebView support
This commit is contained in:
parent
f9ff497978
commit
31f94c2e28
7 changed files with 878 additions and 23 deletions
|
|
@ -234,6 +234,32 @@ build_tools::RelativePath ProjectExporter::rebaseFromProjectFolderToBuildTarget
|
|||
return path.rebased (project.getProjectFolder(), getTargetFolder(), build_tools::RelativePath::buildTargetFolder);
|
||||
}
|
||||
|
||||
build_tools::RelativePath ProjectExporter::rebaseFromBuildTargetToProjectFolder (const build_tools::RelativePath& path) const
|
||||
{
|
||||
jassert (path.getRoot() == build_tools::RelativePath::buildTargetFolder);
|
||||
return path.rebased (getTargetFolder(), project.getProjectFolder(), build_tools::RelativePath::projectFolder);
|
||||
}
|
||||
|
||||
File ProjectExporter::resolveRelativePath (const build_tools::RelativePath& path) const
|
||||
{
|
||||
if (path.isAbsolute())
|
||||
return path.toUnixStyle();
|
||||
|
||||
switch (path.getRoot())
|
||||
{
|
||||
case build_tools::RelativePath::buildTargetFolder:
|
||||
return getTargetFolder().getChildFile (path.toUnixStyle());
|
||||
|
||||
case build_tools::RelativePath::projectFolder:
|
||||
return project.getProjectFolder().getChildFile (path.toUnixStyle());
|
||||
|
||||
case build_tools::RelativePath::unknown:
|
||||
jassertfalse;
|
||||
}
|
||||
|
||||
return path.toUnixStyle();
|
||||
}
|
||||
|
||||
bool ProjectExporter::shouldFileBeCompiledByDefault (const File& file) const
|
||||
{
|
||||
return file.hasFileExtension (cOrCppFileExtensions)
|
||||
|
|
@ -497,6 +523,8 @@ void ProjectExporter::addTargetSpecificPreprocessorDefs (StringPairArray& defs,
|
|||
{
|
||||
defs.set ("JucePlugin_Enable_ARA", "1");
|
||||
}
|
||||
|
||||
linuxSubprocessHelperProperties.setCompileDefinitionIfNecessary (defs);
|
||||
}
|
||||
|
||||
void ProjectExporter::addDefaultPreprocessorDefs (StringPairArray& defs) const
|
||||
|
|
@ -545,7 +573,7 @@ Project::Item& ProjectExporter::getModulesGroup()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool isWebBrowserComponentEnabled (Project& project)
|
||||
static bool isWebBrowserComponentEnabled (const Project& project)
|
||||
{
|
||||
static String guiExtrasModule ("juce_gui_extra");
|
||||
|
||||
|
|
@ -608,6 +636,7 @@ void ProjectExporter::addToModuleLibPaths (const build_tools::RelativePath& path
|
|||
|
||||
void ProjectExporter::addToExtraSearchPaths (const build_tools::RelativePath& pathFromProjectFolder, int index)
|
||||
{
|
||||
jassert (pathFromProjectFolder.getRoot() == build_tools::RelativePath::projectFolder);
|
||||
addProjectPathToBuildPathList (extraSearchPaths, pathFromProjectFolder, index);
|
||||
}
|
||||
|
||||
|
|
@ -1083,3 +1112,115 @@ String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& confi
|
|||
|
||||
return {};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
LinuxSubprocessHelperProperties::LinuxSubprocessHelperProperties (ProjectExporter& projectExporter)
|
||||
: owner (projectExporter)
|
||||
{}
|
||||
|
||||
bool LinuxSubprocessHelperProperties::shouldUseLinuxSubprocessHelper() const
|
||||
{
|
||||
const auto& project = owner.getProject();
|
||||
const auto& projectType = project.getProjectType();
|
||||
|
||||
return owner.isLinux()
|
||||
&& isWebBrowserComponentEnabled (project)
|
||||
&& ! (projectType.isCommandLineApp())
|
||||
&& ! (projectType.isGUIApplication());
|
||||
}
|
||||
|
||||
void LinuxSubprocessHelperProperties::deployLinuxSubprocessHelperSourceFilesIfNecessary() const
|
||||
{
|
||||
if (shouldUseLinuxSubprocessHelper())
|
||||
{
|
||||
const auto deployHelperSourceFile = [] (auto& sourcePath, auto& contents)
|
||||
{
|
||||
if (! sourcePath.isRoot() && ! sourcePath.getParentDirectory().exists())
|
||||
{
|
||||
sourcePath.getParentDirectory().createDirectory();
|
||||
}
|
||||
|
||||
build_tools::overwriteFileIfDifferentOrThrow (sourcePath, contents);
|
||||
};
|
||||
|
||||
const std::pair<File, const char*> sources[]
|
||||
{
|
||||
{ owner.resolveRelativePath (getSimpleBinaryBuilderSource()), BinaryData::juce_SimpleBinaryBuilder_cpp },
|
||||
{ owner.resolveRelativePath (getLinuxSubprocessHelperSource()), BinaryData::juce_LinuxSubprocessHelper_cpp }
|
||||
};
|
||||
|
||||
for (const auto& [path, source] : sources)
|
||||
{
|
||||
deployHelperSourceFile (path, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build_tools::RelativePath LinuxSubprocessHelperProperties::getLinuxSubprocessHelperSource() const
|
||||
{
|
||||
return build_tools::RelativePath { "make_helpers", build_tools::RelativePath::buildTargetFolder }
|
||||
.getChildFile ("juce_LinuxSubprocessHelper.cpp");
|
||||
}
|
||||
|
||||
void LinuxSubprocessHelperProperties::setCompileDefinitionIfNecessary (StringPairArray& defs) const
|
||||
{
|
||||
if (shouldUseLinuxSubprocessHelper())
|
||||
defs.set (useLinuxSubprocessHelperCompileDefinition, "1");
|
||||
}
|
||||
|
||||
build_tools::RelativePath LinuxSubprocessHelperProperties::getSimpleBinaryBuilderSource() const
|
||||
{
|
||||
return build_tools::RelativePath { "make_helpers", build_tools::RelativePath::buildTargetFolder }
|
||||
.getChildFile ("juce_SimpleBinaryBuilder.cpp");
|
||||
}
|
||||
|
||||
build_tools::RelativePath LinuxSubprocessHelperProperties::getLinuxSubprocessHelperBinaryDataSource() const
|
||||
{
|
||||
return build_tools::RelativePath ("pre_build", juce::build_tools::RelativePath::buildTargetFolder)
|
||||
.getChildFile ("juce_LinuxSubprocessHelperBinaryData.cpp");
|
||||
}
|
||||
|
||||
void LinuxSubprocessHelperProperties::addToExtraSearchPathsIfNecessary() const
|
||||
{
|
||||
if (shouldUseLinuxSubprocessHelper())
|
||||
{
|
||||
const auto subprocessHelperBinaryDir = getLinuxSubprocessHelperBinaryDataSource().getParentDirectory();
|
||||
owner.addToExtraSearchPaths (owner.rebaseFromBuildTargetToProjectFolder (subprocessHelperBinaryDir));
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<String> LinuxSubprocessHelperProperties::getParentDirectoryRelativeToBuildTargetFolder (build_tools::RelativePath rp)
|
||||
{
|
||||
jassert (rp.getRoot() == juce::build_tools::RelativePath::buildTargetFolder);
|
||||
const auto parentDir = rp.getParentDirectory().toUnixStyle();
|
||||
return parentDir == rp.toUnixStyle() ? std::nullopt : std::make_optional (parentDir);
|
||||
}
|
||||
|
||||
String LinuxSubprocessHelperProperties::makeSnakeCase (const String& s)
|
||||
{
|
||||
String result;
|
||||
result.preallocateBytes (128);
|
||||
|
||||
bool previousCharacterUnderscore = false;
|
||||
|
||||
for (const auto c : s)
|
||||
{
|
||||
if ( CharacterFunctions::isUpperCase (c)
|
||||
&& result.length() != 0
|
||||
&& ! (previousCharacterUnderscore))
|
||||
{
|
||||
result << "_";
|
||||
}
|
||||
|
||||
result << CharacterFunctions::toLowerCase (c);
|
||||
|
||||
previousCharacterUnderscore = c == '_';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String LinuxSubprocessHelperProperties::getBinaryNameFromSource (const build_tools::RelativePath& rp)
|
||||
{
|
||||
return makeSnakeCase (rp.getFileNameWithoutExtension());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue