Removed dependency from date for copying the .so and headers files of (libkiwix, libzim) , Now we are renameing the folders names via renameFolders method

This commit is contained in:
MohitMaliFtechiz 2023-03-31 12:16:11 +05:30 committed by Matthieu Gautier
parent 5ec2f412fe
commit fb380e208a
2 changed files with 39 additions and 44 deletions

View File

@ -15,7 +15,7 @@ printf "${Green}Downloading libzim ${NC}\n"
printf "\n${Green}Done! ${NC}\n"
printf "${Green}Coping libzim header and so files ${NC}\n"
./gradlew checkCurrentLibzimDate checkCurrentLinuxLibzimDate copyLibzimHeaderAndSoFiles renameLibzimSoFile
./gradlew renameLibzimFolders copyLibzimHeaderAndSoFiles renameLibzimSoFile
printf "\n${Green}Down! ${NC}\n"
printf "${Green}Downloading libkiwix ${NC}\n"
@ -23,5 +23,5 @@ printf "${Green}Downloading libkiwix ${NC}\n"
printf "\n${Green}Done! ${NC}\n"
printf "${Green}Coping libkiwix header and so files ${NC}\n"
./gradlew checkCurrentLibkiwixDate checkCurrentLinuxLibkiwixDate copyLibkiwixHeaderAndSoFiles renameLibkiwixSoFile
./gradlew renameLibkiwixFolders copyLibkiwixHeaderAndSoFiles renameLibkiwixSoFile
printf "\n${Green}Done! ${NC}\n"

View File

