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