Giter Site home page Giter Site logo

libsodiumjni's Introduction

libsodiumjni

Minimal JNI bindings for libsodium

This project provides JNI bindings for some libsodium methods.

It's used by Scala CLI to encode repository secrets about to be uploaded to GitHub via the GitHub API. For now, it only exposes libsodium methods that Scala CLI needs.

The motivation for writing libsodiumjni, rather than using any of the existing JNA-based bindings, is mainly using JNI rather than JNA to interface with libsodium, as JNI is supported from GraalVM native images, while JNA is not.

Build

libsodiumjni is built with Mill.

Compile everything with

$ ./mill __.compile

The Mill build automatically compile the C bindings, and generates a .so / .dylib / .dll. These files are also built on the CI, and pushed to Maven Central (see below).

Artifacts

libsodiumjni is pushed to Maven Central. Add it in a Mill module with

def ivyDeps = super.ivyDeps() ++ Seq(
  ivy"io.github.alexarchambault.tmp.libsodiumjni:libsodiumjni:0.0.2"
)

Both static and dynamic libraries are also pushed as is to Maven Central (see the .so / .dylib / .dll and .a / .lib files here for example). From the command line, you can fetch those files with commands such as

$ cs fetch --intransitive io.github.alexarchambault.tmp.libsodiumjni:libsodiumjni:0.0.2,classifier=x86_64-pc-win32,ext=dll,type=dll -A dll

Adding support for new libsodium new methods

Typical workflow:

  • add a native method in SodiumApi.java
  • run ./mill __.compile, this should add a corresponding declaration in libsodiumjni_internal_SodiumApi.h
  • add an implementation for that declaration in libsodiumjni_internal_SodiumApi.c in the same directory
  • run ./mill __.compile to ensure that the new C code compiles fine
  • use the newly added native method in Sodium.java say
  • optionally, add tests for it in SodiumTests.java
  • ensure those tests pass when running ./mill __.test

libsodiumjni's People

Contributors

alexarchambault avatar lwronski avatar maciejg604 avatar gedochao avatar

Watchers

 avatar  avatar  avatar

Forkers

maciejg604

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.