import Ġde . under couch . gradle . tasks . download . Download Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . Kotlin Native Target Ċ import Ġorg . jetbrains . kotlin . kon an . target . Host Manager Ċ import Ġorg . jetbrains . kotlin . kon an . target . Kon an Target Ċ import Ġorg . jetbrains . kotlin . kon an . target . pre setName Ċ Ċ plugins Ġ{ Ċ ĉ kotlin (" multi platform ") Ċ ĉ id (" de . under couch . download ") Ċ ĉ ` maven - publish ` Ċ } Ċ Ċ val Ġsqlite Version Ġ= Ġ" 3 3 1 0 1 0 0 " Ċ val Ġuse Single Target : ĠBoolean Ġby Ġroot Project . extra Ċ Ċ val Ġsqlite Src Folder Ġ= Ġbuild Dir . resolve (" sqlite _ src / sqlite - amal gam ation -$ sqlite Version ") Ċ Ċ val Ġdownload SQLite Sources Ġby Ġtasks . register ing ( Download :: class ) Ġ{ Ċ ĉ src (" https :// www . sqlite . org / 2 0 2 0 / sqlite - amal gam ation -$ sqlite Version . zip ") Ċ ĉ dest ( build Dir . resolve (" sqlite _ src / sqlite - amal gam ation -$ sqlite Version . zip ")) Ċ ĉ overwrite ( false ) Ċ } Ċ val Ġunzip SQLite Sources Ġby Ġtasks . register ing ( Copy :: class ) Ġ{ Ċ ĉ depends On ( download SQLite Sources ) ĊĊ ĉ from ( zip Tree ( download SQLite Sources . get (). dest )) Ċ ĉ into ( build Dir . resolve (" sqlite _ src ")) Ċ } Ċ Ċ val Ġkon an User Dir Ġ= Ġfile ( System . getenv (" K ON AN _ DATA _ DIR ") Ġ?: Ġ"${ System . getProperty (" user . home ") }/. kon an ") Ċ val Ġkon an Deps Ġ= Ġkon an User Dir . resolve (" dependencies ") Ċ val Ġtool Chain Folder Name Ġ= Ġwhen Ġ{ Ċ ĉ Host Manager . host Is Linux Ġ-> Ġ" clang - llvm - 8 . 0 . 0 - linux - x 8 6 - 6 4 " Ċ ĉ Host Manager . host Is Mac Ġ-> Ġ" clang - llvm - apple - 8 . 0 . 0 - darwin - macos " Ċ ĉ Host Manager . host Is M ing w Ġ-> Ġ" msys 2 - mingw - w 6 4 - x 8 6 _ 6 4 - clang - llvm - lld - compiler _ rt - 8 . 0 . 1 " Ċ ĉ else Ġ-> Ġerror (" Unknown Ġhost ĠOS ") Ċ } Ċ val Ġllvm Bin Folder Ġ= Ġkon an Deps . resolve ("${ tool Chain Folder Name }/ bin ") Ċ Ċ val Ġandroid Sys Root Parent Ġ= Ġkon an Deps . resolve (" target - sys root - 1 - android _ nd k "). resolve (" android - 2 1 ") Ċ Ċ data Ġclass ĠTarget Info ( val Ġtarget Name : ĠString , Ġval Ġsys Root : ĠFile , Ġval Ġclang Args : ĠList < String > Ġ= Ġempty List ()) Ċ val Ġtarget Info Map Ġ= Ġmap Of ( Ċĉ ĉ Kon an Target . LINUX _ X 6 4 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " x 8 6 _ 6 4 - unknown - linux - gnu ", Ċĉĉĉ ĉ kon an Deps . resolve (" target - gcc - toolchain - 3 - linux - x 8 6 - 6 4 / x 8 6 _ 6 4 - unknown - linux - gnu / sys root ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . MAC OS _ X 6 4 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " x 8 6 _ 6 4 - apple - darwin 1 0 ", Ġ// ĠNot Ġsure Ġabout Ġthis Ġbut Ġit Ġdoesn 't Ġmatter Ġyet . Ċĉĉĉ ĉ kon an Deps . resolve (" target - sys root - 1 0 - macos _ x 6 4 ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . M ING W _ X 6 4 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " x 8 6 _ 6 4 - w 6 4 - mingw 3 2 ", Ċĉĉĉ ĉ kon an Deps . resolve (" msys 2 - mingw - w 6 4 - x 8 6 _ 6 4 - clang - llvm - lld - compiler _ rt - 8 . 0 . 1 ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . M ING W _ X 8 6 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " i 6 8 6 - w 6 4 - mingw 3 2 ", Ċĉĉĉ ĉ kon an Deps . resolve (" msys 2 - mingw - w 6 4 - i 6 8 6 - clang - llvm - lld - compiler _ rt - 8 . 0 . 1 ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . LINUX _ ARM 3 2 _ H FP Ġto ĠTarget Info ( Ċĉĉĉ ĉ " arm v 6 - unknown - linux - gn ue ab ih f ", Ċĉĉĉ ĉ kon an Deps . resolve (" target - sys root - 2 - raspberry pi "), Ċĉĉĉ ĉ listOf ("- mf pu = v fp ", Ġ"- m float - abi = hard ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . ANDROID _ ARM 3 2 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " arm - linux - andro ide abi ", Ċĉĉĉ ĉ android Sys Root Parent . resolve (" arch - arm ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . ANDROID _ ARM 6 4 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " aarch 6 4 - linux - android ", Ċĉĉĉ ĉ android Sys Root Parent . resolve (" arch - arm 6 4 ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . ANDROID _ X 8 6 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " i 6 8 6 - linux - android ", Ċĉĉĉ ĉ android Sys Root Parent . resolve (" arch - x 8 6 ") Ċĉ ĉ ), Ċĉ ĉ Kon an Target . ANDROID _ X 6 4 Ġto ĠTarget Info ( Ċĉĉĉ ĉ " x 8 6 _ 6 4 - linux - android ", Ċĉĉĉ ĉ android Sys Root Parent . resolve (" arch - x 6 4 ") Ċĉ ĉ ) Ċ ) Ċ Ċ kotlin Ġ{ Ċ ĉ if Ġ( Host Manager . host Is M ing w Ġ|| Ġ! use Single Target ) Ġm ing w X 6 4 () Ċ ĉ if Ġ( Host Manager . host Is Linux Ġ|| Ġ! use Single Target ) Ġlinux X 6 4 () Ċ ĉ if Ġ( Host Manager . host Is Mac Ġ|| Ġ! use Single Target ) Ġmac os X 6 4 () Ċ ĉ if Ġ(! use Single Target ) Ġ{ Ċĉ ĉ mingw X 8 6 () Ċĉ ĉ linux Arm 3 2 H fp () Ċ ĉ } ĊĊ ĉ targets . with Type < Kotlin Native Target > Ġ{ Ċĉ ĉ val Ġtarget Dir Ġ= Ġsqlite Src Folder . resolve ( kon an Target . pre setName ) ĊĊĉ ĉ val Ġsource File Ġ= Ġsqlite Src Folder . resolve (" sqlite 3 . c ") Ċĉ ĉ val Ġobj File Ġ= Ġtarget Dir . resolve (" sqlite 3 . o ") Ċĉ ĉ val Ġstatic Lib File Ġ= Ġtarget Dir . resolve (" lib sqlite 3 . a ") ĊĊĉ ĉ val Ġcompile SQLite Ġ= Ġtasks . register < Exec >(" compile SQLite ${ kon an Target . pre setName . capitalize () }") Ġ{ Ċĉĉ ĉ only If Ġ{ ĠHost Manager (). isEnabled ( kon an Target ) Ġ} ĊĊĉĉ ĉ depends On ( unzip SQLite Sources ) Ċĉĉ ĉ environment (" PATH ", Ġ"$ llvm Bin Folder ;${ System . getenv (" PATH ") }") Ċĉĉ ĉ if Ġ( Host Manager . host Is Mac Ġ&& Ġkon an Target Ġ== ĠKon an Target . MAC OS _ X 6 4 ) Ġ{ Ċĉĉĉ ĉ environment (" CP ATH ", Ġ"/ Applications / Xcode . app / Contents / Developer / Platforms / Mac OSX . platform / Developer / SDK s / Mac OSX . sdk / usr / include ") Ċĉĉ ĉ } ĊĊĉĉ ĉ inputs . file ( source File ) Ċĉĉ ĉ outputs . file ( obj File ) ĊĊĉĉ ĉ executable ( llvm Bin Folder . resolve (" clang "). absolute Path ) Ċĉĉ ĉ args ("- c ", Ġ"- Wall ") ĊĊĉĉ ĉ val Ġtarget Info Ġ= Ġtarget Info Map . getValue ( kon an Target ) ĊĊĉĉ ĉ args ("-- target =${ target Info . target Name }", Ġ"-- sys root =${ target Info . sys Root }") Ċĉĉ ĉ args ( target Info . clang Args ) Ċĉĉ ĉ args ( Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ FT S 3 ", Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ FT S 5 ", Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ RT REE ", Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ DB STAT _ VT AB ", Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ JSON 1 ", Ċĉĉĉĉ ĉ "- D SQL ITE _ ENABLE _ R BU " Ċĉĉ ĉ ) Ċĉĉ ĉ args ( Ċĉĉĉĉ ĉ "- I ${ sqlite Src Folder . absolute Path }", Ċĉĉĉĉ ĉ "- o ", Ġobj File . absolute Path , Ċĉĉĉĉ ĉ source File . absolute Path Ċĉĉ ĉ ) Ċĉ ĉ } Ċĉ ĉ val Ġarchive SQLite Ġ= Ġtasks . register < Exec >(" archive SQLite ${ kon an Target . pre setName . capitalize () }") Ġ{ Ċĉĉ ĉ only If Ġ{ ĠHost Manager (). isEnabled ( kon an Target ) Ġ} Ċĉĉ ĉ depends On ( compile SQLite ) ĊĊĉĉ ĉ inputs . file ( obj File ) Ċĉĉ ĉ outputs . file ( static Lib File ) ĊĊĉĉ ĉ executable ( llvm Bin Folder . resolve (" llvm - ar "). absolute Path ) Ċĉĉ ĉ args ( Ċĉĉĉĉ ĉ " rc ", Ġstatic Lib File . absolute Path , Ċĉĉĉĉ ĉ obj File . absolute Path Ċĉĉ ĉ ) Ċĉĉ ĉ environment (" PATH ", Ġ"$ llvm Bin Folder ;${ System . getenv (" PATH ") }") Ċĉ ĉ } ĊĊĉ ĉ comp il ations Ġ{ Ċĉĉ ĉ " main " Ġ{ Ċĉĉĉ ĉ default Source Set Ġ{ Ċĉĉĉĉ ĉ kotlin . src Dir (" src / native Main / kotlin ") Ċĉĉĉ ĉ } Ċĉĉĉ ĉ c inter ops . create (" sqlite 3 ") Ġ{ Ċĉĉĉĉ ĉ include Dirs ( sqlite Src Folder ) Ċĉĉĉĉ ĉ val Ġc Interop Task Ġ= Ġtasks [ interop Processing Task Name ] Ċĉĉĉĉ ĉ c Interop Task . depends On ( unzip SQLite Sources ) Ċĉĉĉĉ ĉ compile SQLite . configure Ġ{ Ċĉĉĉĉĉ ĉ depends On ( c Interop Task ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ kotlin Options Ġ{ Ċĉĉĉĉ ĉ compile Kotlin Task . depends On ( archive SQLite ) Ċĉĉĉĉ ĉ free Compiler Args Ġ= ĠlistOf ("- include - binary ", Ġstatic Lib File . absolute Path ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ " test " Ġ{ Ċĉĉĉ ĉ default Source Set Ġ{ Ċĉĉĉĉ ĉ kotlin . src Dir (" src / native Test / kotlin ") Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ } Ċ