Skip to content

Repository files navigation

datkt.uv

libuv bindings for Kotlin/Native.

Installation

The uv package an be installed with various package managers.

From NPM

$ npm install @datkt/uv

Note:This will install uv into node_modules/@datkt/uv

Install From Source

$ git clone git@github.com:datkt/uv.git
$ cd uv
$ make build # or make klib
$ make install

Prerequisites

Usage

## Compile a program in 'main.kt' and link uv.klib found in node_modules
$ konanc -l "$(find node_modules -name uv.klib)" main.kt

where main.kt might be

importdatkt.uv.*// entire libuv APIimportkotlinx.cinterop.*// exposes types needed for interopfunmain(args:Array<String>) {
if (0!= uv_init()) {
throwError("Failed to initialize libuv")
}
}

Example

importkotlinx.cinterop.*importdatkt.uv.uv_initimportdatkt.uv.randombytes_bufimportdatkt.uv.randombytes_randomimportdatkt.uv.randombytes_uniformfunmain(args:Array<String>) {
val rc = uv_init()
if (0!= rc) {
throwError("uv_init() != 0")
}
}

libuv API

This package binds libuvs entire API and provides an interop API for Kotlin and can be imported from the uv package.

Building

The uv package can be built from source into various targets.

Kotlin Library

uv.klib, a Kotlin library that can be linked with konanc can be built from source.

$ make klib

which will produce build/lib/uv.klib. The library can be installed with klib by running make install

Static Library

libuv.a, a static library that can be linked with konanc can be built from source.

$ make static

which will produce build/lib/libuv.a and C header files in build/include. The library can be installed into your system by running make install. The path prefix can be set by defining the PREFIX environment or make variable. It defaults to PREFIX=/usr/local

See Also

License

MIT

Releases

Packages

Contributors

Languages