Skip to content

Commit

Permalink
[SkipCI][libwmf] Add port
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Jan 2, 2024
1 parent fd29ab1 commit 8ad94a1
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/libwmf.yml
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,11 @@ pdf2htmlEX also has a Java wrapper - [pdf2htmlEX-Android](https://github.com/Vil
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libgsf-ndk25-shared.svg?label=Maven%20Central%20libgsf-ndk25-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libgsf-ndk25-shared)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libgsf-ndk26-static.svg?label=Maven%20Central%20libgsf-ndk26-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libgsf-ndk26-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libgsf-ndk26-shared.svg?label=Maven%20Central%20libgsf-ndk26-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libgsf-ndk26-shared)

#### [libwmf](https://github.com/caolanm/libwmf)

[![libwmf](https://github.com/ViliusSutkus89/ndkports/actions/workflows/libwmf.yml/badge.svg)](https://github.com/ViliusSutkus89/ndkports/actions/workflows/libwmf.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libwmf-ndk25-static.svg?label=Maven%20Central%20libwmf-ndk25-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libwmf-ndk25-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libwmf-ndk25-shared.svg?label=Maven%20Central%20libwmf-ndk25-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libwmf-ndk25-shared)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libwmf-ndk26-static.svg?label=Maven%20Central%20libwmf-ndk26-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libwmf-ndk26-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libwmf-ndk26-shared.svg?label=Maven%20Central%20libwmf-ndk26-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libwmf-ndk26-shared)
42 changes: 42 additions & 0 deletions buildSrc/src/main/kotlin/com/android/ndkports/GetPkgConfig.kt
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
}
210 changes: 210 additions & 0 deletions libwmf/build.gradle.kts
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 added libwmf/v0.2.13.tar.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ include(":spiro")
include(":openlibm")
include(":fontforge")
include(":pdf2htmlEX")
include("libgsf")
include(":libgsf")
include(":libwmf")

0 comments on commit 8ad94a1

Please sign in to comment.