Re: [sword-devel] Sword as a WASM library

2022-01-14 Thread Troy A. Griffitts
Welcome Zoltán!

I am curious how local storage is used and how much is available. We jump 
through all kinds of hoops to get libsword compiled and accessible on both iOS 
and Android for Bishop. It would be nice if maybe we could simply ship a WASM 
lib with Bishop for both platforms.

I noticed your patch is to our cmake build. Greg Hellings holds the pumpkin 
there, so I defer to his wisdom on inclusion. Greg, if you're busy, I am happy 
to commit if you have a brief look and "OK" the change.

https://github.com/kovzol/crosswire-sword-mirror/commit/2ed499fe72141345a9d90053b0c96be5549df6ca



On January 12, 2022 1:30:03 PM MST, "Kovács Zoltán"  wrote:
>Dear Developers,
>Troy kindly invited me to the list -- it is an honor for me to accept his
>invitation.
>I recently signed up for the JIRA tracker and created a ticket on my
>request for a minor change on the source code to enable building Sword via
>Emscripten out-of-the-box: https://tracker.crosswire.org/browse/API-252.
>Now I managed to reach a somewhat mature stage of the code -- you can find
>my blog entry on this at https://matek.hu/zoltan/blog-20220112.php.
>Sword works nicely on an offline web page now, and its speed is comparable
>with the native version. Maybe some of you would like to try this and have
>more interest in developing for the offline web platform.
>Thank you so much for devoting your time to developing Sword -- for me it
>was a blessing and joy to have it as a nice library to build on.
>Kind regards,
>Zoltan
>
>-- 
>
>*Dr. Zoltán** Kovács, MSc*
>
>Institut Ausbildung
>
>
>
>
>*Private Pädagogische Hochschule der Diözese Linz*
>*Private University of Education, Diocese Linz**Salesianumweg 3, 4020 Linz*
>*Mail: zoltan.kov...@ph-linz.at *
>
>*Web: www.ph-linz.at *

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.___
sword-devel mailing list: sword-devel@crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Re: [sword-devel] Sword as a WASM library

2022-01-15 Thread Kovács Zoltán
Dear Troy, thanks for the kind words!

Troy A. Griffitts  ezt írta (időpont: 2022. jan. 14.,
P, 18:43):

> Welcome Zoltán!
>
> I am curious how local storage is used and how much is available. We jump
> through all kinds of hoops to get libsword compiled and accessible on both
> iOS and Android for Bishop. It would be nice if maybe we could simply ship
> a WASM lib with Bishop for both platforms.
>

I uploaded a WASM build to
https://github.com/kovzol/crosswire-sword-mirror/releases/tag/2022Jan03.
This should be ready to use for inclusion in other WASM based projects. I
will send you a detailed description on how one could easily build it from
scratch (in a different email).

The local storage is surprisingly easy to set. Emscripten wants to know
which native folder is to be used in the browser and it can be set by using
the --preload-file option on linking. The documentation at
https://emscripten.org/docs/porting/files/packaging_files.html#packaging-using-emcc
explains this very well. I simply packaged the ~/.sword folder to get
access to the same Bible texts I installed for the native version by using
installmgr. In my case the texts KJV, LXX and SBLGNT took about 10 MB of
disk space, and Emscripten created a .data file that had to be uploaded on
the web server too. Loading this amount of data is very fast, less than 1
second. I guess, storing a couple of other texts is still manageable. Maybe
some compression could also be done, but I haven't investigated this
question yet. When a .data file exists, it seems a web server is required
-- maybe the .data file can also be bundled in the .js, so no web server
must be used. I will check this later. (The .js file can contain the .wasm
code if you want, that's the simplest way to avoid using a web server for
WASM based web applications.)

In fact, everything is compiled transparently, no action is to be done in
Sword to access the local storage, nothing. Emscripten takes care of every
step: this works incredibly smoothly.


> I noticed your patch is to our cmake build. Greg Hellings holds the
> pumpkin there, so I defer to his wisdom on inclusion. Greg, if you're busy,
> I am happy to commit if you have a brief look and "OK" the change.
>
>
> https://github.com/kovzol/crosswire-sword-mirror/commit/2ed499fe72141345a9d90053b0c96be5549df6ca
>

Yes, this change should be harmless for the other parts of Sword. :-)

Best regards, Zoltán
___
sword-devel mailing list: sword-devel@crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Re: [sword-devel] Sword as a WASM library

2022-01-15 Thread Kovács Zoltán
> I will send you a detailed description on how one could easily build it
> from scratch (in a different email).
>

After some unsuccessful attempts to simplify the process, this is how it
seems to be the easiest way for the moment (see also
https://github.com/kovzol/bibref/blob/master/.github/workflows/build.yml#L27-L41
for a working GitHub action inside an application based on Sword), in a
shell under Linux (I used Ubuntu 21.10, but this should be irrelevant):

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 2.0.22
./emsdk activate 2.0.22
cd ..
. emsdk/emsdk_env.sh
git clone https://github.com/kovzol/crosswire-sword-mirror
cd crosswire-sword-mirror
mkdir build
cd build
sudo apt install subversion # This is required, otherwise the cmake step
will fail.
emcmake cmake ..
emmake make sword_static

An application based on the WASM build of libsword.a can be compiled and
linked as shown in https://github.com/kovzol/bibref/blob/master/Makefile.
The steps are explained in the beginning of this Makefile, including the
compilation steps of libsword.a as well.

I hope this helps. ;-)

Best, Zoltan
___
sword-devel mailing list: sword-devel@crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page