Respect `output_ignorelist` for macro definitions
sloede opened this issue · 5 comments
When trying to generate bindings for the p4est headers, adding sc_MPI
to the output_ignorelist
setting in the generator.toml
has no effect: Macros of the type
#define sc_MPI_COMM_WORLD MPI_COMM_WORLD
are still translated to
const sc_MPI_COMM_WORLD = MPI_COMM_WORLD
It seems like macro printing ignores the output_ignorelist
, or am I missing something? If I am right, can this be easily fixed?
I can not reproduce this.
It should be handled here:
Clang.jl/src/generator/passes.jl
Line 957 in 9931c38
julia> using Clang.Generators
julia> args = get_default_args()
6-element Vector{String}:
"-isystem/Users/gnimuc/.julia/ar" ⋯ 61 bytes ⋯ "64-apple-darwin14/4.8.5/include"
"-isystem/Users/gnimuc/.julia/ar" ⋯ 67 bytes ⋯ "le-darwin14/4.8.5/include-fixed"
"-isystem/Users/gnimuc/.julia/ar" ⋯ 47 bytes ⋯ "9/x86_64-apple-darwin14/include"
"-isystem/Users/gnimuc/.julia/ar" ⋯ 60 bytes ⋯ "e-darwin14/sys-root/usr/include"
"-isystem/Users/gnimuc/.julia/ar" ⋯ 74 bytes ⋯ "-root/System/Library/Frameworks"
"--target=x86_64-apple-darwin14"
shell> cat test.h
#define sc_MPI_COMM_WORLD MPI_COMM_WORLD
typedef int cs_long_t;
typedef void * cs_dl;
cs_long_t cs_dl_fkeep (cs_dl *A, cs_long_t (*fkeep) (cs_long_t, cs_long_t, double, void *), void *other) ;
julia> ctx = create_context("./test.h", args, Dict("general"=>Dict{String,Any}("output_ignorelist"=>["sc_MPI_COMM_WORLD"])))
[ Info: Parsing headers...
Context(...)
julia> build!(ctx)
[ Info: Processing header: test.h
[ Info: Building the DAG...
┌ Warning: default libname: ":libxxx" is being used, did you forget to set `library_name` in the toml file?
└ @ Clang.Generators ~/.julia/dev/Clang/src/generator/audit.jl:16
[ Info: Emit Julia expressions...
const cs_long_t = Cint
const cs_dl = Ptr{Cvoid}
function cs_dl_fkeep(A, fkeep, other)
ccall((:cs_dl_fkeep, libxxx), cs_long_t, (Ptr{cs_dl}, Ptr{Cvoid}, Ptr{Cvoid}), A, fkeep, other)
end
[ Info: Done!
Context(...)
You are right. It was a user error: After editing export_symbol_prefixes
, I assumed (without checking) that output_ignorelist
also works with prefixes and thus added only sc_MPI_
. Once I add the complete symbol name sc_MPI_COMM_WORLD
, it is not printed as expected. Thus... 🤦🙈
Having said this: Is there a way to apply prefixes (or even patterns) in the output_ignorelist
?
In any case, thank you very much for the swift support!
Having said this: Is there a way to apply prefixes (or even patterns) in the
output_ignorelist
?
That's a good idea. Would you like to submit a PR? The related lines are
Clang.jl/src/generator/passes.jl
Lines 853 to 860 in 9931c38
Would you like to submit a PR?
I would, but alas, I do not have enough time at the moment to do this right. I could, however, create an issue for it to keep track of the idea, if that would be helpful as well.