From 0d8492dd900ed534220c5bf0c770b383dd89af6a Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:02:36 -0400 Subject: [PATCH] Save dependent headers for faster iteration --- res/wrap/.gitignore | 1 + res/wrap/Project.toml | 1 + res/wrap/wrap.jl | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 res/wrap/.gitignore diff --git a/res/wrap/.gitignore b/res/wrap/.gitignore new file mode 100644 index 00000000..d33fed70 --- /dev/null +++ b/res/wrap/.gitignore @@ -0,0 +1 @@ +*.JLD2 diff --git a/res/wrap/Project.toml b/res/wrap/Project.toml index 89a6ad7e..2daf101b 100644 --- a/res/wrap/Project.toml +++ b/res/wrap/Project.toml @@ -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" diff --git a/res/wrap/wrap.jl b/res/wrap/wrap.jl index e31788db..9e783a3c 100644 --- a/res/wrap/wrap.jl +++ b/res/wrap/wrap.jl @@ -6,6 +6,7 @@ using Clang.Generators using Clang.Generators: LinkEnumAlias using Clang using Glob +using JLD2 using JuliaFormatter using Logging @@ -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