Skip to content

Fix support for Unity 6 web builds by letting Unity compile the plugin #50

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

Merged
merged 5 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
target: docker-all-linux
- platform: android
target: docker-all-android
- platform: webgl
target: docker-all-webgl
steps:
- uses: actions/checkout@v3
- name: Cache Docker files
Expand All @@ -37,7 +35,6 @@ jobs:
with:
name: gilzoide-sqlite-net-${{ matrix.platform }}
path: |
Plugins/lib/${{ matrix.platform }}/**/*.bc
Plugins/lib/${{ matrix.platform }}/**/*.dll
Plugins/lib/${{ matrix.platform }}/**/*.dylib
Plugins/lib/${{ matrix.platform }}/**/*.so
Expand Down
32 changes: 2 additions & 30 deletions Plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Android setup
ANDROID_NDK_ROOT ?=
# WebGL/Emscripten setup
EMCC ?= emcc
# macOS code signing setup
CODESIGN ?= codesign
MACOS_CODESIGN_SIGNATURE ?=
Expand All @@ -20,27 +18,17 @@ BUILD_DIRS = \
lib/windows/x86_64 lib/windows/x86 lib/windows/arm64 \
lib/linux/x86_64 lib/linux/x86 \
lib/macos \
lib/android/arm64 lib/android/arm32 lib/android/x86 lib/android/x86_64 \
lib/webgl
lib/android/arm64 lib/android/arm32 lib/android/x86 lib/android/x86_64

