Skip to content

Commit b047b89

Browse files
committed
fix: add binaries strip commands for each platform, and missing e2e tests dependencies for CI
1 parent 673a645 commit b047b89

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
container: ${{ matrix.container && matrix.container || '' }}
1818
env:
1919
APIKEY: ${{ secrets.APIKEY }}
20+
GITHUB_TOKEN: ${{ github.token }}
2021
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}${{ matrix.variant && format('-{0}', matrix.variant) || '' }} build${{ matrix.skip_test != true && ( matrix.name != 'android' || matrix.arch == 'x86_64' ) && ' + test' || ''}}
2122
timeout-minutes: 60
2223
strategy:
@@ -368,6 +369,12 @@ jobs:
368369
make build/e2e ${{ matrix.make }} SQLITE_AMALGAM=${SQLITE_DIR}/sqlite3.c
369370
echo "::endgroup::"
370371
372+
if [ "${{ matrix.variant }}" != "local" ]; then
373+
echo "::group::download sqlite-vector for android e2e"
374+
make build/vector.so ${{ matrix.make }}
375+
echo "::endgroup::"
376+
fi
377+
371378
- name: android test sqlite-memory
372379
if: matrix.name == 'android' && matrix.arch == 'x86_64'
373380
uses: reactivecircus/android-emulator-runner@v2.34.0
@@ -388,14 +395,12 @@ jobs:
388395
echo "Testing extension loading..."
389396
adb shell "sqlite3 :memory: '.load /data/local/tmp/memory.so' 'SELECT memory_version();'"
390397
echo "Extension loading test passed!"
391-
if [ "${{ matrix.variant }}" != "local" ]; then
392-
adb push ${{ github.workspace }}/build/e2e /data/local/tmp/
393-
adb push ${{ github.workspace }}/build/vector.so /data/local/tmp/
394-
adb shell "chmod +x /data/local/tmp/e2e"
395-
echo "Running e2e tests..."
396-
adb shell "APIKEY=$APIKEY VECTOR_LIB=/data/local/tmp/vector /data/local/tmp/e2e"
397-
echo "E2E tests passed!"
398-
fi
398+
[ "${{ matrix.variant }}" = "local" ] || adb push ${{ github.workspace }}/build/e2e /data/local/tmp/
399+
[ "${{ matrix.variant }}" = "local" ] || adb push ${{ github.workspace }}/build/vector.so /data/local/tmp/
400+
[ "${{ matrix.variant }}" = "local" ] || adb shell "chmod +x /data/local/tmp/e2e"
401+
[ "${{ matrix.variant }}" = "local" ] || echo "Running e2e tests..."
402+
[ "${{ matrix.variant }}" = "local" ] || adb shell "APIKEY=$APIKEY VECTOR_LIB=/data/local/tmp/vector /data/local/tmp/e2e"
403+
[ "${{ matrix.variant }}" = "local" ] || echo "E2E tests passed!"
399404
400405
- name: unix test sqlite-memory
401406
if: matrix.skip_test != true && matrix.os != 'windows-2022' && matrix.name != 'android'

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ CXX ?= clang++
4444
CFLAGS := -Wall -Wextra -O2 -fPIC
4545
CXXFLAGS := -Wall -Wextra -O2 -fPIC -std=c++17
4646
DEFINES :=
47+
STRIP_CMD ?= @:
4748

4849
INCLUDES := -I$(SRC_DIR)
4950

@@ -61,6 +62,7 @@ ifeq ($(PLATFORM),macos)
6162
LDFLAGS := -dynamiclib $(FRAMEWORKS)
6263
INCLUDES += -I/opt/homebrew/include -I/usr/local/include
6364
TEST_LDFLAGS := -L/opt/homebrew/lib -L/usr/local/lib -lsqlite3
65+
STRIP_CMD = strip -x -S $(TARGET)
6466

6567
CURL_SSL_LIBS := -framework CoreFoundation
6668

@@ -84,6 +86,7 @@ else ifeq ($(PLATFORM),linux)
8486
CXX := g++
8587
LDFLAGS := -shared -lpthread -lm -ldl
8688
TEST_LDFLAGS := -lsqlite3 -lpthread -lm -ldl
89+
STRIP_CMD = strip --strip-unneeded $(TARGET)
8790
CURL_CONFIG := --with-openssl
8891
CURL_SSL_LIBS := -lssl -lcrypto
8992

@@ -94,6 +97,7 @@ else ifeq ($(PLATFORM),windows)
9497
LDFLAGS := -shared -static-libgcc -lbcrypt
9598
OUTPUT_NAME := memory
9699
TEST_LDFLAGS := -lsqlite3 -lbcrypt
100+
STRIP_CMD = strip --strip-unneeded $(TARGET)
97101
CURL_CONFIG := --with-schannel CFLAGS="-DCURL_STATICLIB"
98102
CURL_SSL_LIBS := -lcrypt32 -lsecur32 -lws2_32
99103

@@ -125,11 +129,13 @@ else ifeq ($(PLATFORM),android)
125129
CURL_LIB := $(CURL_DIR)/$(PLATFORM)/$(ANDROID_ARCH)/libcurl.a
126130
MBEDTLS_INSTALL_DIR := $(MBEDTLS_DIR)/$(PLATFORM)/$(ANDROID_ARCH)
127131
MBEDTLS := $(MBEDTLS_INSTALL_DIR)/lib/libmbedtls.a
132+
CFLAGS = -Wall -Wextra -Os -fPIC -ffunction-sections -fdata-sections -flto
128133
CFLAGS += -I$(MBEDTLS_INSTALL_DIR)/include
129134
CURL_CONFIG := --host $(ANDROID_ARCH)-linux-$(ANDROID_ABI_SUFFIX) --with-mbedtls=$(CURDIR)/$(MBEDTLS_INSTALL_DIR) LDFLAGS="-L$(CURDIR)/$(MBEDTLS_INSTALL_DIR)/lib" LIBS="-lmbedtls -lmbedx509 -lmbedcrypto" AR=$(TOOLCHAIN)/bin/llvm-ar AS=$(TOOLCHAIN)/bin/llvm-as CC=$(CC) CXX=$(CXX) LD=$(TOOLCHAIN)/bin/ld RANLIB=$(TOOLCHAIN)/bin/llvm-ranlib STRIP=$(TOOLCHAIN)/bin/llvm-strip
130135
CURL_SSL_LIBS := -L$(MBEDTLS_INSTALL_DIR)/lib -lmbedtls -lmbedx509 -lmbedcrypto
131136

132-
LDFLAGS := -shared -static-libstdc++ -llog -Wl,-z,max-page-size=16384
137+
LDFLAGS := -shared -static-libstdc++ -llog -Wl,-z,max-page-size=16384 -Wl,--gc-sections -flto
138+
STRIP_CMD = $(TOOLCHAIN)/bin/llvm-strip --strip-unneeded $(TARGET)
133139
TEST_LDFLAGS := -ldl -llog -lm
134140

135141
else ifeq ($(PLATFORM),ios)
@@ -140,6 +146,7 @@ else ifeq ($(PLATFORM),ios)
140146
CXX := $(shell xcrun --sdk iphoneos -f clang++)
141147
CFLAGS += -isysroot $(SDK) -arch arm64 -miphoneos-version-min=14.0
142148
LDFLAGS := -dynamiclib -isysroot $(SDK) -arch arm64 -miphoneos-version-min=14.0 -framework Security
149+
STRIP_CMD = strip -x -S $(TARGET)
143150
CURL_CONFIG := --host=arm64-apple-darwin --with-secure-transport CFLAGS="-arch arm64 -isysroot $$(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=14.0"
144151
CURL_SSL_LIBS := -framework CoreFoundation
145152

@@ -151,6 +158,7 @@ else ifeq ($(PLATFORM),ios-sim)
151158
CXX := $(shell xcrun --sdk iphonesimulator -f clang++)
152159
CFLAGS += -isysroot $(SDK) -arch arm64 -arch x86_64 -miphonesimulator-version-min=14.0
153160
LDFLAGS := -dynamiclib -isysroot $(SDK) -arch arm64 -arch x86_64 -miphonesimulator-version-min=14.0 -framework Security
161+
STRIP_CMD = strip -x -S $(TARGET)
154162
CURL_CONFIG := --host=arm64-apple-darwin --with-secure-transport CFLAGS="-arch x86_64 -arch arm64 -isysroot $$(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=14.0"
155163
CURL_SSL_LIBS := -framework CoreFoundation
156164
endif
@@ -337,6 +345,7 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
337345
$(TARGET): $(C_OBJECTS) $(LLAMA_LIBS) $(CURL_DEPS) | $(DIST_DIR)
338346
@echo "Linking $(TARGET)..."
339347
@$(LINKER) $(C_OBJECTS) $(LLAMA_LIBS) $(CURL_DEPS) $(LDFLAGS) -o $(TARGET)
348+
$(STRIP_CMD)
340349
@echo "Build complete: $(TARGET)"
341350

