Recent

Author Topic: dwindows for Android  (Read 1401 times)

PierceNg

  • Sr. Member
  • ****
  • Posts: 394
    • SamadhiWeb
dwindows for Android
« on: December 16, 2022, 01:25:55 pm »
Continuing from the 'GTK3 proposal' thread, another baby step taken! I've now gotten my littlest demo to run on Android, on emulator and phone. Emulator screenshot attached.

Some notes:

- Android Studio uses Gradle as its build system. For 'native' projects, Gradle calls CMake. I can't quite get CMake to run FPC cross compiler from within Android Studio yet. So I build the Pascal shared library using shell script, then have CMake incorporate the shared library into the final artefact.

- For 32-bit ARM, the Gnu binutils cross linker is not able to produce the Pascal shared library:
Code: Text  [Select][+][-]
  1. Assembling dwindows
  2. Assembling dwprunner
  3. Linking armeabi-v7a/libdwprunner.so
  4. /home/pierce/pkg/cross/arm-linux-androideabi/bin/arm-linux-androideabi-ld.bfd: error:
  5. source object /home/pierce/pkg/android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/29/crtbegin_so.o
  6. has EABI version 5, but target armeabi-v7a/libdwprunner.so has EABI version 0
 
But:
Code: Text  [Select][+][-]
  1. % file *.o
  2. dwindows.o:  ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
  3. dwprunner.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
So I have no idea what's happening here.

I'll look into iOS next.

Edit: iOS thread here: https://forum.lazarus.freepascal.org/index.php/topic,61621.0.html
« Last Edit: December 17, 2022, 06:32:44 am by PierceNg »

PierceNg

  • Sr. Member
  • ****
  • Posts: 394
    • SamadhiWeb
Re: dwindows for Android
« Reply #1 on: April 19, 2024, 10:54:44 am »
Coming back to this after a (long) break, I've now built a demo/exercise app using a webview widget for the user interface, with bidirectional Javascript-Pascal in-process RPC.

The main body of the code loads in-app static content, then binds the names 'HostSayHello' and 'HostExit' for callback to Pascal code from Javascript. Said Pascal code in turns invokes Javascript to manipulate the DOM.

Code: Pascal  [Select][+][-]
  1.   webwidget := dw_html_new(1001); // 1001 is an identifier
  2.   if webwidget <> nil then
  3.     begin
  4.       dw_box_pack_start(mainwindow, webwidget, 0, 0, DW_TRUE, DW_TRUE, 0);
  5.       dw_html_url(webwidget, 'file:///android_asset/index.html');
  6.       dw_html_javascript_add(webwidget, 'HostSayHello');
  7.       dw_html_javascript_add(webwidget, 'HostExit');
  8.       dw_signal_connect(webwidget, DW_SIGNAL_HTML_MESSAGE, @html_message_callback, nil);
  9.     end;

Screenshot of the app running in Android emulator attached.
« Last Edit: April 19, 2024, 10:56:20 am by PierceNg »

 

TinyPortal © 2005-2018