-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd29ab1
commit 8ad94a1
Showing
6 changed files
with
278 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: libwmf | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'buildSrc/**' | ||
- 'libwmf/**' | ||
- '.github/workflows/build.yml' | ||
- '.github/workflows/libwmf.yml' | ||
|
||
jobs: | ||
build: | ||
name: libwmf | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package: libwmf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.android.ndkports | ||
|
||
import java.io.File | ||
|
||
data class PkgConfig( | ||
val cflags: String, | ||
val libs: String, | ||
) | ||
private fun callPkgConfig(arguments: List<String>, 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<String, PkgConfig> { | ||
val config = mutableMapOf<String, PkgConfig>() | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
import com.android.ndkports.* | ||
import org.gradle.jvm.tasks.Jar | ||
|
||
val portVersion = "0.2.13" | ||
|
||
group = rootProject.group | ||
version = "${portVersion}-beta-1" | ||
|
||
plugins { | ||
id("maven-publish") | ||
id("signing") | ||
id("com.android.ndkports.NdkPorts") | ||
} | ||
|
||
dependencies { | ||
val ndkVersionSuffix = rootProject.extra.get("ndkVersionSuffix") | ||
val dependencyLibraryTypeSuffix = rootProject.extra.get("dependencyLibraryTypeSuffix") | ||
implementation("com.viliussutkus89.ndk.thirdparty:freetype${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:2.13.2-beta-8") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libexpat${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:2.5.0-beta-4") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libjpeg-turbo${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:3.0.1-beta-3") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libpng${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:1.6.40-beta-7") | ||
} | ||
|
||
ndkPorts { | ||
ndkPath.set(File(project.findProperty("ndkPath") as String)) | ||
minSdkVersion.set(rootProject.extra.get("minSdkSupportedByNdk").toString().toInt()) | ||
source.set(project.file("v${portVersion}.tar.gz")) | ||
} | ||
|
||
tasks.prefab { | ||
generator.set(PrefabSysrootPlugin::class.java) | ||
} | ||
|
||
val buildTask = tasks.register<AutoconfPortTask>("buildPort") { | ||
val generatedDependencies = prefabGenerated.get().asFile | ||
|
||
// libwmf can't find freetype | ||
lateinit var freetypePkgConfig: Map<String, PkgConfig> | ||
doFirst { | ||
freetypePkgConfig = getPkgConfig( | ||
packageName = "freetype2", | ||
generatedDependenciesDir = generatedDependencies, | ||
isStatic = project.findProperty("libraryType") == "static" | ||
) | ||
} | ||
|
||
autoconf { | ||
val generated = generatedDependencies.resolve(toolchain.abi.triple) | ||
args( | ||
"--with-expat=$generated", | ||
"--with-freetype=$generated", | ||
"--with-png=$generated", | ||
"--with-jpeg=$generated", | ||
) | ||
freetypePkgConfig[toolchain.abi.triple]?.let { | ||
env["CFLAGS"] = it.cflags | ||
env["LDFLAGS"] = it.libs | ||
} | ||
} | ||
} | ||
|
||
tasks.prefabPackage { | ||
version.set(CMakeCompatibleVersion.parse(portVersion)) | ||
|
||
licensePath.set("COPYING") | ||
|
||
dependencies.set(mapOf( | ||
"freetype" to "1", | ||
"libexpat" to "1", | ||
"libjpeg-turbo" to "1", | ||
"libpng" to "1", | ||
)) | ||
|
||
modules { | ||
create("wmf") { | ||
static.set(project.findProperty("libraryType") == "static") | ||
dependencies.set(listOf( | ||
"//freetype:freetype", | ||
"//libexpat:expat", | ||
"//libjpeg-turbo:jpeg", | ||
"//libpng:png", | ||
)) | ||
} | ||
create("wmflite") { | ||
static.set(project.findProperty("libraryType") == "static") | ||
dependencies.set(listOf( | ||
"//freetype:freetype", | ||
"//libexpat:expat", | ||
"//libjpeg-turbo:jpeg", | ||
"//libpng:png", | ||
)) | ||
} | ||
} | ||
} | ||
|
||
val packageSources = tasks.register<Jar>("packageSources") { | ||
archiveClassifier.set("sources") | ||
from(projectDir.resolve("build.gradle.kts")) | ||
from(ndkPorts.source) | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("release") { | ||
from(components["prefab"]) | ||
artifactId += rootProject.extra.get("ndkVersionSuffix") | ||
artifactId += rootProject.extra.get("libraryTypeSuffix") | ||
artifact(packageSources) | ||
pom { | ||
name.set("libwmf") | ||
description.set("library for converting WMF files") | ||
url.set("https://github.com/caolanm/libwmf") | ||
licenses { | ||
license { | ||
name.set("GPLv2") | ||
url.set("https://github.com/caolanm/libwmf/blob/v${portVersion}/COPYING") | ||
distribution.set("repo") | ||
} | ||
} | ||
developers { | ||
// Developer list obtained from: | ||
// https://github.com/caolanm/libwmf/blob/v0.2.13/CREDITS | ||
developer { | ||
name.set("Thomas Boutell") | ||
} | ||
developer { | ||
id.set("allegro") | ||
} | ||
developer { | ||
id.set("Gdtclft") | ||
} | ||
developer { | ||
id.set("wine") | ||
} | ||
developer { | ||
name.set("Bjorn Reese") | ||
} | ||
developer { | ||
name.set("Daniel Stenberg") | ||
} | ||
developer { | ||
name.set("Caolan McNamara") | ||
} | ||
developer { | ||
name.set("Francis James Franklin") | ||
} | ||
developer { | ||
name.set("David Airlie") | ||
} | ||
developer { | ||
name.set("Frédéric Vivien") | ||
} | ||
developer { | ||
name.set("Martin Vermeer") | ||
} | ||
developer { | ||
name.set("Bob Friesenhahn") | ||
} | ||
developer { | ||
name.set("Raj Manandhar") | ||
} | ||
developer { | ||
name.set("Steven Michael Robbins") | ||
} | ||
developer { | ||
name.set("Steven Michael Robbins") | ||
} | ||
developer { | ||
name.set("Bob Bell") | ||
} | ||
developer { | ||
name.set("Albert Chin") | ||
} | ||
developer { | ||
name.set("Matej Vila") | ||
} | ||
developer { | ||
name.set("Benjamin Geer") | ||
} | ||
developer { | ||
name.set("Peter Ohlerich") | ||
} | ||
developer { | ||
name.set("Steve Oney") | ||
} | ||
developer { | ||
name.set("Michael Cree") | ||
} | ||
developer { | ||
name.set("Dom Lachowicz") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/ViliusSutkus89/ndkports") | ||
connection.set("scm:git:https://github.com/ViliusSutkus89/ndkports.git") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
System.getenv("SIGNING_KEY")?.let { signingKey -> | ||
signing { | ||
isRequired = true | ||
useInMemoryPgpKeys(signingKey, System.getenv("SIGNING_PASS")) | ||
sign(publishing.publications.findByName("release")) | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters