From 2837395dc4e39f31d7c25fc1d80d67763f02829e Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:42:21 -0400 Subject: [PATCH] Cleanup --- res/wrap/libmps.toml | 1 - res/wrap/libmtl.toml | 1 - res/wrap/wrap.jl | 118 +++++++++---------------------------------- 3 files changed, 24 insertions(+), 96 deletions(-) diff --git a/res/wrap/libmps.toml b/res/wrap/libmps.toml index 4a753c78..92ff458a 100644 --- a/res/wrap/libmps.toml +++ b/res/wrap/libmps.toml @@ -2,7 +2,6 @@ library_name = "libmps" output_file_path = "../../lib/mps/libmps.jl" prologue_file_path = "libmps_prologue.jl" -#no_audit = true printer_blacklist = [ "mt_macCatalyst", diff --git a/res/wrap/libmtl.toml b/res/wrap/libmtl.toml index 7dc03763..db53adb5 100644 --- a/res/wrap/libmtl.toml +++ b/res/wrap/libmtl.toml @@ -1,7 +1,6 @@ [general] library_name = "libmtl" output_file_path = "../../lib/mtl/libmtl.jl" -no_audit = true generate_isystem_symbols = false diff --git a/res/wrap/wrap.jl b/res/wrap/wrap.jl index 9e783a3c..e86588bd 100644 --- a/res/wrap/wrap.jl +++ b/res/wrap/wrap.jl @@ -25,48 +25,38 @@ function main(names=["all"]; sdk_path=SDK_PATH) ctxs = [] - if "all" in names - names = ["all"] + if "all" in names || "libmtl" in names || "mtl" in names + fwpath = path_to_framework("Metal") + tctx = wrap("libmtl", joinpath(fwpath, "Metal.h"); defines) + push!(ctxs, tctx) end - for name in names - if name == "all" || name == "libmtl" || name == "mtl" - fwpath = path_to_framework("Metal") - tctx = wrap("libmtl", joinpath(fwpath, "Metal.h"); targets=glob("*.h", fwpath), defines, - include_dirs=[fwpath]) - push!(ctxs, tctx) - end - - if name == "all" || name == "libmps" || name == "mps" - mpsframeworks = ["MPSCore", "MPSImage", "MPSMatrix", "MPSNDArray", "MPSNeuralNetwork", "MPSRayIntersector"] - fwpaths = [path_to_framework("MetalPerformanceShaders")] - fwpaths = append!(fwpaths, path_to_mps_framework.(mpsframeworks)) + if "all" in names || "libmps" in names || "mps" in names + mpsframeworks = ["MPSCore", "MPSImage", "MPSMatrix", "MPSNDArray", "MPSNeuralNetwork", "MPSRayIntersector"] + fwpaths = [path_to_framework("MetalPerformanceShaders")] + fwpaths = append!(fwpaths, path_to_mps_framework.(mpsframeworks)) - getheaderfname(path) = Sys.splitext(Sys.splitpath(path)[end-1])[1] * ".h" - headers = joinpath.(fwpaths, getheaderfname.(fwpaths)) - - tctx = wrap("libmps", headers; defines, - include_dirs=fwpaths) - push!(ctxs, tctx) - end + getheaderfname(path) = Sys.splitext(Sys.splitpath(path)[end-1])[1] * ".h" + headers = joinpath.(fwpaths, getheaderfname.(fwpaths)) - # if name == "all" || name == "libfoundation" || name == "foundation" - # fwpath = path_to_framework("Foundation") - # tctx = wrap("libfoundation", joinpath(foundation, "Foundation.h"); targets=glob("*.h", fwpath), defines=["__builtin_va_list"], - # include_dirs=[fwpath]) - # push!(ctxs, tctx) - # end - # if name == "all" || name == "libcf" || name == "cf" - # fwpath = path_to_framework("CoreFoundation") - # tctx = wrap("libfoundation", joinpath(fwpath, "CoreFoundation.h"); targets=glob("*.h", fwpath), defines=["__builtin_va_list"], - # include_dirs=[fwpath]) - # push!(ctxs, tctx) - # end + tctx = wrap("libmps", headers; defines) + push!(ctxs, tctx) end + + # if "all" in names || "libfoundation" in names || "foundation" in names + # fwpath = path_to_framework("Foundation") + # tctx = wrap("libfoundation", joinpath(foundation, "Foundation.h");, defines=["__builtin_va_list"]) + # push!(ctxs, tctx) + # end + # if "all" in names || "libcf" in names || "cf" in names + # fwpath = path_to_framework("CoreFoundation") + # tctx = wrap("libfoundation", joinpath(fwpath, "CoreFoundation.h");, defines=["__builtin_va_list"]) + # push!(ctxs, tctx) + # end return ctxs end -function wrap(name, headers; targets=headers, defines=[], include_dirs=[], precomp_header=nothing) +function wrap(name, headers; defines=[]) @info "Wrapping $name" options = load_options(joinpath(@__DIR__, "$(name).toml")) @@ -158,66 +148,6 @@ function create_objc_context(headers::Vector, args::Vector=String[], options::Di parse_headers!(ctx, headers, args) Generators.add_default_passes!(ctx, options, system_dirs, dependent_headers) - - # push!(ctx.passes, CollectTopLevelNode(ctx.trans_units, dependent_headers, system_dirs)) - # push!(ctx.passes, LinkTypedefToAnonymousTagType()) - # push!(ctx.passes, LinkTypedefToAnonymousTagType(is_system=true)) - # push!(ctx.passes, IndexDefinition()) - # push!(ctx.passes, CollectDependentSystemNode()) - # push!(ctx.passes, IndexDefinition()) - # push!(ctx.passes, CollectNestedRecord()) - # push!(ctx.passes, FindOpaques()) - # push!(ctx.passes, ResolveDependency(info=false)) - # push!(ctx.passes, RemoveCircularReference()) - # push!(ctx.passes, TopologicalSort()) - # push!(ctx.passes, IndexDefinition()) - # push!(ctx.passes, ResolveDependency()) - # push!(ctx.passes, CatchDuplicatedAnonymousTags()) - # push!(ctx.passes, CodegenPreprocessing()) - - # general_options = get(options, "general", Dict()) - # if get(general_options, "smart_de_anonymize", true) - # push!(ctx.passes, DeAnonymize()) - # end - # if get(general_options, "no_audit", false) - # @error "The generator is running in `no_audit` mode. It could generate invalid Julia code. You can remove the `no_audit` entry in the `.toml` file to exit this mode." - # get(general_options, "link_enum_alias", true) && push!(ctx.passes, LinkEnumAlias()) - # else - # push!(ctx.passes, Audit()) - # end - # push!(ctx.passes, Codegen()) - # push!(ctx.passes, CodegenMacro()) - - # if get(general_options, "add_fptr_methods", false) - # push!(ctx.passes, AddFPtrMethods()) - # end - # if get(general_options, "auto_mutability", false) - # push!(ctx.passes, TweakMutability()) - # end - - # # support old behavior - # api_file = get(general_options, "output_api_file_path", "") - # common_file = get(general_options, "output_common_file_path", "") - - # output_file_path = get(general_options, "output_file_path", "") - - # if isempty(api_file) && isempty(common_file) - # if !isempty(output_file_path) - # push!(ctx.passes, ProloguePrinter(output_file_path)) - # push!(ctx.passes, GeneralPrinter(output_file_path)) - # push!(ctx.passes, EpiloguePrinter(output_file_path)) - # else - # # print to stdout if there is no `output_file_path` - # # this is handy when playing in REPL - # push!(ctx.passes, StdPrinter()) - # end - # else - # # let the user handle prologue and epilogue on their own - # push!(ctx.passes, FunctionPrinter(api_file)) - # push!(ctx.passes, CommonPrinter(common_file)) - # end - - # return ctx end function rewriter!(ctx, options)