Skip to content

Commit bf84e86

Browse files
committed
Add Android package dependencies; Fix XCFramework to use make's foreach to avoid shell escaping issues with PLIST/MODULEMAP
1 parent 799d476 commit bf84e86

File tree

8 files changed

+493
-18
lines changed

8 files changed

+493
-18
lines changed

Makefile

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -435,51 +435,51 @@ framework module memory {\
435435
}
436436
endef
437437

438+
LIB_PREFIXES = ios ios-sim macos
438439
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
439440
XCFRAMEWORK_LLAMA = LLAMA="-DGGML_NATIVE=OFF -DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple"
440441

441442
# Helper function to create xcframework from 3 dylibs
442-
# Usage: $(call create_xcframework,variant_suffix,output_name)
443443
define create_xcframework
444-
@for pair in "ios:ios-arm64" "ios-sim:ios-arm64_x86_64-simulator" "macos:macos-arm64_x86_64"; do \
445-
platform=$${pair%%:*}; \
446-
fmwk=$${pair##*:}; \
444+
@$(foreach i,1 2 3,\
445+
prefix=$(word $(i),$(LIB_PREFIXES)); \
446+
fmwk=$(word $(i),$(FMWK_NAMES)); \
447447
mkdir -p $(DIST_DIR)/$$fmwk/memory.framework/Headers; \
448448
mkdir -p $(DIST_DIR)/$$fmwk/memory.framework/Modules; \
449449
cp src/sqlite-memory.h $(DIST_DIR)/$$fmwk/memory.framework/Headers; \
450450
printf "$(PLIST)" > $(DIST_DIR)/$$fmwk/memory.framework/Info.plist; \
451451
printf "$(MODULEMAP)" > $(DIST_DIR)/$$fmwk/memory.framework/Modules/module.modulemap; \
452-
mv $(DIST_DIR)/$${platform}$(1).dylib $(DIST_DIR)/$$fmwk/memory.framework/memory; \
452+
mv $(DIST_DIR)/$${prefix}$(1).dylib $(DIST_DIR)/$$fmwk/memory.framework/memory; \
453453
install_name_tool -id "@rpath/memory.framework/memory" $(DIST_DIR)/$$fmwk/memory.framework/memory; \
454-
done
454+
)
455455
xcodebuild -create-xcframework $(foreach fmwk,$(FMWK_NAMES),-framework $(DIST_DIR)/$(fmwk)/memory.framework) -output $(DIST_DIR)/$(2).xcframework
456456
rm -rf $(foreach fmwk,$(FMWK_NAMES),$(DIST_DIR)/$(fmwk))
457457
endef
458458

459459
.PHONY: xcframework
460460
xcframework:
461-
@# Build remote variant (no llama.cpp)
462-
$(MAKE) -j1 distclean && $(MAKE) PLATFORM=ios OMIT_LOCAL_ENGINE=1 && \
461+
@# Build remote variant (no llama.cpp) - use rm -rf build to preserve dist between builds
462+
MAKEFLAGS= $(MAKE) distclean && MAKEFLAGS= $(MAKE) PLATFORM=ios OMIT_LOCAL_ENGINE=1 && \
463463
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios_remote.dylib && \
464-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=ios-sim OMIT_LOCAL_ENGINE=1 && \
464+
rm -rf $(BUILD_DIR) && MAKEFLAGS= $(MAKE) PLATFORM=ios-sim OMIT_LOCAL_ENGINE=1 && \
465465
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios-sim_remote.dylib && \
466-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=macos OMIT_LOCAL_ENGINE=1 && \
466+
rm -rf $(BUILD_DIR) && MAKEFLAGS= $(MAKE) PLATFORM=macos OMIT_LOCAL_ENGINE=1 && \
467467
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/macos_remote.dylib
468468
$(call create_xcframework,_remote,memory-remote)
469-
@# Build local variant (llama.cpp only)
470-
$(MAKE) -j1 distclean && $(MAKE) PLATFORM=ios OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
469+
@# Build local variant (llama.cpp only) - need distclean between platforms to rebuild llama.cpp
470+
rm -rf $(DIST_DIR) && MAKEFLAGS= $(MAKE) distclean && MAKEFLAGS= $(MAKE) PLATFORM=ios OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
471471
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios_local.dylib && \
472-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=ios-sim OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
472+
rm -rf $(BUILD_DIR) $(LLAMA_BUILD) && MAKEFLAGS= $(MAKE) PLATFORM=ios-sim OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
473473
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios-sim_local.dylib && \
474-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=macos OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
474+
rm -rf $(BUILD_DIR) $(LLAMA_BUILD) && MAKEFLAGS= $(MAKE) PLATFORM=macos OMIT_REMOTE_ENGINE=1 $(XCFRAMEWORK_LLAMA) && \
475475
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/macos_local.dylib
476476
$(call create_xcframework,_local,memory-local)
477-
@# Build full variant (both)
478-
$(MAKE) -j1 distclean && $(MAKE) PLATFORM=ios $(XCFRAMEWORK_LLAMA) && \
477+
@# Build full variant (both) - need distclean between platforms to rebuild llama.cpp
478+
rm -rf $(DIST_DIR) && MAKEFLAGS= $(MAKE) distclean && MAKEFLAGS= $(MAKE) PLATFORM=ios $(XCFRAMEWORK_LLAMA) && \
479479
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios_full.dylib && \
480-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=ios-sim $(XCFRAMEWORK_LLAMA) && \
480+
rm -rf $(BUILD_DIR) $(LLAMA_BUILD) && MAKEFLAGS= $(MAKE) PLATFORM=ios-sim $(XCFRAMEWORK_LLAMA) && \
481481
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/ios-sim_full.dylib && \
482-
$(MAKE) -j1 clean && $(MAKE) PLATFORM=macos $(XCFRAMEWORK_LLAMA) && \
482+
rm -rf $(BUILD_DIR) $(LLAMA_BUILD) && MAKEFLAGS= $(MAKE) PLATFORM=macos $(XCFRAMEWORK_LLAMA) && \
483483
mv $(DIST_DIR)/memory.dylib $(DIST_DIR)/macos_full.dylib
484484
$(call create_xcframework,_full,memory-full)
485485

packages/android/build.gradle

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:8.5.2'
8+
}
9+
}
10+
11+
plugins {
12+
id 'com.gradleup.nmcp.aggregation' version '1.2.0'
13+
}
14+
15+
apply plugin: 'com.android.library'
16+
apply plugin: 'maven-publish'
17+
apply plugin: 'signing'
18+
19+
android {
20+
namespace 'ai.sqlite.memory'
21+
compileSdk 34
22+
23+
defaultConfig {
24+
minSdk 26
25+
targetSdk 34
26+
}
27+
28+
buildTypes {
29+
release {
30+
minifyEnabled false
31+
}
32+
}
33+
34+
compileOptions {
35+
sourceCompatibility JavaVersion.VERSION_1_8
36+
targetCompatibility JavaVersion.VERSION_1_8
37+
}
38+
39+
sourceSets {
40+
main {
41+
jniLibs.srcDirs = ['src/main/jniLibs']
42+
}
43+
}
44+
}
45+
46+
repositories {
47+
google()
48+
mavenCentral()
49+
maven { url 'https://jitpack.io' }
50+
}
51+
52+
dependencies {
53+
}
54+
55+
afterEvaluate {
56+
publishing {
57+
publications {
58+
release(MavenPublication) {
59+
groupId = 'ai.sqlite'
60+
artifactId = 'memory'
61+
version = project.hasProperty('VERSION') ? project.VERSION : ['make', 'version'].execute(null, file('../..')).text.trim()
62+
63+
artifact(project.hasProperty('AAR_PATH') ? project.AAR_PATH : "$buildDir/outputs/aar/android-release.aar")
64+
65+
// Maven Central metadata
66+
pom {
67+
name = 'sqlite-memory'
68+
description = 'A SQLite extension that gives AI agents persistent, searchable memory. Features hybrid semantic search (vector similarity + FTS5), markdown-aware chunking, and local embedding via llama.cpp. Memory databases can be synced between agents using offline first technology each agent works independently and syncs when connected, making it ideal for distributed AI systems, edge deployments, and collaborative agent architectures.'
69+
url = 'https://github.com/sqliteai/sqlite-memory'
70+
71+
licenses {
72+
license {
73+
name = 'Elastic License 2.0'
74+
url = 'https://www.elastic.co/licensing/elastic-license'
75+
}
76+
}
77+
78+
developers {
79+
developer {
80+
id = 'sqliteai'
81+
name = 'SQLite Cloud, Inc.'
82+
email = 'info@sqlitecloud.io'
83+
organization = 'SQLite Cloud, Inc.'
84+
organizationUrl = 'https://sqlite.ai'
85+
}
86+
}
87+
88+
scm {
89+
connection = 'scm:git:git://github.com/sqliteai/sqlite-memory.git'
90+
developerConnection = 'scm:git:ssh://github.com:sqliteai/sqlite-memory.git'
91+
url = 'https://github.com/sqliteai/sqlite-memory/tree/main'
92+
}
93+
}
94+
}
95+
}
96+
}
97+
98+
// Signing configuration for Maven Central
99+
signing {
100+
required { project.hasProperty("SIGNING_KEY") }
101+
if (project.hasProperty("SIGNING_KEY")) {
102+
useInMemoryPgpKeys(
103+
project.property("SIGNING_KEY").toString(),
104+
project.property("SIGNING_PASSWORD").toString()
105+
)
106+
sign publishing.publications.release
107+
}
108+
}
109+
}
110+
111+
// Maven Central publishing via NMCP aggregation
112+
nmcpAggregation {
113+
if (project.hasProperty("SONATYPE_USERNAME") && project.hasProperty("SONATYPE_PASSWORD")) {
114+
centralPortal {
115+
username = project.property("SONATYPE_USERNAME")
116+
password = project.property("SONATYPE_PASSWORD")
117+
publishingType = "AUTOMATIC"
118+
}
119+
publishAllProjectsProbablyBreakingProjectIsolation()
120+
}
121+
}

packages/android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2+
android.useAndroidX=true
44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)