Skip to content

Commit

Permalink
Add Linux support to libclang path finder
Browse files Browse the repository at this point in the history
The libclang path finder has been updated with a new Linux-specific clause. It now utilizes ProcessBuilder to locate the "libclang.so" file and return its directory. This adds support for Linux operating systems in the build script.
  • Loading branch information
Alexandre Mommers committed Dec 28, 2023
1 parent c9747d3 commit 20eff8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions klang/klang/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ private fun inferPlatformClangPath(): Path? {
} catch (ioExp: IOException) {
logger.error("fail to find libclang path " + ioExp.stackTraceToString())
}
} else if (os == "Linux") {
val pb: ProcessBuilder = ProcessBuilder().command("/usr/bin/locate", "libclang.so")
val proc = pb.start()
val str = String(proc.inputStream.readAllBytes())
val dir = Paths.get(str.trim { it <= ' ' }.split("\n").first())
.parent
if (Files.isDirectory(dir)) {
return dir
}
} else {
logger.error("operating system $os not yet supported")
}
Expand Down

0 comments on commit 20eff8c

Please sign in to comment.