-
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
dbd4599
commit acabcf0
Showing
12 changed files
with
395 additions
and
0 deletions.
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,38 @@ | ||
name: poppler | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'buildSrc/**' | ||
- '.github/workflows/build.yml' | ||
- 'poppler/**' | ||
- '.github/workflows/poppler.yml' | ||
|
||
jobs: | ||
build-poppler-23_10_0: | ||
name: poppler 23.10.0 | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package: poppler | ||
version: '23.10.0' | ||
|
||
build-poppler-21_02_0: | ||
name: poppler 21.02.0 | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package: poppler | ||
version: '21.02.0' | ||
|
||
build-poppler-0_89_0: | ||
name: poppler 0.89.0 | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package: poppler | ||
version: '0.89.0' | ||
|
||
build-poppler-0_81_0: | ||
name: poppler 0.81.0 | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package: poppler | ||
version: '0.81.0' |
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
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,276 @@ | ||
import com.android.ndkports.CMakeCompatibleVersion | ||
import com.android.ndkports.CMakePortTask | ||
import com.android.ndkports.PrefabSysrootPlugin | ||
import org.gradle.jvm.tasks.Jar | ||
|
||
group = rootProject.group | ||
|
||
// Hardcode a list of available versions | ||
val portVersion = when(project.findProperty("packageVersion")) { | ||
"0.81.0" -> { | ||
version = "0.81.0-beta-1" | ||
"0.81.0" | ||
} | ||
"0.89.0" -> { | ||
version = "0.89.0-beta-1" | ||
"0.89.0" | ||
} | ||
"21.02.0" -> { | ||
version = "21.02.0-beta-1" | ||
"21.02.0" | ||
} | ||
"23.10.0" -> { | ||
version = "23.10.0-beta-1" | ||
"0.81.0" | ||
} | ||
// @TODO: | ||
else -> { | ||
version = "0.81.0-beta-1" | ||
"0.81.0" | ||
} | ||
} | ||
|
||
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-3") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libiconv${ndkVersionSuffix}-static:1.17-beta-1") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libpng${ndkVersionSuffix}-static:1.6.40-beta-4") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libjpeg-turbo${ndkVersionSuffix}-static:3.0.1-beta-1") | ||
implementation("com.viliussutkus89.ndk.thirdparty:libtiff${ndkVersionSuffix}-static:4.6.0-beta-2") | ||
implementation("com.viliussutkus89.ndk.thirdparty:openjpeg${ndkVersionSuffix}-static:2.5.0-beta-2") | ||
implementation("com.viliussutkus89.ndk.thirdparty:glib2${ndkVersionSuffix}-static:2.78.1-beta-2") | ||
implementation("com.viliussutkus89.ndk.thirdparty:cairo${ndkVersionSuffix}-static:1.18.0-beta-1") | ||
implementation("com.viliussutkus89.ndk.thirdparty:lcms2${ndkVersionSuffix}-static:2.15-beta-2") | ||
|
||
when (portVersion) { | ||
// 23.10.0 supports Android's native alternative of fontconfig | ||
"0.81.0", "0.89.0", "21.02.0" -> { | ||
implementation("com.viliussutkus89.ndk.thirdparty:fontconfig${ndkVersionSuffix}-static:2.14.2-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.findByName("extractSrc")?.dependsOn( | ||
tasks.register("extractAssets", com.android.ndkports.SourceExtractTask::class.java) { | ||
source.set(project.file("poppler-data-0.4.12.tar.gz")) | ||
outDir.set(buildDir.resolve("assets/poppler")) | ||
} | ||
) | ||
|
||
fun File.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): File { | ||
writeText(readText().replace(oldValue, newValue, ignoreCase)) | ||
return this | ||
} | ||
|
||
fun File.patch(patch: String) { | ||
patch(projectDir.resolve("patches/$portVersion").resolve(patch)) | ||
} | ||
|
||
fun File.patch(patch: 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") | ||
} | ||
} | ||
|
||
tasks.extractSrc { | ||
doLast { | ||
val srcDir = outDir.get().asFile | ||
when (portVersion) { | ||
"0.81.0", "0.89.0", "21.02.0" -> { | ||
srcDir.resolve("CMakeLists.txt").patch("fontconfig.patch") | ||
srcDir.resolve("CMakeLists.txt").patch("FindCairo.patch") | ||
srcDir.resolve("ConfigureChecks.cmake").patch("have_unistd_h.patch") | ||
} | ||
"0.89.0", "21.02.0" -> { | ||
TODO() | ||
} | ||
"23.10.0" -> { | ||
// https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md | ||
projectDir.resolve("CheckFileOffsetBits.cmake").copyTo( | ||
target = outDir.get().asFile.resolve("cmake/modules/CheckFileOffsetBits.cmake"), | ||
overwrite = true | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.prefab { | ||
generator.set(PrefabSysrootPlugin::class.java) | ||
} | ||
|
||
tasks.register<CMakePortTask>("buildPort") { | ||
when (portVersion) { | ||
"0.81.0", "0.89.0", "21.02.0" -> { | ||
cmake { | ||
args( | ||
"-DENABLE_UNSTABLE_API_ABI_HEADERS=ON", | ||
|
||
// poppler-gLib requires older GLib version. | ||
"-DENABLE_GLIB=OFF", | ||
) | ||
} | ||
doLast { | ||
com.android.ndkports.Abi.values().forEach { abi -> | ||
installDirectoryFor(abi) | ||
.resolve("include/android.${abi.abiName}/lib/pkgconfig/poppler.pc").appendText( | ||
"Requires: freetype2 libpng16 libturbojpeg libtiff-4 libopenjp2 glib-2.0 cairo lcms2 fontconfig" | ||
) | ||
} | ||
} | ||
} | ||
"23.10.0" -> { | ||
cmake { | ||
args( | ||
"-DENABLE_NSS3=OFF", | ||
"-DENABLE_GPGME=OFF", | ||
"-DENABLE_QT5=OFF", | ||
"-DENABLE_QT6=OFF", | ||
"-DENABLE_BOOST=OFF", | ||
"-DENABLE_LIBCURL=OFF", | ||
|
||
"-DENABLE_GLIB=OFF", | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
tasks.prefabPackage { | ||
version.set(CMakeCompatibleVersion.parse(portVersion)) | ||
|
||
licensePath.set("COPYING") | ||
|
||
modules { | ||
create("poppler") { | ||
static.set(project.findProperty("libraryType") == "static") | ||
dependencies.set(listOf( | ||
"//freetype:freetype", | ||
"//libpng:png16", | ||
"//libjpeg-turbo:turbojpeg", | ||
"//libtiff:tiff", | ||
"//openjpeg:openjp2", | ||
"//glib2:glib-2.0", | ||
"//cairo:cairo", | ||
"//lcms2:lcms2", | ||
"//fontconfig:fontconfig", | ||
)) | ||
} | ||
create("poppler-cpp") { | ||
static.set(project.findProperty("libraryType") == "static") | ||
dependencies.set(listOf(":poppler")) | ||
} | ||
} | ||
} | ||
|
||
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("Poppler") | ||
description.set("Poppler is a free software utility library for rendering Portable Document Format (PDF) documents. Poppler-data bundled.") | ||
url.set("https://poppler.freedesktop.org") | ||
licenses { | ||
// Poppler licenses | ||
license { | ||
name.set("GPLv2") | ||
url.set("https://cgit.freedesktop.org/poppler/poppler/plain/COPYING?h=poppler-21.02.0") | ||
distribution.set("repo") | ||
} | ||
license { | ||
name.set("GPLv3") | ||
url.set("https://cgit.freedesktop.org/poppler/poppler/plain/COPYING3?h=poppler-21.02.0") | ||
distribution.set("repo") | ||
} | ||
|
||
// Poppler-data licenses | ||
license { | ||
name.set("MIT") | ||
url.set("https://cgit.freedesktop.org/poppler/poppler-data/tree/COPYING?h=POPPLER_DATA_0_4_12") | ||
distribution.set("repo") | ||
} | ||
license { | ||
name.set("COPYING.adobe") | ||
url.set("https://cgit.freedesktop.org/poppler/poppler-data/tree/COPYING.adobe?h=POPPLER_DATA_0_4_12") | ||
distribution.set("repo") | ||
} | ||
license { | ||
name.set("GPLv2") | ||
url.set("https://cgit.freedesktop.org/poppler/poppler-data/tree/COPYING.gpl2?h=POPPLER_DATA_0_4_12") | ||
distribution.set("repo") | ||
} | ||
|
||
} | ||
developers { | ||
// Developer list obtained from: | ||
// https://gitlab.freedesktop.org/poppler/poppler/-/blob/poppler-21.02.0/AUTHORS | ||
// https://gitlab.freedesktop.org/poppler/poppler-data/-/blob/POPPLER_DATA_0_4_12/README | ||
developer { | ||
name.set("Derek Noonburg") | ||
email.set("derekn@foolabs.com") | ||
} | ||
developer { | ||
name.set("Albert Astals Cid") | ||
email.set("aacid@kde.org") | ||
} | ||
} | ||
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")) | ||
} | ||
} | ||
} |
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,13 @@ | ||
--- CMakeLists.txt 2023-11-03 12:33:39.721000000 +0200 | ||
+++ CMakeLists.txt 2023-11-03 12:34:02.079000000 +0200 | ||
@@ -156,8 +156,9 @@ | ||
endif() | ||
endif() | ||
|
||
-macro_optional_find_package(Cairo ${CAIRO_VERSION}) | ||
+pkg_search_module(CAIRO REQUIRED IMPORTED_TARGET cairo) | ||
if(CAIRO_FOUND) | ||
+ set(CAIRO_LIBRARIES PkgConfig::CAIRO) | ||
set(HAVE_CAIRO ${CAIRO_FOUND}) | ||
set(CAIRO_FEATURE "#define POPPLER_HAS_CAIRO 1") | ||
set(CAIRO_REQ "cairo") |
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,41 @@ | ||
--- CMakeLists.txt 2019-09-22 18:56:22.000000000 +0300 | ||
+++ CMakeLists.txt 2023-11-03 10:53:17.851000000 +0200 | ||
@@ -93,9 +93,6 @@ | ||
|
||
if(WIN32) | ||
set(_default_fontconfiguration "win32") | ||
-elseif(ANDROID) | ||
- # on android we don't have fontconfig and we don't want windows-specific code | ||
- set(_default_fontconfiguration "generic") | ||
else() | ||
set(_default_fontconfiguration "fontconfig") | ||
endif() | ||
@@ -124,7 +121,7 @@ | ||
macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH) | ||
find_package(Freetype REQUIRED) | ||
if(WITH_FONTCONFIGURATION_FONTCONFIG) | ||
- find_package(Fontconfig REQUIRED) | ||
+ pkg_search_module(FONTCONFIG REQUIRED IMPORTED_TARGET fontconfig) | ||
endif() | ||
macro_optional_find_package(JPEG) | ||
macro_optional_find_package(PNG) | ||
@@ -237,10 +234,6 @@ | ||
# Use mingw's ansi stdio extensions | ||
add_definitions(-D__USE_MINGW_ANSI_STDIO=1) | ||
endif() | ||
-if(FONTCONFIG_FOUND) | ||
- add_definitions(${FONTCONFIG_DEFINITIONS}) | ||
- include_directories(SYSTEM ${FONTCONFIG_INCLUDE_DIR}) | ||
-endif() | ||
if(WITH_FONTCONFIGURATION_WIN32) | ||
if(MINGW) | ||
# Set the minimum required Internet Explorer version to 5.0 | ||
@@ -428,7 +421,7 @@ | ||
) | ||
endif() | ||
if(FONTCONFIG_FOUND) | ||
- set(poppler_LIBS ${poppler_LIBS} ${FONTCONFIG_LIBRARIES}) | ||
+ set(poppler_LIBS ${poppler_LIBS} PkgConfig::FONTCONFIG) | ||
endif() | ||
|
||
if(JPEG_FOUND) |
Oops, something went wrong.