Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Clang.jl new generator API #8

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions res/prologue.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(joinpath(@__DIR__, "..", "deps", "deps.jl"))

const pid_t = Cint
28 changes: 9 additions & 19 deletions res/wrap.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Clang
using Clang.Generators

if length(ARGS) != 1
error("Pass the path to the Flux headers as the first argument")
Expand All @@ -8,25 +8,15 @@ header_dir = ARGS[1]
isdir(header_dir) || error("$header_dir does not exist")

const FLUX_INCLUDE = normpath(header_dir)
const FLUX_DIR = joinpath(FLUX_INCLUDE, "flux")
const FLUX_HEADERS = [joinpath(FLUX_DIR, header) for header in ["core.h"]]

headers = ["flux/core.h"]
FLUX_HEADERS = map(h->joinpath(FLUX_INCLUDE,h), headers)
args = ["-I$FLUX_INCLUDE"]

# To inlude all of the headers included by `core.h`
function wrapped(root, current)
if dirname(current) == joinpath(FLUX_INCLUDE, "flux", "core")
return true
end
return root == current
end
options = load_options(joinpath(@__DIR__, "wrap.toml"))

@add_def pid_t

wc = init(; headers = FLUX_HEADERS,
output_file = "libflux_h.jl",
common_file = "libflux_common.jl",
clang_includes = [FLUX_INCLUDE, CLANG_INCLUDE],
clang_args = ["-I", FLUX_INCLUDE],
header_wrapped = wrapped,
header_library = x->"libflux_core",
)
ctx = create_context(FLUX_HEADERS, args, options)

run(wc)
build!(ctx)
8 changes: 8 additions & 0 deletions res/wrap.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[general]
library_name = "libflux_core"
output_file_path = "../src/api.jl"
module_name = "API"
prologue_file_path = "./prologue.jl"

[codegen.macro]
macro_mode = "basic"
Loading