Skip to content

Commit cfccaff

Browse files
committed
add android and ios build
1 parent c880fa1 commit cfccaff

File tree

3 files changed

+55
-8
lines changed

3 files changed

+55
-8
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,34 @@ permissions:
1010
jobs:
1111
build:
1212
runs-on: ${{ matrix.os }}
13-
name: build for ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
13+
name: build${{ matrix.skip-test != true && ' and test' || ''}} for ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
1414
timeout-minutes: 20
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
include:
19+
- os: macos-latest
20+
name: isim
21+
skip-test: true
22+
make: PLATFORM=isim
23+
- os: macos-latest
24+
name: ios
25+
skip-test: true
26+
make: PLATFORM=ios
27+
- os: ubuntu-latest
28+
arch: arm64-v8a
29+
name: android
30+
skip-test: true
31+
make:
32+
PLATFORM=android
33+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
34+
- os: ubuntu-latest
35+
arch: x86_64
36+
name: android
37+
skip-test: true
38+
make:
39+
PLATFORM=android
40+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang
1941
- os: ubuntu-latest
2042
arch: x86_64
2143
name: linux
@@ -38,18 +60,19 @@ jobs:
3860

3961
- uses: actions/checkout@v4.2.2
4062

63+
- name: build sqlite-js
64+
run: make ${{ matrix.make && matrix.make || ''}}
65+
4166
- name: windows install sqlite3
4267
if: matrix.os == 'windows-latest'
4368
run: choco install sqlite -y
4469

4570
- name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION
46-
if: matrix.os == 'macos-latest'
71+
if: matrix.name == 'macos'
4772
run: brew link sqlite --force
48-
49-
- name: build sqlite-js
50-
run: make
5173

5274
- name: test sqlite-js
75+
if: matrix.skip-test != true
5376
run: make test
5477

5578
- uses: actions/upload-artifact@v4.6.2

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for SQLite JavaScript Extension
2-
# Supports compilation for Linux, macOS, and Windows
2+
# Supports compilation for Linux, macOS, Windows, Android and iOS
33

44
# Set default platform if not specified
55
ifeq ($(OS),Windows_NT)
@@ -33,7 +33,6 @@ CFLAGS := -Wall -Wextra -fPIC -g -O2 -DQJS_BUILD_LIBC $(INCLUDES)
3333
ifeq ($(PLATFORM),windows)
3434
TARGET := $(DIST_DIR)/js.dll
3535
LDFLAGS := -shared
36-
CC := gcc
3736
# Windows-specific flags
3837
CFLAGS += -D_WIN32
3938
# Create .def file for Windows
@@ -43,6 +42,28 @@ else ifeq ($(PLATFORM),macos)
4342
LDFLAGS := -dynamiclib -undefined dynamic_lookup
4443
# macOS-specific flags
4544
CFLAGS += -arch x86_64 -arch arm64
45+
else ifeq ($(PLATFORM),android)
46+
# Use Android NDK's Clang compiler, the user should set the CC
47+
# example CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
48+
ifeq ($(filter %-clang,$(CC)),)
49+
$(error "CC must be set to the Android NDK's Clang compiler")
50+
endif
51+
TARGET := $(DIST_DIR)/js.so
52+
LDFLAGS := -shared
53+
# Android-specific flags
54+
CFLAGS += -D__ANDROID__
55+
else ifeq ($(PLATFORM),ios)
56+
TARGET := $(DIST_DIR)/js.dylib
57+
SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0
58+
LDFLAGS := -dynamiclib $(SDK)
59+
# iOS-specific flags
60+
CFLAGS += -arch arm64 $(SDK)
61+
else ifeq ($(PLATFORM),isim)
62+
TARGET := $(DIST_DIR)/js.dylib
63+
SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0
64+
LDFLAGS := -dynamiclib $(SDK)
65+
# iphonesimulator-specific flags
66+
CFLAGS += -arch x86_64 -arch arm64 $(SDK)
4667
else # linux
4768
TARGET := $(DIST_DIR)/js.so
4869
LDFLAGS := -shared
@@ -112,6 +133,9 @@ help:
112133
@echo " linux (default on Linux)"
113134
@echo " macos (default on macOS)"
114135
@echo " windows (default on Windows)"
136+
@echo " android (needs CC to be set to Android NDK's Clang compiler)"
137+
@echo " ios (only on macOS)"
138+
@echo " isim (only on macOS)"
115139
@echo ""
116140
@echo "Targets:"
117141
@echo " all - Build the extension (default)"

src/sqlitejs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "sqlite3.h"
1717
#endif
1818

19-
#define SQLITE_JS_VERSION "1.1.1"
19+
#define SQLITE_JS_VERSION "1.1.2"
2020

2121
int sqlite3_js_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
2222
const char *sqlitejs_version (void);

0 commit comments

Comments
 (0)