Skip to content

Commit

Permalink
Package pdf2htmlEX, Poppler and Fontconfig assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Jun 19, 2024
1 parent 74ecc5d commit 0e7a2ad
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
28 changes: 27 additions & 1 deletion pdf2htmlEX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build configuration (Debug, Release, RelWithDebInfo, MinSizeRel)")
project(pdf2htmlEX-android)

find_package(pdf2htmlEX REQUIRED CONFIG)

add_subdirectory(src/main/cpp)

FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/build/assets")
function(copy_assets sourcevar dstsubdir)
if(DEFINED "${sourcevar}")
FILE(REMOVE_RECURSE "${CMAKE_CURRENT_LIST_DIR}/build/assets/${dstsubdir}")
FILE(CREATE_LINK "${${sourcevar}}" "${CMAKE_CURRENT_LIST_DIR}/build/assets/${dstsubdir}" COPY_ON_ERROR SYMBOLIC)
endif()
endfunction()

copy_assets("pdf2htmlex_RES_DIRS_DEBUG" "pdf2htmlEX")
copy_assets("pdf2htmlex_RES_DIRS_RELEASE" "pdf2htmlEX")
copy_assets("pdf2htmlex_RES_DIRS_RELWITHDEBINFO" "pdf2htmlEX")
copy_assets("pdf2htmlex_RES_DIRS_MINSIZEREL" "pdf2htmlEX")

copy_assets("poppler-data_RES_DIRS_DEBUG" "poppler-data")
copy_assets("poppler-data_RES_DIRS_RELEASE" "poppler-data")
copy_assets("poppler-data_RES_DIRS_RELWITHDEBINFO" "poppler-data")
copy_assets("poppler-data_RES_DIRS_MINSIZEREL" "poppler-data")

copy_assets("fontconfig_RES_DIRS_DEBUG" "fontconfig")
copy_assets("fontconfig_RES_DIRS_RELEASE" "fontconfig")
copy_assets("fontconfig_RES_DIRS_RELWITHDEBINFO" "fontconfig")
copy_assets("fontconfig_RES_DIRS_MINSIZEREL" "fontconfig")
2 changes: 2 additions & 0 deletions pdf2htmlEX/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ android {
}
ndkVersion '26.3.11579264'
buildTypes.release.externalNativeBuild.cmake.arguments '-DCMAKE_BUILD_TYPE=RelWithDebInfo'

sourceSets.main.assets.srcDirs += "build/assets"
}

dependencies {
Expand Down
1 change: 0 additions & 1 deletion pdf2htmlEX/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ add_library(pdf2htmlEX-android SHARED pdf2htmlEX.cc CCharGC.h)

find_library(log-lib log)
find_package(tmpfile REQUIRED CONFIG)
find_package(pdf2htmlEX REQUIRED CONFIG)

target_link_libraries(pdf2htmlEX-android
pdf2htmlex::pdf2htmlex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void init(@NonNull AssetManager assetManager, @NonNull File cacheDir, @No
EnvVar.set("XDG_CACHE_HOME", xdgCache.getAbsolutePath());

AssetExtractor ae = new AssetExtractor(assetManager).setNoOverwrite();
File fontsConfigDir = ae.extract(new File(filesDir, "etc"), "fontconfig/etc/fonts");
File fontsConfigDir = ae.extract(new File(filesDir, "etc"), "fontconfig/fontconfig/conf.avail");
ae.extract(fontsConfigDir, "pdf2htmlEX/etc/fonts/local.conf");
EnvVar.set("FONTCONFIG_PATH", fontsConfigDir.getAbsolutePath());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public pdf2htmlEX(@NonNull Context ctx) {

// @TODO: https://github.com/ViliusSutkus89/pdf2htmlEX-Android/issues/9
// pdf2htmlEX_dataDir is where pdf2htmlEX's share folder contents are
File pdf2htmlEX_dataDir = ae.extract(new File(filesDir, "share"), "pdf2htmlEX/share/pdf2htmlEX");
File pdf2htmlEX_dataDir = ae.extract(new File(filesDir, "share"), "pdf2htmlEX");

// @TODO: https://github.com/ViliusSutkus89/pdf2htmlEX-Android/issues/10
// Poppler requires encoding data
Expand Down

0 comments on commit 0e7a2ad

Please sign in to comment.