From: stephan Date: Thu, 10 Aug 2023 20:52:14 +0000 (+0000) Subject: Add a working dist zip file for the JNI bits. X-Git-Tag: version-3.43.0~47^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c08c8c208a89a6a27dc3e879ccc7c36e13f453f;p=thirdparty%2Fsqlite.git Add a working dist zip file for the JNI bits. FossilOrigin-Name: d6a4d212ceba662470d8957b6a8d7075d18a84bd0d3e13ce7adcab03604fc3b7 --- diff --git a/ext/jni/GNUmakefile b/ext/jni/GNUmakefile index 3c67e622b4..6e21adc22a 100644 --- a/ext/jni/GNUmakefile +++ b/ext/jni/GNUmakefile @@ -2,8 +2,10 @@ # build assumes a Linux-like system. default: all -JDK_HOME ?= $(HOME)/jdk/current -# /usr/lib/jvm/default-javajava-19-openjdk-amd64 +JAVA_HOME ?= $(HOME)/jdk/current +# e.g. /usr/lib/jvm/default-javajava-19-openjdk-amd64 +JDK_HOME ?= $(JAVA_HOME) +# ^^^ JDK_HOME is not as widely used as JAVA_HOME bin.javac := $(JDK_HOME)/bin/javac bin.java := $(JDK_HOME)/bin/java bin.jar := $(JDK_HOME)/bin/jar @@ -13,8 +15,7 @@ endif MAKEFILE := $(lastword $(MAKEFILE_LIST)) $(MAKEFILE): -package.version := 0.0.1 -package.jar := sqlite3-jni-$(package.version).jar +package.jar := sqlite3-jni.jar dir.top := ../.. dir.tool := ../../tool @@ -246,10 +247,17 @@ tester: endif tests: test tester - -$(package.jar): $(CLASS_FILES) $(MAKEFILE) +package.jar.in := $(abspath $(dir.src)/jar.in) +CLEAN_FILES += $(package.jar.in) +$(package.jar.in): $(MAKEFILE) $(CLASS_FILES.main) + cd $(dir.src); ls -1 org/sqlite/jni/*.* > $@ + @ls -la $@ + @echo "To use this jar you will need the -Djava.library.path=DIR/WITH/libsqlite3-jni.so flag." + @echo "e.g. java -jar $@ -Djava.library.path=bld" + +$(package.jar): $(CLASS_FILES) $(MAKEFILE) $(package.jar.in) rm -f $(dir.src)/c/*~ $(dir.src.jni)/*~ - $(bin.jar) -cfe $@ org.sqlite.Tester1 -C src org -C src c + cd $(dir.src); $(bin.jar) -cfe ../$@ org.sqlite.jni.Tester1 @$(package.jar.in) jar: $(package.jar) @@ -279,7 +287,6 @@ dist-name := $(dist-name-prefix)-TEMP dist-dir.top := $(dist-name) dist-dir.src := $(dist-dir.top)/src -dist-dir.c := $(dist-dir.src)/c dist.top.extras := \ README.md @@ -287,22 +294,24 @@ dist.top.extras := \ dist: \ $(bin.version-info) $(sqlite3.canonical.c) \ - $(MAKEFILE) $(MAKEFILE.dist) + $(package.jar) $(MAKEFILE) @echo "Making end-user deliverables..." @rm -fr $(dist-dir.top) - @mkdir -p $(dist-dir.top) $(dist-dir.c) + @mkdir -p $(dist-dir.src) @cp -p $(dist.top.extras) $(dist-dir.top)/. - @cp -p $(dir.src.c)/*.[ch] $(dist-dir.c)/. - @cp -p $(sqlite3.canonical.c) $(sqlite3.canonical.h) $(dist-dir.c)/. - @cp -rp $(dir.src)/org $(dist-dir.src) + @cp -p jar-dist.make $(dist-dir.top)/Makefile + @cp -p $(dir.src.c)/*.[ch] $(dist-dir.src)/. + @cp -p $(sqlite3.canonical.c) $(sqlite3.canonical.h) $(dist-dir.src)/. @set -e; \ vnum=$$($(bin.version-info) --download-version); \ + vjar=$$($(bin.version-info) --version); \ vdir=$(dist-name-prefix)-$$vnum; \ arczip=$$vdir.zip; \ + cp -p $(package.jar) $(dist-dir.top)/sqlite3-jni-$${vjar}.jar; \ echo "Making $$arczip ..."; \ rm -fr $$arczip $$vdir; \ mv $(dist-dir.top) $$vdir; \ - zip -qr $$arczip $$vdir -x '*.class' -x '*~'; \ + zip -qr $$arczip $$vdir; \ rm -fr $$vdir; \ ls -la $$arczip; \ set +e; \ diff --git a/ext/jni/README.md b/ext/jni/README.md index 5b985a0550..80486d4a07 100644 --- a/ext/jni/README.md +++ b/ext/jni/README.md @@ -2,7 +2,16 @@ SQLite3 via JNI ======================================================================== This directory houses a Java Native Interface (JNI) binding for the -sqlite3 API. +sqlite3 API. If you are reading this from the distribution ZIP file, +links to resources in the canonical source tree will note work. The +canonical copy of this file can be browsed at: + + + +Technical support is available in the forum: + + + > **FOREWARNING:** this subproject is very much in development and subject to any number of changes. Please do not rely on any @@ -23,7 +32,8 @@ Project goals/requirements: - No 3rd-party dependencies beyond the JDK. That includes no build-level dependencies for specific IDEs and toolchains. We welcome the addition of build files for arbitrary environments - insofar as they do not directly interfere with each other. + insofar as they neither interfere with each other nor become + a maintenance burden for the sqlite developers. Non-goals: @@ -34,11 +44,8 @@ Non-goals: Significant TODOs ======================================================================== -- LOTS of APIs left to bind. - -- Bundling of the resulting class files into a jar. Bundling the DLLs - is a much larger problem, as they inherently have platform-specific - OS-level dependencies which we obviously cannot bundle. +- Lots of APIs left to bind. Most "day-to-day" functionality is already + in place and is believed to work well. Building @@ -53,7 +60,7 @@ The canonical builds assumes a Linux-like environment and requires: Put simply: ``` -$ export JDK_HOME=/path/to/jdk/root +$ export JAVA_HOME=/path/to/jdk/root $ make $ make test $ make clean @@ -96,10 +103,9 @@ Known consequences and limitations of this discrepancy include: - Names of databases, tables, and collations must not contain characters which differ in MUTF-8 and UTF-8, or certain APIs will - mis-translate them on their way between languages. The - sqlite3_trace_v2() implementation is also currently affected by - this, in that it will necessarily translate traced SQL statements to - MUTF-8. + mis-translate them on their way between languages. APIs which + transfer other client-side data to Java take extra care to + convert the data at the cost of performance. [modutf8]: https://docs.oracle.com/javase/8/docs/api/java/io/DataInput.html#modified-utf-8 @@ -164,10 +170,13 @@ a much more Java-esque usage: ``` int rc = sqlite3_create_collation(db, "mycollation", SQLITE_UTF8, new Collation(){ + // Required comparison function: @Override public int xCompare(byte[] lhs, byte[] rhs){ ... } + // Optional finalizer function: @Override public void xDestroy(){ ... } + // Optional local state: private String localState1 = "This is local state. There are many like it, but this one is mine."; @@ -179,8 +188,7 @@ int rc = sqlite3_create_collation(db, "mycollation", SQLITE_UTF8, new Collation( Noting that: - It is still possible to bind in call-scope-local state via closures, - but using member data for the Collation object is generally a better - fit for Java. + if desired. - No capabilities of the C API are lost or unduly obscured via the above API reshaping, so power users need not make any compromises. diff --git a/ext/jni/jar-dist.make b/ext/jni/jar-dist.make new file mode 100644 index 0000000000..9f9d13002a --- /dev/null +++ b/ext/jni/jar-dist.make @@ -0,0 +1,59 @@ +#!/this/is/make +#^^^^ help emacs out +# +# This is a POSIX-make-compatible makefile for building the sqlite3 +# JNI library from "dist" zip file. It must be edited to set the +# proper top-level JDK directory and, depending on the platform, add a +# platform-specific -I directory. It should build as-is with any +# 2020s-era version of gcc or clang. It requires JDK version 8 or +# higher. + +default: all + +JAVA_HOME = /usr/lib/jvm/java-1.8.0-openjdk-amd64 +CFLAGS = \ + -fPIC \ + -Isrc \ + -I$(JAVA_HOME)/include \ + -I$(JAVA_HOME)/include/linux \ + -I$(JAVA_HOME)/include/apple \ + -I$(JAVA_HOME)/include/bsd \ + -Wall + +SQLITE_OPT = \ + -DSQLITE_ENABLE_RTREE \ + -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ + -DSQLITE_ENABLE_STMTVTAB \ + -DSQLITE_ENABLE_DBPAGE_VTAB \ + -DSQLITE_ENABLE_DBSTAT_VTAB \ + -DSQLITE_ENABLE_BYTECODE_VTAB \ + -DSQLITE_ENABLE_OFFSET_SQL_FUNC \ + -DSQLITE_OMIT_LOAD_EXTENSION \ + -DSQLITE_OMIT_DEPRECATED \ + -DSQLITE_OMIT_SHARED_CACHE \ + -DSQLITE_THREADSAFE=0 \ + -DSQLITE_TEMP_STORE=2 \ + -DSQLITE_USE_URI=1 \ + -DSQLITE_ENABLE_FTS5 \ + -DSQLITE_DEBUG +# -DSQLITE_DEBUG is just to work around a -Wall warning +# for a var which gets set in all builds but only read +# via assert(). + +sqlite3-jni.dll = libsqlite3-jni.so +$(sqlite3-jni.dll): + @echo "************************************************************************"; \ + echo "*** If this fails to build, be sure to edit this makefile ***"; \ + echo "*** to configure it for your system. ***"; \ + echo "************************************************************************" + $(CC) $(CFLAGS) $(SQLITE_OPT) \ + src/sqlite3-jni.c -shared -o $@ + @echo "Now try running it with: make test" + +test: $(sqlite3-jni.dll) + java -jar -Djava.library.path=. sqlite3-jni-*.jar + +clean: + -rm -f $(sqlite3-jni.dll) + +all: $(sqlite3-jni.dll) diff --git a/manifest b/manifest index 09b278867e..b744c224f3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\spass\sat\s'make\sdist'\srules\sfor\sthe\sJNI\sbundle,\sbut\sthey\sstill\sneed\sa\sbare-bones,\sposix-make-compatible\smakefile\sto\sinclude\sin\sthe\sbundle. -D 2023-08-10T18:57:37.830 +C Add\sa\sworking\sdist\szip\sfile\sfor\sthe\sJNI\sbits. +D 2023-08-10T20:52:14.899 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -231,8 +231,9 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/jni/GNUmakefile 5a3e20bab883979f7b74fc21ba75dda5300e569cd1d61250c424fae0318c9381 -F ext/jni/README.md e965674505e105626127ad45e628e4d19fcd379cdafc4d23c814c1ac2c55681d +F ext/jni/GNUmakefile d228f18de85e7f2f80e05edce3cc4f32da3c45a308e4e921807ca88279010871 +F ext/jni/README.md 7a614a2fa6c561205f7a53fd8626cf93a7b5711ff454fc1814517f796df398eb +F ext/jni/jar-dist.make f90a553203a57934bf275bed86479485135a52f48ac5c1cfe6499ae07b0b35a4 F ext/jni/src/c/sqlite3-jni.c fa251d2033d2210a88ac6190db923f76681be609b97f840360318ab366f3cbdd F ext/jni/src/c/sqlite3-jni.h b19a104e0566440af566366cea72188bd994a96ba85c3f196acaa6f4a4609a55 F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892 @@ -2089,8 +2090,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc8e8cba67c0dcfb9b416041a19456cf5248d909f3efb6fee707a5950be4f374 -R 235efa3b2867de98f67e2a3f239b46e6 +P ff54e66a4d43f2f0f8b25ded970779e6760865a05346e09b39607bb035b02bd7 +R 97317c60f95c647f5cb8b6c80518e6d5 U stephan -Z c61740ae33854adb8fa7a57e62ce6199 +Z 906b52857ac9716df6a6b1f3a6f4d258 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4bd0784d6f..507f990cea 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff54e66a4d43f2f0f8b25ded970779e6760865a05346e09b39607bb035b02bd7 \ No newline at end of file +d6a4d212ceba662470d8957b6a8d7075d18a84bd0d3e13ce7adcab03604fc3b7 \ No newline at end of file