Skip to content

Commit 26382b7

Browse files
melonedovisr
authored andcommitted
Update generator scripts
1 parent e1f2b25 commit 26382b7

File tree

8 files changed

+484
-286
lines changed

8 files changed

+484
-286
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
deps/deps.jl
55
deps/usr
66
deps/build.log
7+
/Manifest.toml
8+
.vscode

gen/Manifest.toml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
[[ArgTools]]
4+
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
5+
6+
[[Artifacts]]
7+
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
8+
9+
[[Base64]]
10+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
11+
12+
[[CEnum]]
13+
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
14+
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
15+
version = "0.4.1"
16+
17+
[[Clang]]
18+
deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"]
19+
git-tree-sha1 = "d3afee03b07f1fcc80c336a94f91aa0ea8370d6e"
20+
repo-rev = "master"
21+
repo-url = "https://github.com/JuliaInterop/Clang.jl"
22+
uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31"
23+
version = "0.14.0"
24+
25+
[[Clang_jll]]
26+
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "libLLVM_jll"]
27+
git-tree-sha1 = "a5923c06de3178dd755f4b9411ea8922a7ae6fb8"
28+
uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100"
29+
version = "11.0.1+3"
30+
31+
[[Dates]]
32+
deps = ["Printf"]
33+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
34+
35+
[[Downloads]]
36+
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
37+
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
38+
39+
[[GEOS_jll]]
40+
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
41+
git-tree-sha1 = "45d0ddfd29620ac9b2d1072801e90fb016c5f94c"
42+
uuid = "d604d12d-fa86-5845-992e-78dc15976526"
43+
version = "3.9.0+0"
44+
45+
[[InteractiveUtils]]
46+
deps = ["Markdown"]
47+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
48+
49+
[[JLLWrappers]]
50+
deps = ["Preferences"]
51+
git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
52+
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
53+
version = "1.3.0"
54+
55+
[[LibCURL]]
56+
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
57+
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
58+
59+
[[LibCURL_jll]]
60+
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
61+
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
62+
63+
[[LibGit2]]
64+
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
65+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
66+
67+
[[LibSSH2_jll]]
68+
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
69+
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
70+
71+
[[Libdl]]
72+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
73+
74+
[[Logging]]
75+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
76+
77+
[[MacroTools]]
78+
deps = ["Markdown", "Random"]
79+
git-tree-sha1 = "0fb723cd8c45858c22169b2e42269e53271a6df7"
80+
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
81+
version = "0.5.7"
82+
83+
[[Markdown]]
84+
deps = ["Base64"]
85+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
86+
87+
[[MbedTLS_jll]]
88+
deps = ["Artifacts", "Libdl"]
89+
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
90+
91+
[[MozillaCACerts_jll]]
92+
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
93+
94+
[[NetworkOptions]]
95+
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
96+
97+
[[Pkg]]
98+
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
99+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
100+
101+
[[Preferences]]
102+
deps = ["TOML"]
103+
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
104+
uuid = "21216c6a-2e73-6563-6e65-726566657250"
105+
version = "1.2.2"
106+
107+
[[Printf]]
108+
deps = ["Unicode"]
109+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
110+
111+
[[REPL]]
112+
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
113+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
114+
115+
[[Random]]
116+
deps = ["Serialization"]
117+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
118+
119+
[[SHA]]
120+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
121+
122+
[[Serialization]]
123+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
124+
125+
[[Sockets]]
126+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
127+
128+
[[TOML]]
129+
deps = ["Dates"]
130+
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
131+
132+
[[Tar]]
133+
deps = ["ArgTools", "SHA"]
134+
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
135+
136+
[[UUIDs]]
137+
deps = ["Random", "SHA"]
138+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
139+
140+
[[Unicode]]
141+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
142+
143+
[[Zlib_jll]]
144+
deps = ["Libdl"]
145+
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
146+
147+
[[libLLVM_jll]]
148+
deps = ["Artifacts", "Libdl"]
149+
uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a"
150+
151+
[[nghttp2_jll]]
152+
deps = ["Artifacts", "Libdl"]
153+
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
154+
155+
[[p7zip_jll]]
156+
deps = ["Artifacts", "Libdl"]
157+
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"

gen/generate.jl

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Clang.Generators
2+
using MacroTools
3+
using GEOS_jll
4+
5+
function rewriter(dag::ExprDAG)
6+
for n in dag.nodes
7+
map!(rewriter, n.exprs, n.exprs)
8+
end
9+
end
10+
11+
"Functions that return a Cstring are wrapped in unsafe_string to return a String"
12+
function rewriter(x::Expr)
13+
if @capture(x,
14+
function f_(fargs__)
15+
ccall(fname_, rettype_, argtypes_, argvalues__)
16+
end
17+
)
18+
# it is a function wrapper around a ccall
19+
20+
# bind the ccall such that we can easily wrap it
21+
cc = :(ccall($fname, $rettype, $argtypes, $(argvalues...)))
22+
23+
cc2 = if rettype == :Cstring
24+
:(unsafe_string($cc))
25+
else
26+
cc
27+
end
28+
29+
# stitch the modified function expression back together
30+
x2 = :(function $f($(fargs...))
31+
$cc2
32+
end) |> prettify
33+
x2
34+
else
35+
# do not modify expressions that are no ccall function wrappers
36+
x
37+
end
38+
end
39+
40+
cd(@__DIR__)
41+
42+
include_dir = joinpath(GEOS_jll.artifact_dir, "include") |> normpath
43+
44+
# wrapper generator options
45+
options = load_options(joinpath(@__DIR__, "generate.toml"))
46+
47+
args = get_default_args()
48+
push!(args, "-I$include_dir")
49+
50+
header_dir = include_dir
51+
headers = [joinpath(header_dir, "geos_c.h")]
52+
53+
# create context
54+
ctx = create_context(headers, args, options)
55+
56+
# run generator
57+
build!(ctx, BUILDSTAGE_NO_PRINTING)
58+
rewriter(ctx.dag)
59+
build!(ctx, BUILDSTAGE_PRINTING_ONLY)

gen/generate.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[general]
2+
library_name = "libgeos"
3+
output_file_path = "../src/libgeos.jl"
4+
# prologue_file_path = "prologue.jl"
5+
use_julia_native_enum_type = false
6+
print_using_CEnum = false
7+
use_deterministic_symbol = true
8+
is_local_header_only = true
9+
smart_de_anonymize = true
10+
printer_blacklist = [
11+
]
12+
[codegen]
13+
use_julia_bool = true
14+
always_NUL_terminated_string = true
15+
is_function_strictly_typed = false
16+
opaque_func_arg_as_PtrCvoid = false
17+
opaque_as_mutable_struct = false
18+
use_ccall_macro = false

gen/wrap_geos.jl

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/LibGEOS.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ module LibGEOS
2424
export contains
2525
end
2626

27-
include("geos_common.jl")
28-
include("geos_c.jl")
27+
include("../lib/libgeos.jl")
2928

3029
mutable struct GEOSError <: Exception
3130
msg::String

0 commit comments

Comments
 (0)