From e74f5d227c57ad1b057bb73876a61f1a201ef1f1 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Tue, 2 Jan 2024 05:10:56 +0200 Subject: [PATCH] [SkipCI][libwmf] remove GetPkgConfig helper, supply FREETYPE_CONFIG envvar to configure instead --- .../com/android/ndkports/GetPkgConfig.kt | 42 ------------------- libwmf/build.gradle.kts | 23 ++++------ 2 files changed, 7 insertions(+), 58 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt 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" } }