Skip to content

Commit

Permalink
Fix generation handling of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Octogonapus committed May 1, 2024
1 parent 283faca commit 812a372
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
14 changes: 13 additions & 1 deletion gen/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "46342e1b48a16f578d983378fc2b627a4124a3d5"
project_hash = "bd802c34455e572f67caa68a2beb6ffc7761162e"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -82,6 +82,18 @@ git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.5.0"

[[deps.LibAwsCal]]
deps = ["CEnum", "LibAwsCommon", "aws_c_cal_jll"]
git-tree-sha1 = "cb38f20d8e187a33770840e2a2eaef8c13ee425d"
uuid = "ef519ef6-af43-41a0-8ac4-eb81328190af"
version = "1.0.0"

[[deps.LibAwsCommon]]
deps = ["CEnum", "aws_c_common_jll"]
git-tree-sha1 = "d8705f05415a487369d5bbfb2ca149c72ffb5609"
uuid = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
version = "1.0.0"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
Expand Down
2 changes: 2 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
JLLPrefixes = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
LibAwsCal = "ef519ef6-af43-41a0-8ac4-eb81328190af"
LibAwsCommon = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
aws_c_cal_jll = "70f11efc-bab2-57f1-b0f3-22aad4e67c4b"
aws_c_common_jll = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
aws_c_io_jll = "13c41daa-f319-5298-b5eb-5754e0170d52"
Expand Down
30 changes: 24 additions & 6 deletions gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using Clang.Generators
using Clang.JLLEnvs
using JLLPrefixes
import aws_c_common_jll, aws_c_io_jll, aws_c_cal_jll
using LibAwsCommon
using LibAwsCal

cd(@__DIR__)

Expand All @@ -27,6 +29,21 @@ function should_skip_target(target)
return target == "i686-w64-mingw32"
end

const deps_jlls = [aws_c_common_jll, aws_c_cal_jll]
const deps = [LibAwsCommon, LibAwsCal]
const deps_names = sort(collect(Iterators.flatten(names.(deps))))

# clang can emit code for forward declarations of structs defined in our dependencies. we need to skip those, otherwise
# we'll have duplicate struct definitions.
function skip_nodes_in_dependencies!(dag::ExprDAG)
replace!(get_nodes(dag)) do node
if insorted(node.id, deps_names)
return ExprNode(node.id, Generators.Skip(), node.cursor, Expr[], node.adj)
end
return node
end
end

# download toolchains in parallel
Threads.@threads for target in JLLEnvs.JLL_ENV_TRIPLES
if should_skip_target(target)
Expand All @@ -44,11 +61,10 @@ for target in JLLEnvs.JLL_ENV_TRIPLES
options["general"]["callback_documentation"] = get_docs

args = get_default_args(target)
inc = JLLEnvs.get_pkg_include_dir(aws_c_common_jll, target)
push!(args, "-isystem$inc")

inc = JLLEnvs.get_pkg_include_dir(aws_c_cal_jll, target)
push!(args, "-isystem$inc")
for dep in deps_jlls
inc = JLLEnvs.get_pkg_include_dir(dep, target)
push!(args, "-isystem$inc")
end

header_dirs = []
inc = JLLEnvs.get_pkg_include_dir(aws_c_io_jll, target)
Expand All @@ -68,5 +84,7 @@ for target in JLLEnvs.JLL_ENV_TRIPLES
unique!(headers)

ctx = create_context(headers, args, options)
build!(ctx)
build!(ctx, BUILDSTAGE_NO_PRINTING)
skip_nodes_in_dependencies!(ctx.dag)
build!(ctx, BUILDSTAGE_PRINTING_ONLY)
end

0 comments on commit 812a372

Please sign in to comment.