xref: /libCEED/julia/LibCEED.jl/gen/generator.jl (revision 5cd6c1fb67d52eb6a42b887bb79c183682dd86ca)
1using Clang.Generators
2
3function generate_ceed_bindings(ceed_path)
4    # libCEED include dir and header files
5    include_dir = joinpath(ceed_path, "include") |> normpath
6    header_files = ["ceed.h", "ceed/cuda.h", "ceed/backend.h"]
7    headers = [joinpath(include_dir, header) for header in header_files]
8
9    # load options from generator TOML file
10    options = load_options(joinpath(@__DIR__, "generator.toml"))
11
12    # add compiler flags
13    args = get_default_args()
14    push!(args, "-I$include_dir")
15
16    # create context
17    ctx = create_context(headers, args, options)
18
19    # run generator
20    build!(ctx)
21
22    # remove trailing newline from output file
23    outfile = options["general"]["output_file_path"]
24    write(outfile, readchomp(outfile))
25    return
26end
27