Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
name: build

on:
workflow_dispatch:
pull_request:
branches:
- "**"
push:
branches:
- "**"
- main

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ macOS-latest ]
# os: [ macOS-latest, ubuntu-18.04 ] GitHub actions removed ubuntu-18.04
# os: [ macOS-latest, windows-latest, ubuntu-18.04 ]
os: [ macOS-latest, windows-latest, ubuntu-latest ]
runs-on: ${{matrix.os}}
steps:
- name: Checkout the repo
uses: actions/checkout@v4

- uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "17"

- name: Install msys2
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
Expand All @@ -29,7 +32,7 @@ jobs:
install: git mingw-w64-x86_64-toolchain libsqlite

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v4

- name: Cache gradle
uses: actions/cache@v4
Expand All @@ -54,6 +57,11 @@ jobs:
echo "c:\msys64\mingw64\bin" >> $GITHUB_PATH

- name: Build
if: matrix.os != 'macOS-latest'
run: ./gradlew build --no-daemon --stacktrace

- name: Build and Test
if: matrix.os == 'macOS-latest'
run: ./gradlew build allTests --no-daemon --stacktrace
env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
44 changes: 0 additions & 44 deletions .github/workflows/deploy.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
distribution: "adopt"
java-version: "17"
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v4
- name: Cache gradle
uses: actions/cache@v4
with:
Expand All @@ -39,8 +39,8 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-

- name: Finish Maven Central Release
run: ./gradlew closeAndReleaseRepository --no-daemon --stacktrace --no-build-cache
- name: Publish Artifacts to Maven Central
run: ./gradlew publish --no-daemon --stacktrace --no-build-cache
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ samples/**/*.kt.bc-build
samples/androidNativeActivity/Polyhedron

.vscode
.kotlin/
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin.code.style=official
GROUP=co.touchlab

VERSION_NAME=1.3.3
KOTLIN_VERSION=1.9.20
KOTLIN_VERSION=2.2.10

kotlin.native.ignoreDisabledTargets=true

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
111 changes: 34 additions & 77 deletions sqliter-driver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.konan.target.HostManager

plugins {
kotlin("multiplatform")
id("com.vanniktech.maven.publish") version "0.27.0"
id("com.vanniktech.maven.publish") version "0.34.0"
}

val GROUP: String by project
Expand All @@ -11,31 +11,13 @@ val VERSION_NAME: String by project
group = GROUP
version = VERSION_NAME

fun configInterop(target: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget) {
val main by target.compilations.getting
val sqlite3 by main.cinterops.creating {
includeDirs("$projectDir/src/include")
// extraOpts = listOf("-mode", "sourcecode")
}

target.compilations.forEach { kotlinNativeCompilation ->
kotlinNativeCompilation.kotlinOptions.freeCompilerArgs += when {
HostManager.hostIsLinux -> listOf(
"-linker-options",
"-lsqlite3 -L/usr/lib/x86_64-linux-gnu -L/usr/lib"
)

HostManager.hostIsMingw -> listOf("-linker-options", "-lsqlite3 -Lc:\\msys64\\mingw64\\lib")
else -> listOf("-linker-options", "-lsqlite3")
}
}
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}

kotlin {
applyDefaultHierarchyTemplate()

val knTargets = listOf(
macosX64(),
iosX64(),
Expand All @@ -55,75 +37,50 @@ kotlin {
linuxArm64(),
)

knTargets
.forEach { target ->
configInterop(target)
knTargets.forEach { target ->
target.compilations["main"].cinterops.create("sqlite3").apply {
includeDirs("$projectDir/src/include")
// extraOpts = listOf("-mode", "sourcecode")
}

target.compilerOptions {
freeCompilerArgs.addAll(
when {
HostManager.hostIsLinux -> listOf(
"-linker-options",
"-lsqlite3 -L/usr/lib/x86_64-linux-gnu -L/usr/lib"
)

HostManager.hostIsMingw -> listOf("-linker-options", "-lsqlite3 -Lc:\\msys64\\mingw64\\lib")
else -> listOf("-linker-options", "-lsqlite3")
}
)
}
}

sourceSets {
all {
languageSettings.apply {
languageSettings {
optIn("kotlin.experimental.ExperimentalNativeApi")
optIn("kotlinx.cinterop.ExperimentalForeignApi")
optIn("kotlinx.cinterop.BetaInteropApi")
}
}
commonMain {
dependencies {
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
}
}

val nativeCommonMain = sourceSets.maybeCreate("nativeCommonMain")
val nativeCommonTest = sourceSets.maybeCreate("nativeCommonTest")

val appleMain = sourceSets.maybeCreate("appleMain").apply {
dependsOn(nativeCommonMain)
}
val linuxMain = sourceSets.maybeCreate("linuxMain").apply {
dependsOn(nativeCommonMain)
}
val linuxX64Main = sourceSets.maybeCreate("linuxX64Main").apply {
dependsOn(linuxMain)
}
val linuxArm64Main = sourceSets.maybeCreate("linuxArm64Main").apply {
dependsOn(linuxMain)
}

val mingwMain = sourceSets.maybeCreate("mingwMain").apply {
dependsOn(nativeCommonMain)
}

val mingwX64Main = sourceSets.maybeCreate("mingwX64Main").apply {
dependsOn(mingwMain)
}

knTargets.forEach { target ->
when {
target.name.startsWith("mingw") -> {
target.compilations.getByName("main").defaultSourceSet.dependsOn(mingwMain)
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
}

target.name.startsWith("linux") -> {
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
}

else -> {
target.compilations.getByName("main").defaultSourceSet.dependsOn(appleMain)
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}

commonTest.dependencies {
implementation(kotlin("test"))
}
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile> {
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
mavenPublishing {
// Signing and POM are automatically handled by the plugin + gradle.properties
configureBasedOnAppliedPlugins(true, true)
publishToMavenCentral(automaticRelease = true)
}

listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package co.touchlab.sqliter.concurrency

import co.touchlab.sqliter.util.maybeFreeze
import kotlinx.cinterop.Arena
import kotlinx.cinterop.alloc
import kotlinx.cinterop.ptr
import platform.posix.*
import platform.posix.PTHREAD_MUTEX_RECURSIVE
import platform.posix.pthread_mutex_destroy
import platform.posix.pthread_mutex_init
import platform.posix.pthread_mutex_lock
import platform.posix.pthread_mutex_t
import platform.posix.pthread_mutex_trylock
import platform.posix.pthread_mutex_unlock
import platform.posix.pthread_mutexattr_destroy
import platform.posix.pthread_mutexattr_init
import platform.posix.pthread_mutexattr_settype
import platform.posix.pthread_mutexattr_t

/**
* A simple lock.
Expand All @@ -19,7 +28,6 @@ internal actual class Lock actual constructor() {
pthread_mutexattr_init(attr.ptr)
pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt())
pthread_mutex_init(mutex.ptr, attr.ptr)
maybeFreeze()
}

actual fun lock() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.touchlab.sqliter.concurrency

import co.touchlab.sqliter.util.maybeFreeze
import kotlinx.cinterop.Arena
import kotlinx.cinterop.alloc
import kotlinx.cinterop.ptr
Expand Down Expand Up @@ -29,7 +28,6 @@ internal actual class Lock actual constructor() {
pthread_mutexattr_init(attr.ptr)
pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt())
pthread_mutex_init(mutex.ptr, attr.ptr)
maybeFreeze()
}

actual fun lock() {
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading