Git Product home page Git Product logo

gradle-jextract's Introduction

This is a Gradle plugin for integrating Project Panama's jextract tool in the build process. There is also a full demo project showcasing the gradle-jextract plugin.

๐Ÿ’ก ย  Example

Since the plugin is available on Gradle's Plugin Portal it can be applied within the build script's plugins block.

plugins {
  id "io.github.krakowski.jextract" version "0.3.1"
}

Applying the plugin adds the jextract task which can be configured by the build script.

jextract {

    header("${project.projectDir}/src/main/c/stdio.h") {
        // The library name
        libraries = [ 'stdc++' ]
    
        // The package under which all source files will be generated
        targetPackage = 'org.unix'
        
        // The generated class name
        className = 'Linux'
    }
}

If the Gradle Java Plugin or Application plugin is applied, the gradle-jextract plugin configures them and uses the configured toolchain for its task, which can be set as follows.

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(19))
    }
}

If your JDK is not installed in one of the default locations, Gradle can be instructed to search in a custom location. To enable this feature the org.gradle.java.installations.paths property has to be set within your global gradle.properties file usually located inside ${HOME}/.gradle.

org.gradle.java.installations.paths=/custom/path/jdk19

The plugin will first try to find jextract inside PATH and then fall back to ${JAVA_HOME}/bin.

๐Ÿ“ ย  Configuration Options

The jextract task exposes the following configuration options.

Name Type Required Description
clangArguments java.lang.String Arguments which should be passed to clang
libraries java.lang.String[] The libraries against which the native code will link
includes java.lang.String[] A list of directories which should be included during code generation
targetPackage java.lang.String โšซ The package under which all bindings will be generated
className java.lang.String The generated class file's name
functions java.lang.String[] Whitelist of function symbols
macros java.lang.String[] Whitelist of macro symbols
structs java.lang.String[] Whitelist of struct symbols
typedefs java.lang.String[] Whitelist of typedef symbols
unions java.lang.String[] Whitelist of union symbols
variables java.lang.String[] Whitelist of global variable symbols
definedMacros java.lang.String[] List of additional defined C preprocessor macros
sourceMode java.lang.Boolean Generate source files instead of class files (default: true)
outputDir org.gradle.api.file.Directory The output directory under which the generated source files will be placed

๐Ÿ”ง ย  Requirements

๐Ÿ“œ ย  License

This project is licensed under the GNU GPLv3 License - see the LICENSE file for details.

gradle-jextract's People

Contributors

aecsocket avatar arc-blroth avatar bartvhelvert avatar elect86 avatar krakowski avatar rnett avatar

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.