Skip to content

Commit

Permalink
Add fontconfig port
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Oct 31, 2023
1 parent 9eb2c5d commit d71be4f
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/fontconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: fontconfig
on:
workflow_dispatch:
push:
paths:
- 'buildSrc/**'
- 'fontconfig/**'
- '.github/workflows/build.yml'
- '.github/workflows/fontconfig.yml'

jobs:
build:
name: fontconfig
uses: ./.github/workflows/build.yml
with:
package: fontconfig
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,11 @@ Figure out proper way to deliver per ABI headers.
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libiconv-ndk25-shared.svg?label=Maven%20Central%20libiconv-ndk25-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libiconv-ndk25-shared)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libiconv-ndk26-static.svg?label=Maven%20Central%20libiconv-ndk26-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libiconv-ndk26-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/libiconv-ndk26-shared.svg?label=Maven%20Central%20libiconv-ndk26-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:libiconv-ndk26-shared)

#### [Fontconfig](https://www.freedesktop.org/wiki/Software/fontconfig/)

[![fontconfig](https://github.com/ViliusSutkus89/ndkports/actions/workflows/fontconfig.yml/badge.svg)](https://github.com/ViliusSutkus89/ndkports/actions/workflows/fontconfig.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/fontconfig-ndk25-static.svg?label=Maven%20Central%20fontconfig-ndk25-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:fontconfig-ndk25-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/fontconfig-ndk25-shared.svg?label=Maven%20Central%20fontconfig-ndk25-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:fontconfig-ndk25-shared)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/fontconfig-ndk26-static.svg?label=Maven%20Central%20fontconfig-ndk26-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:fontconfig-ndk26-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/fontconfig-ndk26-shared.svg?label=Maven%20Central%20fontconfig-ndk26-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:fontconfig-ndk26-shared)
137 changes: 137 additions & 0 deletions fontconfig/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import com.android.ndkports.CMakeCompatibleVersion
import com.android.ndkports.MesonPortTask
import com.android.ndkports.PrefabSysrootPlugin
import org.gradle.jvm.tasks.Jar

val portVersion = "2.14.2"

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")
implementation("com.viliussutkus89.ndk.thirdparty:freetype${ndkVersionSuffix}-static:2.13.2-beta-2")
implementation("com.viliussutkus89.ndk.thirdparty:libpng${ndkVersionSuffix}-static:1.6.40-beta-2")
implementation("com.viliussutkus89.ndk.thirdparty:libexpat${ndkVersionSuffix}-static:2.5.0-beta-1")
}

ndkPorts {
ndkPath.set(File(project.findProperty("ndkPath") as String))
minSdkVersion.set(rootProject.extra.get("minSdkSupportedByNdk").toString().toInt())
source.set(project.file("${name}-${portVersion}.tar.xz"))
}

tasks.prefab {
generator.set(PrefabSysrootPlugin::class.java)
}

fun File.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): File {
writeText(readText().replace(oldValue, newValue, ignoreCase))
return this
}

tasks.extractSrc {
doLast {
outDir.get().asFile.resolve("fonts.conf.in").replace("<cachedir>@FC_CACHEDIR@</cachedir>", "")
}
}

tasks.register<MesonPortTask>("buildPort") {
meson { }

doLast {
// @TODO: verify other ABIs have matching assets
val dst = project.buildDir.resolve("assets/fontconfig").apply { mkdirs() }
val iDir = installDirectoryFor(com.android.ndkports.Abi.Arm)
listOf(iDir.resolve("etc"), iDir.resolve("share")).forEach {
it.copyRecursively(dst.resolve(it.name)) { file, exception ->
if (exception !is FileAlreadyExistsException) {
throw exception
}
if (!file.readBytes().contentEquals(exception.file.readBytes())) {
throw exception
}
OnErrorAction.SKIP
}
}
}
}

tasks.prefabPackage {
version.set(CMakeCompatibleVersion.parse(portVersion))

licensePath.set("COPYING")

modules {
create("fontconfig") {
static.set(project.findProperty("libraryType") == "static")
dependencies.set(listOf(
"//freetype:freetype",
"//libpng:png16",
"//libexpat:expat",
))
}
}
}

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("Fontconfig")
description.set("Fontconfig is a library for configuring and customizing font access.")
url.set("https://www.freedesktop.org/wiki/Software/fontconfig/")
licenses {
// Poppler licenses
license {
name.set("MIT")
url.set("https://gitlab.freedesktop.org/fontconfig/fontconfig/-/raw/2.14.2/COPYING")
distribution.set("repo")
}
}
developers {
// Developer list obtained from:
// https://gitlab.freedesktop.org/fontconfig/fontconfig/-/raw/2.14.2/AUTHORS
developer {
name.set("Keith Packard")
email.set("keithp@keithp.com")
}
developer {
name.set("Patrick Lam")
email.set("plam@mit.edu")
}
}
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 fontconfig/fontconfig-2.14.2.tar.xz
Binary file not shown.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ include(":libjpeg-turbo")
include(":libtiff")
include(":pixman")
include(":libexpat")
include(":fontconfig")
include(":lcms2")
include(":openjpeg")
include(":fribidi")
Expand Down

0 comments on commit d71be4f

Please sign in to comment.