342351
.PHONY: test
@@ -407,20 +416,30 @@ $(BUILD_DIR)/e2e: $(BUILD_DIR)/e2e.o $(TEST_C_OBJECTS) $(TEST_SQLITE_OBJ) $(LLAM
407416
-o $@
408417

409418
VECTOR_PLATFORM ?= $(PLATFORM)
419+
VECTOR_ARCH := $(ARCH)
410420
VECTOR_LIB := $(BUILD_DIR)/vector.$(EXT)
411421

422+
# Map arch names to match sqlite-vector release naming
423+
ifeq ($(ARCH),aarch64)
424+
VECTOR_ARCH := arm64
425+
endif
426+
412427
# Detect musl libc (Alpine Linux)
413428
ifeq ($(PLATFORM),linux)
414429
ifeq ($(shell cat /etc/alpine-release 2>/dev/null && echo yes),yes)
415430
VECTOR_PLATFORM := linux-musl
416431
endif
417432
endif
418433

434+
# Use GitHub token if available (avoids API rate limits on CI)
435+
GITHUB_AUTH := $(if $(GITHUB_TOKEN),-H "Authorization: token $(GITHUB_TOKEN)",)
436+
419437
$(VECTOR_LIB): | $(BUILD_DIR)
420-
@echo "Downloading sqlite-vector for $(VECTOR_PLATFORM)-$(ARCH)..."
421-
@VECTOR_TAG=$$(curl -sL https://api.github.com/repos/sqliteai/sqlite-vector/releases/latest | grep '"tag_name"' | head -1 | sed 's/.*: *"\(.*\)".*/\1/') && \
438+
@echo "Downloading sqlite-vector for $(VECTOR_PLATFORM)-$(VECTOR_ARCH)..."
439+
@VECTOR_TAG=$$(curl -sL $(GITHUB_AUTH) https://api.github.com/repos/sqliteai/sqlite-vector/releases/latest | grep '"tag_name"' | head -1 | sed 's/.*: *"\(.*\)".*/\1/') && \
440+
echo "Downloading version $${VECTOR_TAG}..." && \
422441
curl -sL -o $(BUILD_DIR)/vector.tar.gz \
423-
"https://github.com/sqliteai/sqlite-vector/releases/download/$${VECTOR_TAG}/vector-$(VECTOR_PLATFORM)-$(ARCH)-$${VECTOR_TAG}.tar.gz" && \
442+
"https://github.com/sqliteai/sqlite-vector/releases/download/$${VECTOR_TAG}/vector-$(VECTOR_PLATFORM)-$(VECTOR_ARCH)-$${VECTOR_TAG}.tar.gz" && \
424443
tar -xzf $(BUILD_DIR)/vector.tar.gz -C $(BUILD_DIR) && \
425444
rm -f $(BUILD_DIR)/vector.tar.gz
426445
@test -f $(VECTOR_LIB) || (echo "Error: $(VECTOR_LIB) not found after download" && exit 1)

test/e2e.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@
1111
#include <stdio.h>
1212
#include <stdlib.h>
1313
#include <string.h>
14+
#include <stdint.h>
1415
#include <math.h>
15-
#include <sys/stat.h>
16-
#include <unistd.h>
1716
#include "sqlite-memory.h"
1817

1918
#ifdef _WIN32
2019
#include <direct.h>
20+
#include <io.h>
2121
#define MKDIR(path) _mkdir(path)
2222
#define RMDIR(path) _rmdir(path)
2323
#else
24+
#include <sys/stat.h>
25+
#include <unistd.h>
2426
#define MKDIR(path) mkdir(path, 0755)
2527
#define RMDIR(path) rmdir(path)
2628
#endif

0 commit comments

Comments
 (0)