diff --git a/ddprof-lib/build.gradle b/ddprof-lib/build.gradle index 9fd8e44f..7c9fdd4d 100644 --- a/ddprof-lib/build.gradle +++ b/ddprof-lib/build.gradle @@ -290,7 +290,8 @@ tasks.register('javadocJar', Jar) { tasks.register('scanBuild', Exec) { workingDir "${projectDir}/src/test/make" - commandLine 'scan-build' + def llvmVersion = project.findProperty('llvm.version') ?: '11' + commandLine "scan-build-${llvmVersion}" args "-o", "${projectDir}/build/reports/scan-build", "--force-analyze-debug-code", "--use-analyzer", "/usr/bin/clang++", diff --git a/gradle/spotless.gradle b/gradle/spotless.gradle index 3db49fb2..30a4a10e 100644 --- a/gradle/spotless.gradle +++ b/gradle/spotless.gradle @@ -55,29 +55,21 @@ spotless { } if (project.plugins.hasPlugin('cpp-library') || project.plugins.hasPlugin('cpp-application')) { cpp { - def clangVersion = null + def llvmVersion = project.findProperty('llvm.version') ?: '11' + def clangFormatBinary = "clang-format-${llvmVersion}" + try { - def checkClangFormat = ['clang-format', '--version'].execute() + def checkClangFormat = [clangFormatBinary, '--version'].execute() checkClangFormat.waitFor() - if (checkClangFormat.exitValue() == 0) { - def versionOutput = checkClangFormat.text.trim() - // Extract the version number from the output using regex - def versionMatcher = (versionOutput =~ /clang-format version (\d+\.\d+\.\d+.*)/) - if (versionMatcher) { - clangVersion = versionMatcher[0][1] // The version is captured in group 1 - } + if (checkClangFormat.exitValue() != 0) { + throw new GradleException("${clangFormatBinary} is not available. Please install Clang ${llvmVersion}.") } } catch (Throwable t) { - throw new GradleException("Clang-format is not available. Please install Clang 11.") - } - - // Check if the version is 11.0.0 or higher - if (clangVersion && !clangVersion.startsWith("11")) { - throw new GradleException("Clang version ${clangVersion} is not supported. Please install Clang 11.") + throw new GradleException("${clangFormatBinary} is not available. Please install Clang ${llvmVersion}.") } target 'src/main/cpp/**' - clangFormat(clangVersion).configFile(configPath + '/enforcement/.clang-format') + clangFormat().configFile(configPath + '/enforcement/.clang-format') } }