Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statically compiling sqlite3 on android required these changes #66

Open
hagna opened this issue Nov 12, 2019 · 0 comments
Open

statically compiling sqlite3 on android required these changes #66

hagna opened this issue Nov 12, 2019 · 0 comments

Comments

@hagna
Copy link

hagna commented Nov 12, 2019

diff --git a/wiishpkg/building/build_android.nim b/wiishpkg/building/build_android.nim
index 54c21d4..9cb4118 100644
--- a/wiishpkg/building/build_android.nim
+++ b/wiishpkg/building/build_android.nim
@@ -97,6 +97,9 @@ proc doAndroidBuild*(directory:string, config:Config): string =
       &"--cpu:{cpu}",
       &"-d:appJavaPackageName={config.java_package_name}",
       "--noMain",
+      "--dynlibOverride:sqlite3",
+      "--dynlibOverride:sqlite3_32",
+      "--dynlibOverride:sqlite3_64",
       "--gc:regions",
       "--header",
       "--threads:on",
@@ -200,7 +203,8 @@ LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := main
-LOCAL_SRC_FILES := {cfiles.join(" ")}
+LOCAL_SRC_FILES := {cfiles.join(" ")} /home/demo/sqlitesrc/sqlite3.c
+LOCAL_CFLAGS := -DSQLITE_ENABLE_FTS5
 LOCAL_LDLIBS := -llog
 
 include $(BUILD_SHARED_LIBRARY)

Where /home/demo/sqlitesrc is the sqlite3 amalgamation.

cfiles also includes another sqlite.nim.c file:

 [armeabi-v7a] Compile thumb  : main <= @m..@s.nimble@spkgs@sndb-0.19.7@sndb@ssqlite.nim.c

Here is the main_mobile.nim that I compiled:

## Hello, World Wiish App
import wiishpkg/webview_mobile
import wiishpkg/mobileutil
import os
import strformat
import strutils
import logging
import times
import ndb/sqlite

let index_html = app.resourcePath("index.html").replace(" ", "%20")


app.launched.handle:
  debug "app: App launched"
  app.window.onReady.handle:
    info "app: onReady"
    app.window.sendMessage("Looks like you're ready, JS!")
  app.window.onMessage.handle(message):
    info "app: onMessage: " & message
    let db1 = open("", "", "", "")
    db1.exec(sql"""create table bar (a);""")
    db1.exec(sql"""create virtual table t using fts5(a, b);""")
    info "create fts5 table"
    app.window.sendMessage("Celebrate in memory db over and over" & message)

app.willExit.handle:
  debug "app: App is exiting"

app.start(url = "file://" & index_html)

It would be nice if wiish had a way to add these build flags and the changes to Android.mk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant