Git Product home page Git Product logo

clang.jl's Introduction

Clang

CI TagBot codecov docs-stable docs-dev GitHub Discussions

This package provides a Julia language wrapper for libclang: the stable, C-exported interface to the LLVM Clang compiler. The libclang API documentation provides background on the functionality available through libclang, and thus through the Julia wrapper. The repository also hosts related tools built on top of libclang functionality.

Installation

pkg> add Clang

If you'd like to use the old generator(Clang.jl v0.13), please checkout this branch for the documentation. Should you have any questions on how to upgrade the generator script, feel free to submit a post/request in the Discussions area.

Binding Generator

Clang.jl provides a module Clang.Generators for auto-generating C library bindings for Julia language from C headers.

Quick start

Write a config file generator.toml:

[general]
library_name = "libclang"
output_file_path = "./LibClang.jl"
module_name = "LibClang"
jll_pkg_name = "Clang_jll"
export_symbol_prefixes = ["CX", "clang_"]

and a Julia script generator.jl:

using Clang.Generators
using Clang.LibClang.Clang_jll  # replace this with your jll package

cd(@__DIR__)

include_dir = normpath(Clang_jll.artifact_dir, "include")
clang_dir = joinpath(include_dir, "clang-c")

options = load_options(joinpath(@__DIR__, "generator.toml"))

# add compiler flags, e.g. "-DXXXXXXXXX"
args = get_default_args()  # Note you must call this function firstly and then append your own flags
push!(args, "-I$include_dir")

headers = [joinpath(clang_dir, header) for header in readdir(clang_dir) if endswith(header, ".h")]
# there is also an experimental `detect_headers` function for auto-detecting top-level headers in the directory
# headers = detect_headers(clang_dir, args)

# create context
ctx = create_context(headers, args, options)

# run generator
build!(ctx)

Please refer to this toml file for a full list of configuration options.

Examples

The binding generator is currently used by many projects in the Julia package ecosystem and you can take them as good examples.

Other Users:

clang.jl's People

Contributors

gnimuc avatar ihnorton avatar melonedo avatar jameswrigley avatar kmsquire avatar timholy avatar yuyichao avatar visr avatar serenity4 avatar nolta avatar vtjnash avatar jpata avatar vchuravy avatar t-bltg avatar viralbshah avatar github-actions[bot] avatar stemann avatar jiahao avatar jgoldfar avatar amitmurthy avatar octogonapus avatar dependabot[bot] avatar habemus-papadum avatar simondanisch avatar nicoleepp avatar samuelpowell avatar terasakisatoshi avatar simonster avatar cousinitt avatar tkelman 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.