Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterofbread committed Nov 24, 2024
1 parent b0dd46c commit a1025da
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,13 @@ object Static {
): List<String> {
require(cflags || libs)

val executable_name =
if (Platform.getCurrent() == Platform.WINDOWS) "pkgconf.exe"
else "pkg-config"

val process_builder: ProcessBuilder = ProcessBuilder(
listOfNotNull(
findExecutable("pkg-config", "pkgconf.exe"),
findExecutable(executable_name),
if (cflags) "--cflags" else null,
if (libs) "--libs" else null
) + package_names
Expand Down Expand Up @@ -547,22 +551,18 @@ object Static {
}
}

private fun findExecutable(vararg names: String): String {
require(names.isNotEmpty())

private fun findExecutable(name: String): String {
val path_split: Char =
if (Platform.getCurrent() == Platform.WINDOWS) ';'
else ':'

for (dir in System.getenv("PATH")?.split(path_split).orEmpty()) {
for (name in names) {
val file: File = File(dir).resolve(name)
if (file.isFile) {
return file.absolutePath
}
val file: File = File(dir).resolve(name)
if (file.isFile) {
return file.absolutePath
}
}

return names.first()
return name
}
}

0 comments on commit a1025da

Please sign in to comment.