Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf2htmlEX Conan #369

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ef08ac
Add conan remote odr to default position, not position 0
ViliusSutkus89 Aug 7, 2024
c83c8f7
Use separate conan profile files for each arch. Add pdf2htmlEX conan …
ViliusSutkus89 Aug 7, 2024
42c7996
Use pdf2htmlEX delivered by conan instead of app.opendocument:pdf2htm…
ViliusSutkus89 Aug 7, 2024
4bec8ac
Revert EnvVar filename to c. Set nevvar linker lang to C
ViliusSutkus89 Aug 8, 2024
a1d2d2c
Add envvar and pdf2htmlEX-android CMake targets
ViliusSutkus89 Aug 8, 2024
e0fe8fb
Use shared C++ stl
ViliusSutkus89 Aug 8, 2024
64583b4
Share .conan2 folder between build and test jobs. Reduces load on art…
ViliusSutkus89 Aug 8, 2024
6e0fa8c
Merge branch 'main' into pdf2htmlex-conan
ViliusSutkus89 Aug 9, 2024
d26811d
Remove leftover conanprofile.txt
ViliusSutkus89 Aug 9, 2024
f8a11a3
Merge branch 'main' into pdf2htmlex-conan
ViliusSutkus89 Aug 10, 2024
09b6a2e
Merge branch 'main' into pdf2htmlex-conan
ViliusSutkus89 Aug 15, 2024
53769d1
Update pdf2htmlEX and it's asset collection mechanism
ViliusSutkus89 Aug 15, 2024
0f54f6c
Use odr.core built with pdf2htmlEX
ViliusSutkus89 Aug 15, 2024
036172f
Remove PdfLoader. Update fontconfig
ViliusSutkus89 Aug 15, 2024
de9de01
Use rolling odrcore/pdf2htmlEX version
ViliusSutkus89 Aug 15, 2024
8ae3de1
Don't include ReLinker. Relinker is needed on API<23
ViliusSutkus89 Aug 15, 2024
01c5bb7
Bring back PdfLoader, but it's just a copy of OdfLoader with retransl…
ViliusSutkus89 Aug 15, 2024
5927c8c
[2/2] Bring back PdfLoader
ViliusSutkus89 Aug 15, 2024
9ed1196
Update conan profiles. pdf2htmlEX-config not needed anymore
ViliusSutkus89 Aug 21, 2024
067abac
Update DocLoader. Call wvWare/pdf2htmlEX/ODR in CoreWrapper
ViliusSutkus89 Aug 25, 2024
e9cc120
Add pdf2htmlEX and wvWare password support
ViliusSutkus89 Aug 25, 2024
ff368c3
Remove wvWare-Android gradle dependency. It's consumed through conan
ViliusSutkus89 Aug 25, 2024
5eab9e3
Fix wvWare asset delivery
ViliusSutkus89 Aug 25, 2024
b668f69
Fix wv asset extraction path
ViliusSutkus89 Aug 25, 2024
6d06e99
Fix wvWare asset delivery... again
ViliusSutkus89 Aug 25, 2024
44cf997
Remove commented out retranslate from PdfLoader
ViliusSutkus89 Aug 26, 2024
0fe1afd
Update asset gathering logic. Do symlinks in conanfile instead of CMa…
ViliusSutkus89 Aug 26, 2024
66f97d3
packagingOptions.jniLibs not needed anymore
ViliusSutkus89 Aug 26, 2024
b6506b4
Merge branch 'main' into pdf2htmlex-conan
ViliusSutkus89 Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/config/ubuntu-22.04/conan/profiles/android-23-armv7
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "23" %}
{% set arch = "armv7" %}
{% set cc = {
"armv7": "armv7a-linux-androideabi" + api_level + "-clang",
"armv8": "aarch64-linux-android" + api_level + "-clang",
"x86": "i686-linux-android" + api_level + "-clang",
"x86_64": "x86_64-linux-android" + api_level + "-clang",
}[arch] %}

[settings]
os=Android
os.api_level={{api_level}}
arch={{arch}}
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_shared

[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}

