Browse Source

Projucer: Add an option to enable clang-tidy in Android builds

v7.0.9
Tom Poole 2 years ago
parent
commit
e37d70934a
6 changed files with 35 additions and 7 deletions
  1. +3
    -1
      examples/DemoRunner/Builds/Android/app/build.gradle
  2. +3
    -1
      extras/AudioPerformanceTest/Builds/Android/app/build.gradle
  3. +3
    -1
      extras/AudioPluginHost/Builds/Android/app/build.gradle
  4. +3
    -1
      extras/NetworkGraphicsDemo/Builds/Android/app/build.gradle
  5. +22
    -3
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h
  6. +1
    -0
      extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h

+ 3
- 1
examples/DemoRunner/Builds/Android/app/build.gradle View File

@@ -1,8 +1,10 @@
apply plugin: 'com.android.application'

def ndkVersionString = "25.2.9519653"

android {
compileSdkVersion 33
ndkVersion "25.2.9519653"
ndkVersion ndkVersionString
namespace "com.rmsl.jucedemorunner"
externalNativeBuild {
cmake {


+ 3
- 1
extras/AudioPerformanceTest/Builds/Android/app/build.gradle View File

@@ -1,8 +1,10 @@
apply plugin: 'com.android.application'

def ndkVersionString = "25.2.9519653"

android {
compileSdkVersion 33
ndkVersion "25.2.9519653"
ndkVersion ndkVersionString
namespace "com.juce.audioperformancetest"
externalNativeBuild {
cmake {


+ 3
- 1
extras/AudioPluginHost/Builds/Android/app/build.gradle View File

@@ -1,8 +1,10 @@
apply plugin: 'com.android.application'

def ndkVersionString = "25.2.9519653"

android {
compileSdkVersion 33
ndkVersion "25.2.9519653"
ndkVersion ndkVersionString
namespace "com.juce.audiopluginhost"
externalNativeBuild {
cmake {


+ 3
- 1
extras/NetworkGraphicsDemo/Builds/Android/app/build.gradle View File

@@ -1,8 +1,10 @@
apply plugin: 'com.android.application'

def ndkVersionString = "25.2.9519653"

android {
compileSdkVersion 33
ndkVersion "25.2.9519653"
ndkVersion ndkVersionString
namespace "com.juce.networkgraphicsdemo"
externalNativeBuild {
cmake {


+ 22
- 3
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h View File

@@ -105,7 +105,7 @@ public:
androidReadMediaVideoPermission, androidExternalWritePermission,
androidInAppBillingPermission, androidVibratePermission, androidOtherPermissions, androidPushNotifications,
androidEnableRemoteNotifications, androidRemoteNotificationsConfigFile, androidEnableContentSharing, androidKeyStore,
androidKeyStorePass, androidKeyAlias, androidKeyAliasPass, gradleVersion, gradleToolchain, androidPluginVersion;
androidKeyStorePass, androidKeyAlias, androidKeyAliasPass, gradleVersion, gradleToolchain, gradleClangTidy, androidPluginVersion;
//==============================================================================
AndroidProjectExporter (Project& p, const ValueTree& t)
@@ -151,6 +151,7 @@ public:
androidKeyAliasPass (settings, Ids::androidKeyAliasPass, getUndoManager(), "android"),
gradleVersion (settings, Ids::gradleVersion, getUndoManager(), "7.5.1"),
gradleToolchain (settings, Ids::gradleToolchain, getUndoManager(), "clang"),
gradleClangTidy (settings, Ids::gradleClangTidy, getUndoManager(), false),
androidPluginVersion (settings, Ids::androidPluginVersion, getUndoManager(), "7.3.0"),
AndroidExecutable (getAppSettings().getStoredPath (Ids::androidStudioExePath, TargetOS::getThisOS()).get().toString())
{
@@ -171,6 +172,9 @@ public:
{ "clang", "gcc" },
{ "clang", "gcc" }),
"The toolchain that gradle should invoke for NDK compilation (variable model.android.ndk.tooclhain in app/build.gradle)");
props.add (new ChoicePropertyComponent (gradleClangTidy, "Use Clang-Tidy"),
"If enabled and the toolchain is clang this will run clang-tidy when compiling.");
}
//==============================================================================
@@ -680,10 +684,22 @@ private:
mo << "apply plugin: 'com.android." << (isLibrary() ? "library" : "application") << "'" << newLine << newLine;
// CMake 3.22 will fail to build Android projects that set ANDROID_ARM_MODE unless NDK 24+ is used
mo << "def ndkVersionString = \"25.2.9519653\"" << newLine << newLine;
if (gradleClangTidy.get() && gradleToolchain.get().toString() == "clang")
mo << "Properties properties = new Properties()" << newLine
<< "properties.load(project.rootProject.file(\"local.properties\").newDataInputStream())" << newLine
<< "def llvmDir = \"${properties.getProperty('sdk.dir')}/ndk/${ndkVersionString}/toolchains/llvm\"" << newLine
<< "def clangTidySearch = fileTree(llvmDir).filter { file -> file.name.matches('^clang-tidy(.exe)?$') }" << newLine
<< "if (clangTidySearch.size() != 1) {" << newLine
<< " throw new GradleException(\"Could not locate a unique clang-tidy in ${llvmDir}\")" << newLine
<< "}" << newLine
<< "def clangTidy = clangTidySearch.getSingleFile().getAbsolutePath()" << newLine << newLine;
mo << "android {" << newLine;
mo << " compileSdkVersion " << static_cast<int> (androidTargetSDK.get()) << newLine;
// CMake 3.22 will fail to build Android projects that set ANDROID_ARM_MODE unless NDK 24+ is used
mo << " ndkVersion \"25.2.9519653\"" << newLine;
mo << " ndkVersion ndkVersionString" << newLine;
mo << " namespace " << project.getBundleIdentifierString().toLowerCase().quoted() << newLine;
mo << " externalNativeBuild {" << newLine;
mo << " cmake {" << newLine;
@@ -1488,6 +1504,9 @@ private:
cmakeArgs.add ("\"-DANDROID_ARM_MODE=arm\"");
cmakeArgs.add ("\"-DANDROID_ARM_NEON=TRUE\"");
if (isClang && gradleClangTidy.get())
cmakeArgs.add ("\"-DCMAKE_CXX_CLANG_TIDY=${clangTidy}\"");
auto cppStandard = [this]
{
auto projectStandard = project.getCppStandardString();


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

@@ -283,6 +283,7 @@ namespace Ids
const Identifier androidPluginVersion ("gradleWrapperVersion"); // old name is very confusing, but we need to remain backward compatible
DECLARE_ID (gradleToolchain);
DECLARE_ID (gradleToolchainVersion);
DECLARE_ID (gradleClangTidy);
DECLARE_ID (linuxExtraPkgConfig);
DECLARE_ID (font);
DECLARE_ID (colour);


Loading…
Cancel
Save