From 56c0a08c58fc758d7b55639eb0faf9fd18284bb0 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Tue, 18 Jun 2024 18:11:05 +0300 Subject: [PATCH] Attempt to use Conan port of pdf2htmlEX --- .github/conan/profiles/android | 56 ++++++++++++++++++++++++++ .github/conan/profiles/android-armv7 | 56 ++++++++++++++++++++++++++ .github/conan/profiles/android-armv8 | 56 ++++++++++++++++++++++++++ .github/conan/profiles/android-x86 | 56 ++++++++++++++++++++++++++ .github/conan/profiles/android-x86_64 | 56 ++++++++++++++++++++++++++ .github/conan/profiles/default | 36 +++++++++++++++++ .github/conan/profiles/ubuntu | 36 +++++++++++++++++ .github/workflows/build.yml | 14 ++++++- pdf2htmlEX/build.gradle | 24 +++++++++-- pdf2htmlEX/conanfile.txt | 9 +++++ pdf2htmlEX/src/main/cpp/CMakeLists.txt | 2 +- 11 files changed, 396 insertions(+), 5 deletions(-) create mode 100644 .github/conan/profiles/android create mode 100644 .github/conan/profiles/android-armv7 create mode 100644 .github/conan/profiles/android-armv8 create mode 100644 .github/conan/profiles/android-x86 create mode 100644 .github/conan/profiles/android-x86_64 create mode 100644 .github/conan/profiles/default create mode 100644 .github/conan/profiles/ubuntu create mode 100644 pdf2htmlEX/conanfile.txt diff --git a/.github/conan/profiles/android b/.github/conan/profiles/android new file mode 100644 index 00000000..e74b612d --- /dev/null +++ b/.github/conan/profiles/android @@ -0,0 +1,56 @@ +{% set android_home = os.getenv("ANDROID_HOME") %} +{% set ndk_version = "26.1.10909125" %} +{% set api_level = "21" %} + +[settings] +os=Android +os.api_level={{api_level}} +arch=x86 +build_type=RelWithDebInfo +compiler=clang +compiler.version=17 +compiler.cppstd=20 +compiler.libcxx=c++_static + +[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-center-index/issues/24349 +# https://github.com/conan-io/conan/issues/15376 +# https://github.com/conan-io/conan-center-index/issues/22114 +# https://github.com/conan-io/conan/issues/14077 +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/i686-linux-android{{api_level}}-clang +CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang++ +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 + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/android-armv7 b/.github/conan/profiles/android-armv7 new file mode 100644 index 00000000..2a47389b --- /dev/null +++ b/.github/conan/profiles/android-armv7 @@ -0,0 +1,56 @@ +{% set android_home = os.getenv("ANDROID_HOME") %} +{% set ndk_version = "26.1.10909125" %} +{% set api_level = "21" %} + +[settings] +os=Android +os.api_level={{api_level}} +arch=armv7 +build_type=RelWithDebInfo +compiler=clang +compiler.version=17 +compiler.cppstd=20 +compiler.libcxx=c++_static + +[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-center-index/issues/24349 +# https://github.com/conan-io/conan/issues/15376 +# https://github.com/conan-io/conan-center-index/issues/22114 +# https://github.com/conan-io/conan/issues/14077 +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/armv7a-linux-androideabi{{api_level}}-clang +CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi{{api_level}}-clang++ +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 + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/android-armv8 b/.github/conan/profiles/android-armv8 new file mode 100644 index 00000000..3763dddf --- /dev/null +++ b/.github/conan/profiles/android-armv8 @@ -0,0 +1,56 @@ +{% set android_home = os.getenv("ANDROID_HOME") %} +{% set ndk_version = "26.1.10909125" %} +{% set api_level = "21" %} + +[settings] +os=Android +os.api_level={{api_level}} +arch=armv8 +build_type=RelWithDebInfo +compiler=clang +compiler.version=17 +compiler.cppstd=20 +compiler.libcxx=c++_static + +[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-center-index/issues/24349 +# https://github.com/conan-io/conan/issues/15376 +# https://github.com/conan-io/conan-center-index/issues/22114 +# https://github.com/conan-io/conan/issues/14077 +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/aarch64-linux-android{{api_level}}-clang +CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android{{api_level}}-clang++ +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 + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/android-x86 b/.github/conan/profiles/android-x86 new file mode 100644 index 00000000..e74b612d --- /dev/null +++ b/.github/conan/profiles/android-x86 @@ -0,0 +1,56 @@ +{% set android_home = os.getenv("ANDROID_HOME") %} +{% set ndk_version = "26.1.10909125" %} +{% set api_level = "21" %} + +[settings] +os=Android +os.api_level={{api_level}} +arch=x86 +build_type=RelWithDebInfo +compiler=clang +compiler.version=17 +compiler.cppstd=20 +compiler.libcxx=c++_static + +[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-center-index/issues/24349 +# https://github.com/conan-io/conan/issues/15376 +# https://github.com/conan-io/conan-center-index/issues/22114 +# https://github.com/conan-io/conan/issues/14077 +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/i686-linux-android{{api_level}}-clang +CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang++ +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 + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/android-x86_64 b/.github/conan/profiles/android-x86_64 new file mode 100644 index 00000000..c926f80d --- /dev/null +++ b/.github/conan/profiles/android-x86_64 @@ -0,0 +1,56 @@ +{% set android_home = os.getenv("ANDROID_HOME") %} +{% set ndk_version = "26.1.10909125" %} +{% set api_level = "21" %} + +[settings] +os=Android +os.api_level={{api_level}} +arch=x86_64 +build_type=RelWithDebInfo +compiler=clang +compiler.version=17 +compiler.cppstd=20 +compiler.libcxx=c++_static + +[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-center-index/issues/24349 +# https://github.com/conan-io/conan/issues/15376 +# https://github.com/conan-io/conan-center-index/issues/22114 +# https://github.com/conan-io/conan/issues/14077 +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/x86_64-linux-android{{api_level}}-clang +CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android{{api_level}}-clang++ +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 + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/default b/.github/conan/profiles/default new file mode 100644 index 00000000..b44ea71b --- /dev/null +++ b/.github/conan/profiles/default @@ -0,0 +1,36 @@ +[settings] +os=Linux +arch=x86_64 +build_type=RelWithDebInfo +compiler=clang +compiler.version=15 +compiler.cppstd=20 +compiler.libcxx=libstdc++11 + +[conf] +tools.build:compiler_executables={'c': 'clang-15', 'cpp': 'clang++-15'} + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/conan/profiles/ubuntu b/.github/conan/profiles/ubuntu new file mode 100644 index 00000000..b44ea71b --- /dev/null +++ b/.github/conan/profiles/ubuntu @@ -0,0 +1,36 @@ +[settings] +os=Linux +arch=x86_64 +build_type=RelWithDebInfo +compiler=clang +compiler.version=15 +compiler.cppstd=20 +compiler.libcxx=libstdc++11 + +[conf] +tools.build:compiler_executables={'c': 'clang-15', 'cpp': 'clang++-15'} + +[options] +# gobject introspection not yet available for conan 2 +poppler/*:with_gobject_introspection=False + +# We are not using xorg functionality in cairo +cairo/*:with_xlib=False +cairo/*:with_xlib_xrender=False +cairo/*:with_xcb=False +cairo/*:with_symbol_lookup=False + +# Unused functionality in GLib +glib/*:with_elf=False +glib/*:with_mount=False +glib/*:with_selinux=False + +# @TODO: These dependencies are currently problematic +freetype/*:with_bzip2=False +freetype/*:with_brotli=False +poppler/*:with_tiff=False +fontforge/*:with_tiff=False + +[replace_requires] +libjpeg/9e: libjpeg/9f +libdeflate/1.19: libdeflate/1.20 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b64e25a..233aa61f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2021 - 2023 ViliusSutkus89.com +# Copyright (c) 2021 - 2024 ViliusSutkus89.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -53,6 +53,18 @@ jobs: java-version: 17 - uses: android-actions/setup-android@v3 + - name: install python dependencies + run: pip install --upgrade pip conan setuptools + + - run: conan config install .github/conan/profiles + - uses: actions/checkout@v4 + with: + repository: ViliusSutkus89/conan-odr-index + ref: pdf2htmlEX_and_deps + path: conan-odr-index + + - run: python conan-odr-index/scripts/conan_export_all_packages.py + - run: ./gradlew lintRelease publishToMavenLocal - uses: actions/upload-artifact@v4 diff --git a/pdf2htmlEX/build.gradle b/pdf2htmlEX/build.gradle index bd643b1a..04c6e5d3 100644 --- a/pdf2htmlEX/build.gradle +++ b/pdf2htmlEX/build.gradle @@ -4,7 +4,7 @@ * pdf2htmlEX-Android (https://github.com/opendocument-app/pdf2htmlEX-Android) * pdf2htmlEX library port for Android - Convert PDF to HTML without losing text or format. * - * Copyright (c) 2019 - 2023 ViliusSutkus89.com + * Copyright (c) 2019 - 2024 ViliusSutkus89.com * * pdf2htmlEX-Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -27,6 +27,21 @@ plugins { group = rootProject.group +task conanInstall { + ["armv7", "armv8", "x86", "x86_64"].each { String arch -> + exec { + commandLine( + "conan", "install", ".", + "--output-folder=build/conan/" + arch, + "--build=missing", + "--profile:host=android-" + arch, + "-s", "arch=" + arch, + "-s", "build_type=Release" + ) + } + } +} + android { namespace "app.opendocument.android.pdf2htmlex" compileSdk 34 @@ -39,7 +54,11 @@ android { testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - externalNativeBuild.cmake.arguments '-DANDROID_STL=c++_shared' + externalNativeBuild.cmake.arguments( + '-DANDROID_STL=c++_static', + "-DCMAKE_TOOLCHAIN_FILE=conan_android_toolchain.cmake", + "-DCMAKE_BUILD_TYPE=RelWithDebInfo", + ) buildConfigField("String", "VERSION_NAME", "\"${rootProject.version}\"") } publishing { @@ -70,7 +89,6 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation("com.viliussutkus89.ndk.thirdparty:pdf2htmlEX-ndk26-static:0.18.8.rc2-beta-10") } publishing { diff --git a/pdf2htmlEX/conanfile.txt b/pdf2htmlEX/conanfile.txt new file mode 100644 index 00000000..f14cbe4f --- /dev/null +++ b/pdf2htmlEX/conanfile.txt @@ -0,0 +1,9 @@ +[requires] +pdf2htmlex/0.18.8.rc1-20240614-git + +[generators] +CMakeToolchain +CMakeDeps + +[layout] +cmake_layout diff --git a/pdf2htmlEX/src/main/cpp/CMakeLists.txt b/pdf2htmlEX/src/main/cpp/CMakeLists.txt index 6a6443ca..795e2e00 100644 --- a/pdf2htmlEX/src/main/cpp/CMakeLists.txt +++ b/pdf2htmlEX/src/main/cpp/CMakeLists.txt @@ -30,7 +30,7 @@ find_package(tmpfile REQUIRED CONFIG) find_package(pdf2htmlEX REQUIRED CONFIG) target_link_libraries(pdf2htmlEX-android - pdf2htmlEX::pdf2htmlEX + pdf2htmlex::pdf2htmlex envvar tmpfile::tmpfile ${log-lib}