Skip to content

Commit

Permalink
Merge pull request #100 from JuliaIO/vs/clang
Browse files Browse the repository at this point in the history
Auto-generated wrappers with Clang.jl
  • Loading branch information
ViralBShah authored Aug 13, 2023
2 parents 14d552f + d34ba62 commit 7ad7eba
Show file tree
Hide file tree
Showing 21 changed files with 9,065 additions and 177 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "GZip"
uuid = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
authors = ["staticfloat@gmail.com <staticfloat@gmail.com>"]
version = "0.5.2"
version = "0.6.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a"

[compat]
julia = "1"
julia = "1.9"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Expand Down
6 changes: 6 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a"

[compat]
Clang = "0.17"
28 changes: 28 additions & 0 deletions gen/generator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Clang.Generators
using Clang.Generators.JLLEnvs
using Zlib_jll

cd(@__DIR__)
options = load_options(joinpath(@__DIR__, "generator.toml"))
headers = "zlib.h"

# run generator for all platforms
for target in JLLEnvs.JLL_ENV_TRIPLES
@info "processing $target"

options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src/lib", "$target.jl")

# add compiler flags, e.g. "-DXXXXXXXXX"
args = get_default_args()
arch = JLLEnvs.get_arch(target)
os = JLLEnvs.get_os(target)
if (arch == "aarch64" || arch == "x86_64" || arch == "powerpc64le") && (os != "windows")
push!(args, "-DZ_WANT64")
end

# create context
ctx = create_context(headers, args, options)

# run generator
build!(ctx)
end
13 changes: 13 additions & 0 deletions gen/generator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[general]
library_name = "Zlib_jll.libz_path"
output_file_path = "../src/zlib_h.jl"
module_name = "Zlib_h"
jll_pkg_name = "Zlib_jll"
export_symbol_prefixes = ["Z_",]
use_julia_native_enum_type = false
print_using_CEnum = false

[codegen]
is_function_strictly_typed = true
opaque_func_arg_as_PtrCvoid = false
opaque_as_mutable_struct = true
Loading

0 comments on commit 7ad7eba

Please sign in to comment.