forked from unum-cloud/usearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
207 lines (178 loc) · 5.68 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import org.gradle.internal.jvm.Jvm
plugins {
id 'java-library'
id 'cpp'
id 'maven-publish'
id 'signing'
}
group "cloud.unum"
version = file("VERSION").text.trim()
java {
sourceCompatibility = JavaVersion.VERSION_18
targetCompatibility = JavaVersion.VERSION_18
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir "java/"
exclude "test/"
}
// Ensure native libraries are included in the main source set
resources {
srcDirs "$buildDir/libs"
include "usearch/**"
}
}
test {
java {
srcDir "java/test"
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
dependencies {
testImplementation('junit:junit:4.13.2')
}
model {
components {
usearch(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "java/cloud/unum/usearch"
include "**/*.cpp"
}
exportedHeaders {
srcDirs "include", "fp16/include", "simsimd/include", "${Jvm.current().javaHome}/include"
}
}
}
binaries.withType(StaticLibraryBinarySpec) {
buildable = false
}
binaries.withType(SharedLibraryBinarySpec) {
if (targetPlatform.operatingSystem.linux) {
cppCompiler.args '-I', "${Jvm.current().javaHome}/include/linux"
cppCompiler.args '-D_FILE_OFFSET_BITS=64'
cppCompiler.args '-std=c++11'
} else if (targetPlatform.operatingSystem.macOsX) {
cppCompiler.args '-I', "${Jvm.current().javaHome}/include/darwin"
cppCompiler.args '-D_FILE_OFFSET_BITS=64'
cppCompiler.args '-std=c++11'
} else if (targetPlatform.operatingSystem.windows){
cppCompiler.args "-I${Jvm.current().javaHome}/include/win32"
cppCompiler.args '/std:c++11'
}
}
}
}
toolChains {
clang(Clang)
gcc(Gcc) {
target("linux_aarch64") {
cppCompiler.withArguments { args ->
args << "-march=armv8-a"
}
}
}
}
}
test {
forkEvery 1
dependsOn jar
// Rearrange test classpath, add compiled JAR instead of main classes
classpath = project.sourceSets.test.output + configurations.testRuntimeClasspath + files(jar.archiveFile)
// Enable detailed test logging
testLogging {
// Ensure that we get output from all tests, not just failing ones
showStandardStreams = true
exceptionFormat = 'full' // Can be 'short', 'full', or 'summary'
// More detailed test result logging
events "passed", "skipped", "failed"
}
}
jar {
dependsOn("usearchSharedLibrary")
from("$buildDir/libs/usearch/shared") {
include "libusearch.so", "libusearch.dylib", "libusearch.dll"
into "usearch"
}
from sourceSets.main.output
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
publishing {
publications {
library(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
signing {
sign publishing.publications.library
}
pom {
name = "USearch"
description = "Smaller & Faster Single-File Vector Search Engine from Unum"
url = "https://github.com/unum-cloud/usearch"
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:git://github.com/unum-cloud/usearch.git'
developerConnection = 'scm:git:ssh://github.com/unum-cloud/usearch.git'
url = 'https://github.com/unum-cloud/usearch'
}
developers {
developer {
id = 'ashvardanian'
name = 'Ash Vardanian'
email = '[email protected]'
}
}
}
}
}
// Publishing to GitHub is much easier ;)
repositories {
maven {
name = "OSSRH"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/unum-cloud/usearch"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
// Ensure that the native library is built before the Java code
compileJava.dependsOn tasks.withType(SharedLibraryBinarySpec)
tasks.named("processResources").configure {
dependsOn tasks.named("linkUsearchSharedLibrary")
}