[buildenv]
# Cross compile toolchain evn vars are required to build
# libffi, libgettext, libiconv, libxml2 and other autotools packages for Android
# https://github.com/conan-io/conan/issues/16493
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
35 changes: 35 additions & 0 deletions .github/config/ubuntu-22.04/conan/profiles/android-23-armv8
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "23" %}
{% set arch = "armv8" %}
{% set cc = {
"armv7": "armv7a-linux-androideabi" + api_level + "-clang",
"armv8": "aarch64-linux-android" + api_level + "-clang",
"x86": "i686-linux-android" + api_level + "-clang",
"x86_64": "x86_64-linux-android" + api_level + "-clang",
}[arch] %}

[settings]
os=Android
os.api_level={{api_level}}
arch={{arch}}
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_shared

[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}

[buildenv]
# Cross compile toolchain evn vars are required to build
# libffi, libgettext, libiconv, libxml2 and other autotools packages for Android
# https://github.com/conan-io/conan/issues/16493
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
35 changes: 35 additions & 0 deletions .github/config/ubuntu-22.04/conan/profiles/android-23-x86
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "23" %}
{% set arch = "x86" %}
{% set cc = {
"armv7": "armv7a-linux-androideabi" + api_level + "-clang",
"armv8": "aarch64-linux-android" + api_level + "-clang",
"x86": "i686-linux-android" + api_level + "-clang",
"x86_64": "x86_64-linux-android" + api_level + "-clang",
}[arch] %}

[settings]
os=Android
os.api_level={{api_level}}
arch={{arch}}
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_shared

[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}

[buildenv]
# Cross compile toolchain evn vars are required to build
# libffi, libgettext, libiconv, libxml2 and other autotools packages for Android
# https://github.com/conan-io/conan/issues/16493
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
35 changes: 35 additions & 0 deletions .github/config/ubuntu-22.04/conan/profiles/android-23-x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "23" %}
{% set arch = "x86_64" %}
{% set cc = {
"armv7": "armv7a-linux-androideabi" + api_level + "-clang",
"armv8": "aarch64-linux-android" + api_level + "-clang",
"x86": "i686-linux-android" + api_level + "-clang",
"x86_64": "x86_64-linux-android" + api_level + "-clang",
}[arch] %}

[settings]
os=Android
os.api_level={{api_level}}
arch={{arch}}
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_shared

[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}

[buildenv]
# Cross compile toolchain evn vars are required to build
# libffi, libgettext, libiconv, libxml2 and other autotools packages for Android
# https://github.com/conan-io/conan/issues/16493
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/{{cc}}++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
11 changes: 11 additions & 0 deletions .github/config/ubuntu-22.04/conan/profiles/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[settings]
os=Linux
arch=x86_64
build_type=Release
compiler=gcc
compiler.version=12
compiler.cppstd=20
compiler.libcxx=libstdc++11

[conf]
tools.build:compiler_executables={'c': 'gcc-12', 'cpp': 'g++-12'}
1 change: 1 addition & 0 deletions .github/config/ubuntu-22.04/conan/profiles/ubuntu
5 changes: 3 additions & 2 deletions .github/workflows/android_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ jobs:

- name: conan remote
run: conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan
- name: conan profile
run: conan profile detect

- name: conan config
run: conan config install .github/config/ubuntu-22.04/conan

