Skip to content

Commit

Permalink
Save dependent headers for faster iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Dec 12, 2024
1 parent 62deea7 commit 0d8492d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions res/wrap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.JLD2
1 change: 1 addition & 0 deletions res/wrap/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
Clang_jll = "0ee61d77-7f21-5576-8119-9fcc46b10100"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Expand Down
11 changes: 10 additions & 1 deletion res/wrap/wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Clang.Generators
using Clang.Generators: LinkEnumAlias
using Clang
using Glob
using JLD2
using JuliaFormatter
using Logging

Expand Down Expand Up @@ -131,14 +132,22 @@ function create_objc_context(headers::Vector, args::Vector=String[], options::Di
# Since the framework we're wrapping is a system header,
# find all dependent headers, then remove all but the relevant ones
# also temporarily disable logging
dep_headers_fname = if haskey(options, "general") && haskey(options["general"], "library_name")
options["general"]["library_name"]*".JLD2"
else
nothing
end
Base.CoreLogging._min_enabled_level[] = Logging.Info+1
dependent_headers = let
dependent_headers = if !isnothing(dep_headers_fname) && isfile(dep_headers_fname)
JLD2.load(dep_headers_fname, "dep_headers")
else
all_headers = find_dependent_headers(headers,args,[])
dep_headers = Vector{eltype(all_headers)}(undef, 0)
for header in headers
target_framework = "/"*joinpath(Sys.splitpath(header)[end-2:end-1])
dep_headers = append!(dep_headers, filter(s -> occursin(target_framework, s), all_headers))
end
JLD2.@save dep_headers_fname dep_headers
dep_headers
end
Base.CoreLogging._min_enabled_level[] = Logging.Debug
Expand Down

0 comments on commit 0d8492d

Please sign in to comment.