mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android Studio exporter: fixed and refactored the way include paths are added to build.gradle.
This commit is contained in:
parent
60478175d6
commit
0ef8bdb08f
1 changed files with 31 additions and 22 deletions
|
|
@ -336,7 +336,7 @@ private:
|
|||
struct GradleHeaderIncludePath : public GradleStatement
|
||||
{
|
||||
GradleHeaderIncludePath (const String& path)
|
||||
: GradleStatement ("cppFlags.add(\"-I" + sanitisePath (path) + "\".toString())") {}
|
||||
: GradleStatement ("cppFlags.add(\"-I${project.rootDir}/" + sanitisePath (path) + "\".toString())") {}
|
||||
};
|
||||
|
||||
struct GradleLibrarySearchPath : public GradleStatement
|
||||
|
|
@ -563,21 +563,11 @@ private:
|
|||
ndkSettings->add<GradleString> ("toolchain", toolchain);
|
||||
ndkSettings->add<GradleString> ("stl", isClang ? "c++_static" : "gnustl_static");
|
||||
|
||||
ndkSettings->addChildObject (getNdkJuceExtraProperties());
|
||||
|
||||
addAllNdkCompilerSettings (ndkSettings);
|
||||
|
||||
return ndkSettings;
|
||||
}
|
||||
|
||||
GradleObject* getNdkJuceExtraProperties() const
|
||||
{
|
||||
auto ext = new GradleObject ("ext");
|
||||
ext->add<GradleString> ("juceRootDir", "${project.rootDir}/../../../../");
|
||||
ext->add<GradleString> ("juceModuleDir", "${juceRootDir}/modules");
|
||||
return ext;
|
||||
}
|
||||
|
||||
void addAllNdkCompilerSettings (GradleObject* ndk) const
|
||||
{
|
||||
addNdkCppFlags (ndk);
|
||||
|
|
@ -608,16 +598,33 @@ private:
|
|||
|
||||
void addNdkHeaderIncludePaths (GradleObject* ndk) const
|
||||
{
|
||||
const char* basicJucePaths[] = { "${project.rootDir}/app", "${ext.juceRootDir}", "${ext.juceModuleDir}", nullptr };
|
||||
StringArray includePaths (basicJucePaths);
|
||||
StringArray includePaths;
|
||||
|
||||
includePaths.add (sanitisePath (project.getProjectFolder().getFullPathName() + "/Source/"));
|
||||
includePaths.add (sanitisePath (project.getProjectFolder().getFullPathName() + "/../../JUCE/modules/"));
|
||||
for (const auto& cppFile : getAllCppFilesToBeIncludedWithPath())
|
||||
includePaths.addIfNotAlreadyThere (cppFile.getParentDirectory().toUnixStyle());
|
||||
|
||||
for (const auto& path : includePaths)
|
||||
ndk->add<GradleHeaderIncludePath> (path);
|
||||
}
|
||||
|
||||
Array<RelativePath> getAllCppFilesToBeIncludedWithPath() const
|
||||
{
|
||||
Array<RelativePath> cppFiles;
|
||||
|
||||
struct NeedsToBeIncludedWithPathPredicate
|
||||
{
|
||||
bool operator() (const Project::Item& projectItem) const
|
||||
{
|
||||
return projectItem.shouldBeAddedToTargetProject() && ! projectItem.isModuleCode();
|
||||
}
|
||||
};
|
||||
|
||||
for (const auto& group : getAllGroups())
|
||||
findAllProjectItemsWithPredicate (group, cppFiles, NeedsToBeIncludedWithPathPredicate());
|
||||
|
||||
return cppFiles;
|
||||
}
|
||||
|
||||
void addNdkLinkerFlags (GradleObject* ndk) const
|
||||
{
|
||||
const auto linkerFlags = StringArray::fromTokens (getExtraLinkerFlagsString(), " ", "");
|
||||
|
|
@ -700,7 +707,7 @@ private:
|
|||
|
||||
ndkSettings->add<GradleCppFlag> ("-O" + config.getGCCOptimisationFlag());
|
||||
|
||||
for (const auto& path : config.getHeaderSearchPaths())
|
||||
for (const auto& path : getHeaderSearchPaths (config))
|
||||
ndkSettings->add<GradleHeaderIncludePath> (path);
|
||||
|
||||
for (const auto& path : config.getLibrarySearchPaths())
|
||||
|
|
@ -718,6 +725,14 @@ private:
|
|||
buildConfig->addChildObject (ndkSettings);
|
||||
}
|
||||
|
||||
StringArray getHeaderSearchPaths (const BuildConfiguration& config) const
|
||||
{
|
||||
StringArray paths (extraSearchPaths);
|
||||
paths.addArray (config.getHeaderSearchPaths());
|
||||
paths = getCleanedStringArray (paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
GradleObject* getAndroidSigningConfigs() const
|
||||
{
|
||||
auto releaseConfig = new GradleObject ("create(\"releaseConfig\")");
|
||||
|
|
@ -806,12 +821,6 @@ private:
|
|||
writeXmlOrThrow (*manifest, folder.getChildFile ("app/src/main/AndroidManifest.xml"), "utf-8", 100, true);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct ShouldBeAddedToProjectPredicate
|
||||
{
|
||||
bool operator() (const Project::Item& projectItem) const { return projectItem.shouldBeAddedToTargetProject(); }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
const File androidStudioExecutable;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue