diff --git a/buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt b/buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt deleted file mode 100644 index 4c34d96..0000000 --- a/buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.android.ndkports - -import java.io.File - -data class PkgConfig( - val cflags: String, - val libs: String, -) -private fun callPkgConfig(arguments: List, pkgConfigLibDir: String): String { - val pb = ProcessBuilder(arguments).redirectErrorStream(true) - pb.environment()["PKG_CONFIG_LIBDIR"] = pkgConfigLibDir - - val result = pb.start() - val status = result.waitFor(); - val output = result.inputStream.bufferedReader().use { it.readText() }.trim() - if (status != 0) { - throw RuntimeException("PkgConfigHelper failed with:\n$output") - } - return output -} - -fun getPkgConfig( - packageName: String, - generatedDependenciesDir: File, - isStatic: Boolean, -): Map { - val config = mutableMapOf() - val arguments = mutableListOf("pkg-config", packageName) - if (isStatic) - arguments.add("--static") - generatedDependenciesDir.listFiles()?.forEach { generatedDirectory -> - val triple = generatedDirectory.name - val pkgConfigLibDir = generatedDirectory.resolve("lib/pkgconfig").absoluteFile - assert(pkgConfigLibDir.exists()) - - config[triple] = PkgConfig( - cflags = callPkgConfig(arguments + "--cflags", pkgConfigLibDir = pkgConfigLibDir.path), - libs = callPkgConfig(arguments + "--libs", pkgConfigLibDir = pkgConfigLibDir.path), - ) - } ?: throw RuntimeException("Generated dependencies directory is empty!\n") - return config -} diff --git a/libwmf/build.gradle.kts b/libwmf/build.gradle.kts index a9afdf7..c4f84ac 100644 --- a/libwmf/build.gradle.kts +++ b/libwmf/build.gradle.kts @@ -1,4 +1,6 @@ -import com.android.ndkports.* +import com.android.ndkports.AutoconfPortTask +import com.android.ndkports.CMakeCompatibleVersion +import com.android.ndkports.PrefabSysrootPlugin import org.gradle.jvm.tasks.Jar val portVersion = "0.2.13" @@ -33,17 +35,7 @@ tasks.prefab { val buildTask = tasks.register("buildPort") { val generatedDependencies = prefabGenerated.get().asFile - - // libwmf can't find freetype - lateinit var freetypePkgConfig: Map - doFirst { - freetypePkgConfig = getPkgConfig( - packageName = "freetype2", - generatedDependenciesDir = generatedDependencies, - isStatic = project.findProperty("libraryType") == "static" - ) - } - + val isStatic = project.findProperty("libraryType") == "static" autoconf { val generated = generatedDependencies.resolve(toolchain.abi.triple) args( @@ -52,10 +44,9 @@ val buildTask = tasks.register("buildPort") { "--with-png=$generated", "--with-jpeg=$generated", ) - freetypePkgConfig[toolchain.abi.triple]?.let { - env["CFLAGS"] = it.cflags - env["LDFLAGS"] = it.libs - } + env["ac_cv_path_FREETYPE_CONFIG"] = "pkg-config freetype2" + if (isStatic) + env["ac_cv_path_FREETYPE_CONFIG"] += " --static" } }