Skip to content

Commit

Permalink
[wvWare] Add port
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Jan 2, 2024
1 parent e74f5d2 commit 0ff64e8
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/wvware.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: wvWare
on:
workflow_dispatch:
push:
paths:
- 'buildSrc/**'
- 'wvware/**'
- '.github/workflows/build.yml'
- '.github/workflows/wvware.yml'

jobs:
build:
name: wvWare
uses: ./.github/workflows/build.yml
with:
package: wvware
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,13 @@ 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/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)

#### [wvWare](http://wvware.sourceforge.net)

wvWare has a Java wrapper - [wvWare-Android](https://github.com/ViliusSutkus89/wvWare-Android)

[![wvWare](https://github.com/ViliusSutkus89/ndkports/actions/workflows/wvWare.yml/badge.svg)](https://github.com/ViliusSutkus89/ndkports/actions/workflows/wvWare.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/wvWare-ndk25-static.svg?label=Maven%20Central%20wvWare-ndk25-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:wvWare-ndk25-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/wvWare-ndk25-shared.svg?label=Maven%20Central%20wvWare-ndk25-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:wvWare-ndk25-shared)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/wvWare-ndk26-static.svg?label=Maven%20Central%20wvWare-ndk26-static)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:wvWare-ndk26-static)
[![Maven Central](https://img.shields.io/maven-central/v/com.viliussutkus89.ndk.thirdparty/wvWare-ndk26-shared.svg?label=Maven%20Central%20wvWare-ndk26-shared)](https://search.maven.org/search?q=g:com.viliussutkus89.ndk.thirdparty%20AND%20a:wvWare-ndk26-shared)
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ include(":fontforge")
include(":pdf2htmlEX")
include(":libgsf")
include(":libwmf")
include(":wvWare")
198 changes: 198 additions & 0 deletions wvWare/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import com.android.ndkports.AutoconfPortTask
import com.android.ndkports.CMakeCompatibleVersion
import com.android.ndkports.PrefabSysrootPlugin
import org.gradle.jvm.tasks.Jar

val portVersion = "1.2.9"

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:libgsf${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:1.14.51-beta-1")
implementation("com.viliussutkus89.ndk.thirdparty:libpng${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:1.6.40-beta-7")
implementation("com.viliussutkus89.ndk.thirdparty:libwmf${ndkVersionSuffix}${dependencyLibraryTypeSuffix}:0.2.13-beta-1")
}

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

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
}

fun File.patch(patch: String): File {
patch(projectDir.resolve("patches/$portVersion").resolve(patch))
return this
}

fun File.patch(patch: File): File {
val pb = ProcessBuilder(
if (isFile) listOf("patch", "-p0", absolutePath)
else listOf("patch", "-p0")
)

if (isDirectory)
pb.directory(absoluteFile)

val process = pb.start()
process.outputStream.writer().use {
it.write(patch.readText())
}
process.errorStream.bufferedReader().use {
println(it.readText())
}
process.inputStream.bufferedReader().use {
println(it.readText())
}
if (process.waitFor() != 0) {
throw RuntimeException("Patch failed!\n")
}
return this
}

tasks.extractSrc {
doLast {
val srcDir = outDir.get().asFile

srcDir.resolve("GNUmakefile.am").patch("skip-programs.patch")
srcDir.resolve("wv.h").patch("printf-redirect.patch")

srcDir.resolve("config.sub").delete()
val pb = ProcessBuilder(srcDir.resolve("autogen.sh").absolutePath).directory(srcDir)
pb.environment()["NOCONFIGURE"] = "1"
if (pb.start().waitFor() != 0)
throw RuntimeException("autogen.sh failed!")
}
}

val buildTask = tasks.register<AutoconfPortTask>("buildPort") {
val generatedDependencies = prefabGenerated.get().asFile
val isStatic = project.findProperty("libraryType") == "static"
autoconf {
val generated = generatedDependencies.resolve(toolchain.abi.triple)
arg("--with-libwmf=$generated")
env["ac_cv_path_LIBWMF_CONFIG"] = "pkg-config libwmf"
if (isStatic)
env["ac_cv_path_LIBWMF_CONFIG"] += " --static"

// wvWare can't find libpng
generated.let {
env["CFLAGS"] = "-I${generated.resolve("include")}"
env["LDFLAGS"] = "-L${generated.resolve("lib")}"
}

env["CFLAGS"] += " -Wno-error=incompatible-function-pointer-types"
}

doLast {
com.android.ndkports.Abi.values().forEach { abi ->
val installDir = installDirectoryFor(abi)
buildDirectoryFor(abi).resolve("config.h").copyTo(
target = installDir.resolve("include/wv/config.h"), overwrite = true
)

installDir.resolve("lib/pkgconfig/wv-1.0.pc").let { pc ->
pc.replace("-lpng", "")
pc.replace("Requires:", "Requires: libpng16")
}
}
}
}

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

licensePath.set("COPYING")

dependencies.set(mapOf(
"libgsf" to "1",
"libpng" to "1",
"libwmf" to "1",
))
modules {
create("wv") {
includesPerAbi.set(true)
static.set(project.findProperty("libraryType") == "static")
dependencies.set(listOf(
"//libgsf:gsf-1",
"//libpng:png16",
"//libwmf:wmf",
"//libwmf:wmflite",
))
}
}
}

val packageSources = tasks.register<Jar>("packageSources") {
archiveClassifier.set("sources")
from(projectDir.resolve("build.gradle.kts"))
from(projectDir.resolve("patches/$portVersion"))
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("wvWare")
description.set("Library to load and parse Word 2000, 97, 95 and 6 files")
url.set("http://wvware.sourceforge.net")
licenses {
license {
name.set("GPLv2")
url.set("http://www.gnu.org/copyleft/gpl.html")
distribution.set("repo")
}
}
developers {
// Developer list obtained from:
// http://wvware.sourceforge.net/#dom
developer {
name.set("Dom Lachowicz")
}
developer {
name.set("Caolán McNamara")
}
developer {
name.set("Martin Vermeer")
}
}
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"))
}
}
}
12 changes: 12 additions & 0 deletions wvWare/patches/1.2.9/printf-redirect.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- wv.h
+++ wv.h
@@ -10,6 +10,9 @@
extern "C" {
#endif

+int printfRedirect(const char* __fmt, ...);
+#define printf printfRedirect
+
/* The structure below is used to refer to a wvStream. Usually,
* kind = GSF_STREAM,
* but if we can't open a file using LibGSF, we fall back to the old file-based
11 changes: 11 additions & 0 deletions wvWare/patches/1.2.9/skip-programs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- GNUmakefile.am
+++ GNUmakefile.am
@@ -18,8 +18,6 @@ wvhdr_HEADERS = wv.h

bin_SCRIPTS = wvCleanLatex wvHtml wvDocBook wvAbw wvMime wvPS wvDVI wvLatex wvPDF wvText wvWml

-bin_PROGRAMS = wvWare wvRTF wvConvert wvVersion wvSummary
-
lib_LTLIBRARIES = libwv.la

GETOPT = @LIBOBJS@
Binary file added wvWare/wv-1.2.9.tar.gz
Binary file not shown.

0 comments on commit 0ff64e8

Please sign in to comment.