Skip to content

Commit

Permalink
Merge pull request #4 from mossroy/upgrade_libzim_to_7.0.0
Browse files Browse the repository at this point in the history
Upgrade libzim to 7.0.0
  • Loading branch information
mossroy authored Oct 27, 2021
2 parents bdc3330 + 3060a58 commit 9e3b727
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ build/lib/libxapian.a :
cd xapian-core-1.4.18; emmake make install

build/lib/libzim.a : build/lib/liblzma.so build/lib/libz.a build/lib/libzstd.a build/lib/libicudata.so build/lib/libxapian.a
wget -O libzim-6.3.2.tar.gz https://github.com/openzim/libzim/archive/6.3.2.tar.gz
tar xf libzim-6.3.2.tar.gz
wget -O libzim-7.0.0.tar.gz https://github.com/openzim/libzim/archive/7.0.0.tar.gz
tar xf libzim-7.0.0.tar.gz
# It's no use trying to compile examples
sed -i -e "s/^subdir('examples')//" libzim-6.3.2/meson.build
cd libzim-6.3.2; PKG_CONFIG_PATH=/src/build/lib/pkgconfig meson --prefix=`pwd`/../build --cross-file=../emscripten-crosscompile.ini . build -DUSE_MMAP=false
sed -i -e "s/^subdir('examples')//" libzim-7.0.0/meson.build
cd libzim-7.0.0; PKG_CONFIG_PATH=/src/build/lib/pkgconfig meson --prefix=`pwd`/../build --cross-file=../emscripten-crosscompile.ini . build -DUSE_MMAP=false
# Quick and dirty way
cd libzim-6.3.2 ; patch -p1 -F5 <../patch_libzim_for_emscripten.patch
cd libzim-6.3.2; ninja -C build
cd libzim-6.3.2; ninja -C build install
cd libzim-7.0.0 ; patch -p1 -F5 <../patch_libzim_for_emscripten.patch
cd libzim-7.0.0; ninja -C build
cd libzim-7.0.0; ninja -C build install

demo_file_api.js: build/lib/libzim.a demo_file_api.cpp prejs_file_api.js postjs_file_api.js
em++ --bind demo_file_api.cpp build/lib/libzim.a -Ibuild/include -Lbuild/lib -lzstd -llzma -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -Werror -std=c++11 -O0 -g --pre-js prejs_file_api.js --post-js postjs_file_api.js -s DISABLE_EXCEPTION_CATCHING=0 -s "EXPORTED_RUNTIME_METHODS=['ALLOC_NORMAL','printErr','ALLOC_STACK','print']" -s DEMANGLE_SUPPORT=1 -s TOTAL_MEMORY=83886080 -s ALLOW_MEMORY_GROWTH=1 -lworkerfs.js
Expand All @@ -57,8 +57,8 @@ clean :
rm -rf zlib-1.2.11 zlib-1.2.11.tar.gz*
rm -rf xapian-core-1.4.18 xapian-core-1.4.18.tar.xz*
rm -rf icu icu4c-63_2-src.tgz*
rm -rf libzim-6.3.2
rm -rf libzim-6.3.2.tar.gz
rm -rf libzim-7.0.0
rm -rf libzim-7.0.0.tar.gz
rm -rf build
rm a.out.*

Expand Down
18 changes: 9 additions & 9 deletions a.out.js
Original file line number Diff line number Diff line change
Expand Up @@ -6482,15 +6482,15 @@ var ___cxa_is_pointer_type = Module["___cxa_is_pointer_type"] = createExportWrap
/** @type {function(...*):?} */
var dynCall_viij = Module["dynCall_viij"] = createExportWrapper("dynCall_viij");

/** @type {function(...*):?} */
var dynCall_iij = Module["dynCall_iij"] = createExportWrapper("dynCall_iij");

/** @type {function(...*):?} */
var dynCall_ji = Module["dynCall_ji"] = createExportWrapper("dynCall_ji");

/** @type {function(...*):?} */
var dynCall_viijj = Module["dynCall_viijj"] = createExportWrapper("dynCall_viijj");

/** @type {function(...*):?} */
var dynCall_iij = Module["dynCall_iij"] = createExportWrapper("dynCall_iij");

/** @type {function(...*):?} */
var dynCall_iijj = Module["dynCall_iijj"] = createExportWrapper("dynCall_iijj");

Expand Down Expand Up @@ -6547,32 +6547,32 @@ function invoke_viii(index,a1,a2,a3) {
}
}

function invoke_iii(index,a1,a2) {
function invoke_vii(index,a1,a2) {
var sp = stackSave();
try {
return getWasmTableEntry(index)(a1,a2);
getWasmTableEntry(index)(a1,a2);
} catch(e) {
stackRestore(sp);
if (e !== e+0 && e !== 'longjmp') throw e;
_setThrew(1, 0);
}
}

function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) {
function invoke_iii(index,a1,a2) {
var sp = stackSave();
try {
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6);
return getWasmTableEntry(index)(a1,a2);
} catch(e) {
stackRestore(sp);
if (e !== e+0 && e !== 'longjmp') throw e;
_setThrew(1, 0);
}
}

function invoke_vii(index,a1,a2) {
function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) {
var sp = stackSave();
try {
getWasmTableEntry(index)(a1,a2);
return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6);
} catch(e) {
stackRestore(sp);
if (e !== e+0 && e !== 'longjmp') throw e;
Expand Down
Binary file modified a.out.wasm
Binary file not shown.
15 changes: 8 additions & 7 deletions demo_file_api.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <zim/file.h>
#include <zim/fileiterator.h>
#include <zim/archive.h>
#include <zim/item.h>
#include <iostream>
#include <chrono>
#include <emscripten/bind.h>
Expand All @@ -15,15 +15,16 @@ int main(int argc, char* argv[])

// Get article count of a ZIM file (with kiwix-lib)
unsigned int getArticleCount(std::string filename) {
zim::File f(filename);
return f.getCountArticles();
zim::Archive a(filename);
return a.getArticleCount();
}

// Get ArticleContent by URL (with libzim)
std::string getArticleContentByUrl(std::string filename, std::string url) {
zim::File f(filename);
zim::Article article = f.getArticleByUrl(url);
return article.getData(0).data();
zim::Archive a(filename);
zim::Entry entry = a.getEntryByPath(url);
zim::Item item = entry.getItem(true);
return item.getData();
}

// Binding code
Expand Down

0 comments on commit 9e3b727

Please sign in to comment.