@ -68,6 +68,12 @@ android {
}
ndkVersion '21.4.7075529'
configurations {
testCompileClasspath.extendsFrom(compileClasspath)
testRuntimeClasspath.extendsFrom(testCompileClasspath)
testImplementation.extendsFrom(implementation)
testRuntimeOnly.extendsFrom(runtimeOnly)
}
}
dependencies {
@ -77,11 +83,6 @@ dependencies {
ext.libkiwix_base_url = 'https://download.kiwix.org/nightly'
ext.libzim_base_url = 'https://download.openzim.org/nightly'
// change this date to get latest libzim .so and header files
ext.nightly_date_for_libkiwix = project.properties["nightly_date_for_libkiwix"] ?: ""
ext.nightly_date_for_libkiwix_linux = project.properties["nightly_date_for_libkiwix_linux"] ?: ""
ext.nightly_date_for_libzim = project.properties["nightly_date_for_libzim"] ?: ""
ext.nightly_date_for_libzim_linux = project.properties["nightly_date_for_libzim_linux"] ?: ""
ext.libkiwix_version = project.properties["libkiwix_version"] ?: ""
ext.libzim_version = project.properties["libzim_version"] ?: ""
@ -98,14 +99,6 @@ task downloadLibzimSoAndHeaderFiles(type: Download) {
overwrite true
}
task checkCurrentLibzimDate() {
project.ext.set("nightly_date_for_libzim", getDateFromPath(buildDir.path, "libzim_android-arm64-"))
}
task checkCurrentLinuxLibzimDate() {
project.ext.set("nightly_date_for_libzim_linux", getDateFromPath(buildDir.path, "libzim_linux-x86_64-"))
}
task unzipLibzim(type: Copy) {
// unzip android arm
from tarTree(buildDir.path + "/libzim_android-arm.tar.gz")
@ -124,41 +117,45 @@ task unzipLibzim(type: Copy) {
into buildDir
}
task renameLibzimFolders() {
renameFolders(buildDir.path,"libzim_")
}
task copyLibzimHeaderAndSoFiles(type: Copy) {
copy {
// copying header file
from buildDir.path + "/libzim_android-arm-" + nightly_date_for_libzim + '/include/'
from buildDir.path + "/libzim_android-arm/include/"
into buildDir.path + "/include/libzim/"
}
copy {
// copying android_arm so file
from buildDir.path + "/libzim_android-arm-" + nightly_date_for_libzim + '/lib/arm-linux-androideabi/'
from buildDir.path + "/libzim_android-arm/lib/arm-linux-androideabi/"
into buildDir.path + "/jniLibs/armeabi-v7a/libzim/"
}
copy {
// copying android_arm64 so file
from buildDir.path + "/libzim_android-arm64-" + nightly_date_for_libzim + '/lib/aarch64-linux-android/'
from buildDir.path + "/libzim_android-arm64/lib/aarch64-linux-android/"
into buildDir.path + "/jniLibs/arm64-v8a/libzim/"
}
copy {
// copying android_x86 so file
from buildDir.path + "/libzim_android-x86-" + nightly_date_for_libzim + '/lib/i686-linux-android/'
from buildDir.path + "/libzim_android-x86/lib/i686-linux-android/"
into buildDir.path + "/jniLibs/x86/libzim/"
}
copy {
// copying android_x86_64 so file
from buildDir.path + "/libzim_android-x86_64-" + nightly_date_for_libzim + '/lib/x86_64-linux-android/'
from buildDir.path + "/libzim_android-x86_64/lib/x86_64-linux-android/"
into buildDir.path + "/jniLibs/x86_64/libzim/"
}
copy {
// copying linux_x86_64 so file
project.ext.set("libzim_version", getFileFromFolder(buildDir.path + "/libzim_linux-x86_64-" + nightly_date_for_libzim_linux + "/lib/x86_64-linux-gnu/"))
from buildDir.path + "/libzim_linux-x86_64-" + nightly_date_for_libzim_linux + "/lib/x86_64-linux-gnu/" + libzim_version
project.ext.set("libzim_version", getFileFromFolder(buildDir.path + "/libzim_linux-x86_64/lib/x86_64-linux-gnu/"))
from buildDir.path + "/libzim_linux-x86_64/lib/x86_64-linux-gnu/" + libzim_version
into buildDir.path
}
}
@ -184,22 +181,20 @@ task downloadLibkiwixSoAndHeaderFiles(type: Download) {
overwrite true
}
task checkCurrentLibkiwixDate() {
project.ext.set("nightly_date_for_libkiwix", getDateFromPath(buildDir.path, "libkiwix_android-arm64-"))
task renameLibkiwixFolders() {
renameFolders(buildDir.path,"libkiwix_")
}
task checkCurrentLinuxLibkiwixDate() {
project.ext.set("nightly_date_for_libkiwix_linux", getDateFromPath(buildDir.path, "libkiwix_linux-x86_64-"))
}
static String getDateFromPath(String path, String matchesString) {
File folder = new File(path)
if (folder.exists()) {
return folder.listFiles()
.stream()
.filter(f -> f.name.startsWith(matchesString))
.map(s -> s.name.replace(matchesString, ""))
.collect(Collectors.toList())[0]
static void renameFolders(String path, String startWith) {
File directory = new File(path)
if (directory.exists() && directory.isDirectory()) {
Arrays.stream(directory.listFiles())
.filter(folder -> folder.isDirectory() && folder.getName().startsWith(startWith))
.forEach(file -> {
String newName = file.getName().replaceAll("-\\d{4}-\\d{2}-\\d{2}", "")
File newFile = new File(directory, newName)
file.renameTo(newFile)
})
}
}
@ -224,38 +219,38 @@ task unzipLibkiwix(type: Copy) {
task copyLibkiwixHeaderAndSoFiles(type: Copy) {
copy {
// copying header file
from buildDir.path + "/libkiwix_android-arm-" + nightly_date_for_libkiwix + '/include/kiwix/'
from buildDir.path + "/libkiwix_android-arm/include/kiwix/"
into buildDir.path + "/include/libkiwix/"
}
copy {
// copying android_arm so file
from buildDir.path + "/libkiwix_android-arm-" + nightly_date_for_libkiwix + '/lib/arm-linux-androideabi/'
from buildDir.path + "/libkiwix_android-arm/lib/arm-linux-androideabi/"
into buildDir.path + "/jniLibs/armeabi-v7a/libkiwix/"
}
copy {
// copying android_arm64 so file
from buildDir.path + "/libkiwix_android-arm64-" + nightly_date_for_libkiwix + '/lib/aarch64-linux-android/'
from buildDir.path + "/libkiwix_android-arm64/lib/aarch64-linux-android/"
into buildDir.path + "/jniLibs/arm64-v8a/libkiwix/"
}
copy {
// copying android_x86 so file
from buildDir.path + "/libkiwix_android-x86-" + nightly_date_for_libkiwix + '/lib/i686-linux-android/'
from buildDir.path + "/libkiwix_android-x86/lib/i686-linux-android/"
into buildDir.path + "/jniLibs/x86/libkiwix/"
}
copy {
// copying android_x86_64 so file
from buildDir.path + "/libkiwix_android-x86_64-" + nightly_date_for_libkiwix + '/lib/x86_64-linux-android/'
from buildDir.path + "/libkiwix_android-x86_64/lib/x86_64-linux-android/"
into buildDir.path + "/jniLibs/x86_64/libkiwix/"
}
copy {
// copying linux_x86_64 so file
project.ext.set("libkiwix_version", getFileFromFolder(buildDir.path + "/libkiwix_linux-x86_64-" + nightly_date_for_libkiwix_linux + "/lib/x86_64-linux-gnu/"))
from buildDir.path + "/libkiwix_linux-x86_64-" + nightly_date_for_libkiwix_linux + "/lib/x86_64-linux-gnu/" + libkiwix_version
project.ext.set("libkiwix_version", getFileFromFolder(buildDir.path + "/libkiwix_linux-x86_64/lib/x86_64-linux-gnu/"))
from buildDir.path + "/libkiwix_linux-x86_64/lib/x86_64-linux-gnu/" + libkiwix_version
into buildDir.path
}
}
@ -343,4 +338,4 @@ task buildLinuxSoFile(type: Exec) {
commandLine 'bash', '-c', "cmake . -B ${buildDir} && make -C ${buildDir}"
}
build.dependsOn buildLinuxSoFile
build.dependsOn buildLinuxSoFile