SQLITE_SRC = sqlite-amalgamation/sqlite3.c
SQLITE_CFLAGS_SRC = tools~/sqlite-cflags.txt
SQLITE_NET_SRC = $(wildcard sqlite-net~/src/*.cs) sqlite-net~/LICENSE.txt
SQLITE_NET_DEST = ../Runtime/sqlite-net
SQLITE_NET_SED_SCRIPT = tools~/fix-library-path.sed

ifneq ($(findstring 4.,$(MAKE_VERSION)),)
SQLITE_CFLAGS = $(file < $(SQLITE_CFLAGS_SRC))
else
SQLITE_CFLAGS = $(shell cat $(SQLITE_CFLAGS_SRC))
endif
CFLAGS += $(SQLITE_CFLAGS)

$(BUILD_DIRS):
mkdir -p $@

.PRECIOUS: lib/%/sqlite3.o~
lib/%/sqlite3.o~: .EXTRA_PREREQS = $(SQLITE_CFLAGS_SRC)
lib/%/sqlite3.o~: $(SQLITE_SRC) | lib/%
$(CC) -c -o $@ $< $(CFLAGS)

Expand All @@ -64,11 +52,6 @@ ifdef MACOS_CODESIGN_SIGNATURE
$(CODESIGN) -s "$(MACOS_CODESIGN_SIGNATURE)" $@
endif

# iOS/tvOS/visionOS compile flags
sqlite-amalgamation/sqlite3.c.meta: .EXTRA_PREREQS = $(SQLITE_CFLAGS_SRC)
sqlite-amalgamation/sqlite3.c.meta:
sed -i '' -E -e 's/(\s*CompileFlags:).*/\1 $(SQLITE_CFLAGS)/' $@

# Android
check-ndk-root:
ifndef ANDROID_NDK_ROOT
Expand All @@ -85,10 +68,6 @@ lib/android/arm32/libgilzoide-sqlite-net.so: CC = $(wildcard $(ANDROID_NDK_ROOT)
lib/android/x86_64/libgilzoide-sqlite-net.so: CC = $(wildcard $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/*/bin/x86_64-linux-android21-clang)
lib/android/x86/libgilzoide-sqlite-net.so: CC = $(wildcard $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/*/bin/i686-linux-android21-clang)

# WebGL
lib/webgl/libgilzoide-sqlite-net.bc: .EXTRA_PREREQS = $(SQLITE_CFLAGS_SRC)
lib/webgl/libgilzoide-sqlite-net.bc: $(SQLITE_SRC) | lib/webgl
$(EMCC) -c -emit-llvm -o $@ $< $(CFLAGS)

# Source
$(SQLITE_NET_DEST)/%.cs: sqlite-net~/src/%.cs $(SQLITE_NET_SED_SCRIPT)
Expand Down Expand Up @@ -123,14 +102,11 @@ android-arm32: lib/android/arm32/libgilzoide-sqlite-net.so
android-x86_64: lib/android/x86_64/libgilzoide-sqlite-net.so
android-x86: lib/android/x86/libgilzoide-sqlite-net.so

webgl: lib/webgl/libgilzoide-sqlite-net.bc

source: $(SQLITE_NET_DEST)/License.txt $(SQLITE_NET_DEST)/AssemblyInfo.cs $(SQLITE_NET_DEST)/SQLite.cs $(SQLITE_NET_DEST)/SQLiteAsync.cs

all-android: android-arm64 android-arm32 android-x86_64 android-x86
all-apple: macos-universal sqlite-amalgamation/sqlite3.c.meta
all-apple: macos-universal
all-linux: linux-x86_64
all-webgl: webgl
all-windows: windows-x86_64 windows-x86
all-windows-mingw: windows-mingw-x86_64 windows-mingw-x86
all-windows-llvm-mingw: windows-mingw-x86_64 windows-mingw-x86 windows-mingw-arm64
Expand All @@ -142,9 +118,6 @@ docker-all-android:
docker-all-linux:
docker build -f tools~/Dockerfile.build.linux --platform=linux/amd64 -t gilzoide-sqlite-net-build-linux:latest $(DOCKER_BUILD_ARGS) .
docker run --rm -v "$(CURDIR)":/src -w /src --platform=linux/amd64 gilzoide-sqlite-net-build-linux:latest make all-linux
docker-all-webgl:
docker build -f tools~/Dockerfile.build.webgl -t gilzoide-sqlite-net-build-webgl:latest $(DOCKER_BUILD_ARGS) .
docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-sqlite-net-build-webgl:latest make all-webgl
docker-all-windows:
docker build -f tools~/Dockerfile.build.windows -t gilzoide-sqlite-net-build-windows:latest $(DOCKER_BUILD_ARGS) .
docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-sqlite-net-build-windows:latest make all-windows-mingw
Expand All @@ -159,5 +132,4 @@ download-latest-build:
rsync -r $(TMPDIR)/gilzoide-sqlite-net-linux/* lib/linux/
rsync -r $(TMPDIR)/gilzoide-sqlite-net-android/* lib/android/
rsync -r $(TMPDIR)/gilzoide-sqlite-net-macos/* lib/macos/
rsync -r $(TMPDIR)/gilzoide-sqlite-net-webgl/* lib/webgl/
$(RM) -r $(TMPDIR)
8 changes: 0 additions & 8 deletions Plugins/lib/webgl.meta

This file was deleted.

Binary file removed Plugins/lib/webgl/libgilzoide-sqlite-net.bc
Binary file not shown.
2 changes: 2 additions & 0 deletions Plugins/sqlite-amalgamation/sqlite3.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "sqlite3_defines.h"

/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.48.0. By combining all the individual C code files into this
Expand Down
14 changes: 10 additions & 4 deletions Plugins/sqlite-amalgamation/sqlite3.c.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Plugins/sqlite-amalgamation/sqlite3.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "sqlite3_defines.h"

/*
** 2001-09-15
**
Expand Down
7 changes: 6 additions & 1 deletion Plugins/sqlite-amalgamation/sqlite3.h.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Plugins/sqlite-amalgamation/sqlite3_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Compile-time definitions used to build SQLite
// This is a separate file so that IL2CPP can use the same flags on all platforms
#define SQLITE_USE_URI 1
#define SQLITE_DQS 0
#define SQLITE_DEFAULT_MEMSTATUS 0
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS 1
#define SQLITE_MAX_EXPR_DEPTH 0
#define SQLITE_OMIT_DECLTYPE 1
#define SQLITE_OMIT_DEPRECATED 1
#define SQLITE_OMIT_PROGRESS_CALLBACK 1
#define SQLITE_OMIT_SHARED_CACHE 1
#define SQLITE_USE_ALLOCA 1
#define SQLITE_ENABLE_RTREE 1
#define SQLITE_ENABLE_MATH_FUNCTIONS 1
#define HAVE_ISNAN 1
#define SQLITE_ENABLE_GEOPOLY 1
#define SQLITE_ENABLE_FTS5 1
#define SQLITE_ENABLE_HIDDEN_COLUMNS 1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Plugins/sqlite-amalgamation/sqlite3ext.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "sqlite3_defines.h"

/*
** 2006 June 7
**
Expand Down
7 changes: 6 additions & 1 deletion Plugins/sqlite-amalgamation/sqlite3ext.h.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Plugins/tools~/Dockerfile.build.webgl

This file was deleted.

1 change: 0 additions & 1 deletion Plugins/tools~/sqlite-cflags.txt

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ This package provides the excelent [SQLite-net](https://github.com/praeclarum/sq
+ `SQLiteConnection.Deserialize` extension method for deserializing memory (`byte[]`, `NativeArray<byte>` or `ReadOnlySpan<byte>`) into an open database (reference: [SQLite Deserialization](https://www.sqlite.org/c3ref/deserialize.html)).
- [SQLite 3.48.0](https://sqlite.org/releaselog/3_48_0.html)
+ Enabled modules: [R\*Tree](https://sqlite.org/rtree.html), [Geopoly](https://sqlite.org/geopoly.html), [FTS5](https://sqlite.org/fts5.html), [Built-In Math Functions](https://www.sqlite.org/lang_mathfunc.html)
+ Prebuilt for Windows, Linux, macOS, Android and WebGL
+ Built from source in iOS, tvOS and visionOS projects
+ Supports Windows, Linux, macOS, WebGL, Android, iOS, tvOS and visionOS platforms
+ Supports persisting data in WebGL builds by using a [custom VFS backed by Indexed DB](https://github.com/gilzoide/idbvfs).


Expand Down
Loading