Skip to content

[WIP] llvm version param #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ddprof-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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++",
Expand Down
24 changes: 8 additions & 16 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

Expand Down
Loading