2025-07-05 20:20 UTC+0200 Aleksander Czajczynski (hb fki.pl) ; WebAssembly support resurfaces

297 views
Skip to first unread message

Aleksander Czajczynski

unread,
Jul 5, 2025, 5:25:53 PMJul 5
to harbou...@googlegroups.com
2025-07-05 20:20 UTC+0200 Aleksander Czajczynski (hb fki.pl)
  + config/wasm/global.mk
  + config/wasm/libs.mk
  + config/wasm/emcc.mk
  * utils/hbmk2/hbmk2.prg
  * contrib/hbrun/hbrun.hbp
    + add basic support for build Harbour into JS/WebAssembly using
      emscripten, using these settings:
        HB_PLATFORM=wasm HB_COMPILER=emcc HB_BUILD_3RDEXT=no

    * {abstr} is now a hbmk2 keyword to possibly group all
      toolsets similar in flavour: WASI/clang, JS/emscripten
      These most likely will be targeting plaforms which are not
      full operating-systems, they are also commonly qualified as
      sandbox solutions.

    * introduced __PLATFORM__WASM and __PLATFORM__ABSTRACT .prg defines

  * utils/hbmk2/hbmk2.prg
    + allow to specify hb_ProgName() value at build-time for platforms
      where the function cannot return a meaningful value (f.e.
      JS/WebAssembly)
    ; TODO: Add support for passing hb_ProgName() value command-line
            parameter, f.e. `--hb:self=hbrun`

  * config/global.mk
  * include/hbsetup.h
    * consider abstract/emscripten targets similar to linux-like

  * src/rtl/arc4.c
    ! fix to build under emscripten (which is assumed to be a
      linux-like environment)

  ; though platform/compiler names are not currently compatible
    with origin, this WebAssembly platform support was guided by
    Harbour 3.4:
    2017-06-09 01:10 UTC Viktor Szakats (vszakats users.noreply.github.com)
    as usual Viktor was here before, many thanks!

  ; example project, how to make a multi-platform GUI application which
    also targets WebAssembly, can be found here:
    https://github.com/alcz/harbour-cimgui-sokol-starterkit/

Hello there!

I may write more on this another day. Now just attaching a bit more elaborate demo of what's possible with Harbour:

https://os.allcom.pl/hb/wasm/yadbu.html
https://github.com/alcz/harbour-cimgui-sokol-starterkit/tree/master/examples/yadbu

No 3rd party .js libs attached yet, so only drag & drop to open a file. In-browser DBU is cool - hopefully it will be extended. I dream a bit to have a capable Harbour debugger built the same way. Especially debugging
of multi-threading apps is tricky with "AltD()".

Best regards, Aleksander

Lailton Fernando Mariano

unread,
Jul 7, 2025, 9:02:41 AMJul 7
to Harbour Developers
Thank you, Aleksander!

I tried some code with Emscripten a few years ago too.
Amazing job — congratulations, and thanks for sharing!

Lailton Fernando Mariano

unread,
Jul 7, 2025, 9:51:44 AMJul 7
to Harbour Developers
I was able to build it on MacOS, but the bin folder, some output ( that should contains the .js ) is empty

Screenshot 2025-07-07 at 10.49.16 AM.png

Aleksander Czajczynski

unread,
Jul 7, 2025, 10:28:37 AMJul 7
to harbou...@googlegroups.com
From the screenshot I could tell that hbmk2 and hbtest do not have *.js files. It's the same on Linux. I'll take a look later. Though using console tools with: "node harbour.js" etc. is not very much interesting use case for me. For macOS it would be nice to do the GUI tests  (not WASM related) from additional repo, I didn't have time to turn on a Mac...

Lailton Fernando Mariano

unread,
Jul 7, 2025, 12:51:11 PMJul 7
to Harbour Developers
Okay.

I will do some testing with MacOS.
from now I was able to build the examples the unique one not working for me is the yadbu. 
for some reason it is not found the lib libcimgui.a but I did the build and it exist.

I have added to the yadbu.hbp
../cimgui-docking/cimgui.hbc -request=__HBEXTERN__CIMGUI__

but also not working. maybe I am missing something. I will continue trying.


```
hbmk2: Error: Referenced, missing, but unknown function(s):
       IGSETNEXTWINDOWVIEWPORT(), IMGUIVIEWPORT(), IGDOCKSPACE(),
       IGDOCKBUILDERREMOVENODE(), IGDOCKBUILDERADDNODE(),
       IGDOCKBUILDERSETNODESIZE(), IGDOCKBUILDERSPLITNODE(),
       IGDOCKBUILDERDOCKWINDOW(), IGDOCKBUILDERFINISH(),
       IMGUIWINDOWCLASS_IMGUIWINDOWCLASS(), IMGUIWINDOWCLASS(),
       IGSETNEXTWINDOWCLASS()
```

Lailton Fernando Mariano

unread,
Jul 7, 2025, 1:03:41 PMJul 7
to Harbour Developers
Solved,
I was missing add to the yadbu.hbp 
../cimgui-docking/cimgui.hbp

Thanks

Aleksander Czajczynski

unread,
Jul 8, 2025, 10:06:17 AMJul 8
to harbou...@googlegroups.com
Hello!


Lailton Fernando Mariano wrote:
Solved,
I was missing add to the yadbu.hbp 
../cimgui-docking/cimgui.hbp

After initial build of docking branch, compiling this sample on macOS needs something like this:

IMGUI_DOCKING=y hbmk2 yadbu.hbp


Keeping multiple cimgui's in single tree is confusing, I agree. This will be changed later, cimgui will be a git submodule and a some mini package manager will be there to help getting different ImGui releases.

If you have any other doubts, you can reach me directly, to not pollute the mailing list too much. Anyway can you post a macOS screenshot of a working sample?

Best regards, Aleksander
--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/12bbdc03-c238-49d6-9c95-d377aeeab554n%40googlegroups.com.

Lailton Fernando Mariano

unread,
Jul 8, 2025, 1:14:08 PMJul 8
to Harbour Developers
Ok, thank you

Screenshot 2025-07-08 at 2.12.07 PM.png

Reply all
Reply to author
Forward
0 new messages