- name: gradle
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace
Expand Down
5 changes: 4 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.18.1)
project(odr-droid CXX)
project(odr-droid LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -13,3 +13,6 @@ target_include_directories(odr-core
PRIVATE src/main/cpp)
target_link_libraries(odr-core
PRIVATE odrcore::odrcore log)

add_library(envvar SHARED src/main/cpp/EnvVar.c)
set_target_properties(envvar PROPERTIES LINKER_LANGUAGE C)
45 changes: 23 additions & 22 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
Expand All @@ -11,16 +9,9 @@ android {
ndkVersion "26.3.11579264"
}

tasks.register('conanProfile', Copy) {
from "conanprofile.txt"
into project.layout.buildDirectory
filter(ReplaceTokens, tokens: ["NDK_PATH": android.ndkDirectory.toString()])
}

["armv8", "armv7", "x86", "x86_64"].each { architecture ->
tasks.named("conanInstall-" + architecture) {
profile.set('build/conanprofile.txt')
dependsOn(tasks.named('conanProfile'))
profile.set('../.github/config/ubuntu-22.04/conan/profiles/android-23-' + architecture)
}
}

Expand All @@ -40,13 +31,16 @@ android {

externalNativeBuild {
cmake {
targets "odr-core"
targets "odr-core", "envvar"
arguments(
"-DCMAKE_TOOLCHAIN_FILE=build/conan/android_toolchain.cmake",
// We can migrate to static STL once all C++ deps are in conan and linked as one .so library
"-DANDROID_STL=c++_shared",
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
)
}
}
sourceSets.main.assets.srcDirs += "build/conan/armv8/assets"
}

flavorDimensions "default"
Expand Down Expand Up @@ -111,18 +105,25 @@ android {
lint {
abortOnError false
}
packagingOptions {
jniLibs {
// No need to pickFirst libc++_shared.so if all files are identical.
// They will be identical if NDK major version matches.
// NDK runtime problems may occur if NDK version mismatches,
// so comment this out, to get a compile error instead
// pickFirsts += ['**/libc++_shared.so']
}
}
namespace 'at.tomtasche.reader'
}

// Make sure the assets are installed when needed
afterEvaluate {
tasks.named("generateProDebugAssets").configure {
dependsOn(tasks.named("conanInstall-armv8"))
}
tasks.named("generateProReleaseAssets").configure {
dependsOn(tasks.named("conanInstall-armv8"))
}
tasks.named("generateLiteDebugAssets").configure {
dependsOn(tasks.named("conanInstall-armv8"))
}
tasks.named("generateLiteReleaseAssets").configure {
dependsOn(tasks.named("conanInstall-armv8"))
}
}

dependencies {
implementation platform('com.google.firebase:firebase-bom:33.1.1')
implementation 'com.google.firebase:firebase-storage'
Expand All @@ -140,8 +141,8 @@ dependencies {
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.webkit:webkit:1.11.0'

implementation 'app.opendocument:pdf2htmlex-android:0.18.25'
implementation 'com.viliussutkus89:wvware-android:1.2.9'
implementation 'com.viliussutkus89:fontconfig-android-translator:1.0.2'
implementation 'com.viliussutkus89:assetextractor-android:1.3.3'
implementation 'com.github.huzongyao:AndroidMagic:v1.1.2'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand Down
30 changes: 30 additions & 0 deletions app/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps

required_conan_version = ">=2.0.6"


class OdrDroidConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"

def requirements(self):
self.requires("odrcore/4.1.0-pdf2htmlex-git", options={
"with_pdf2htmlEX": True,
"with_wvWare": True,
})

def generate(self):
deps = CMakeDeps(self)
deps.generate()

tc = CMakeToolchain(self)
tc.generate()

asset_dir = os.path.join(self.build_folder, 'assets')
os.mkdir(asset_dir)
os.symlink(self.dependencies['pdf2htmlex'].cpp_info.resdirs[0], os.path.join(asset_dir, 'pdf2htmlEX'))
os.symlink(self.dependencies['poppler-data'].cpp_info.resdirs[0], os.path.join(asset_dir, 'poppler-data'))
os.symlink(self.dependencies['fontconfig'].cpp_info.resdirs[0], os.path.join(asset_dir, 'fontconfig'))
os.symlink(self.dependencies['wvware'].cpp_info.resdirs[0], os.path.join(asset_dir, 'wv'))
6 changes: 0 additions & 6 deletions app/conanfile.txt

This file was deleted.

14 changes: 0 additions & 14 deletions app/conanprofile.txt

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/main/assets/etc/fonts/local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
<its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
</its:rules>

<description>Load Android font files from /system/fonts</description>
<dir>/system/fonts</dir>

<include ignore_missing="yes">system-etc-fonts-xml-translated.conf</include>

<dir prefix="relative">../../share/fonts</dir>

<alias binding="strong">
<family>Symbol</family>
<prefer><family>Standard Symbols L</family></prefer>
</alias>

<alias binding="strong">
<family>Zapf Dingbats</family>
<prefer><family>Dingbats</family></prefer>
</alias>

</fontconfig>
Loading
Loading