Skip to content

Commit

Permalink
Update asset gathering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 26, 2024
1 parent 01dde76 commit 29598b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
14 changes: 0 additions & 14 deletions pdf2htmlEX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,3 @@ 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_DIR" "pdf2htmlEX")
copy_assets("POPPLER_DATA_RES_DIR" "poppler-data")
copy_assets("FONTCONFIG_RES_DIR" "fontconfig")

#@TODO: fontforge cidfiles
8 changes: 4 additions & 4 deletions pdf2htmlEX/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ android {
version '3.22.1'
}
ndkVersion '26.3.11579264'
sourceSets.main.assets.srcDirs += "build/assets"
sourceSets.main.assets.srcDirs += "build/conan/armv8/assets"
sourceSets.androidTest.assets.srcDirs = [ getProject().parent.getLayout().getProjectDirectory().dir("test/androidTestAssets") ]
}

// Assets delivered by conan are gathered by CMake
// Make sure the assets are installed and ready when needed
afterEvaluate {
tasks.named("generateDebugAssets").configure {
dependsOn(tasks.named("mergeDebugNativeLibs"))
dependsOn(tasks.named("conanInstall-armv8"))
}
tasks.named("generateReleaseAssets").configure {
dependsOn(tasks.named("mergeReleaseNativeLibs"))
dependsOn(tasks.named("conanInstall-armv8"))
}
}

Expand Down
12 changes: 7 additions & 5 deletions pdf2htmlEX/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

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

Expand All @@ -12,10 +14,10 @@ def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)

# @TODO: figure out how to use POPPLER_DATA_DIR exported by poppler-data
tc.variables["POPPLER_DATA_RES_DIR"] = self.dependencies['poppler-data'].cpp_info.resdirs[0]
tc.variables["PDF2HTMLEX_RES_DIR"] = self.dependencies['pdf2htmlex'].cpp_info.resdirs[0]
tc.variables["FONTCONFIG_RES_DIR"] = self.dependencies['fontconfig'].cpp_info.resdirs[0]
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'))

0 comments on commit 29598b7

Please sign in to comment.