Skip to content

Commit

Permalink
Fix generator handling of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Octogonapus committed May 1, 2024
1 parent 59eab0d commit 413fc0b
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 78 deletions.
8 changes: 7 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 = "bd850a42ef7f95a1a9bd908c048d0235fc178ef8"
project_hash = "d64bc1695197acfdf3b992bbffaef26ba6da3bd1"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -82,6 +82,12 @@ git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.5.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
1 change: 1 addition & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
JLLPrefixes = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
LibAwsCommon = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
aws_c_common_jll = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
aws_c_sdkutils_jll = "1282aa60-004d-510b-9f52-12498d409daa"

Expand Down
35 changes: 23 additions & 12 deletions gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ using Clang.Generators
using Clang.JLLEnvs
using JLLPrefixes
import aws_c_common_jll, aws_c_sdkutils_jll
using LibAwsCommon

cd(@__DIR__)

const refs_to_remove = []

# This is called if the docs generated from the extract_c_comment_style method did not generate any lines.
# We need to generate at least some docs so that cross-references work with Documenter.jl.
function get_docs(node, docs)
Expand All @@ -21,13 +20,6 @@ function get_docs(node, docs)
return ["Documentation not found."]
end

# remove references to things which don't exist because it causes Documenter.jl's cross_references check to fail
for ref in refs_to_remove
for doci in eachindex(docs)
docs[doci] = replace(docs[doci], "[`$ref`](@ref)" => "`$ref`")
end
end

return docs
end

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

const deps_jlls = [aws_c_common_jll]
const deps = [LibAwsCommon]
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 @@ -53,8 +60,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")
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_sdkutils_jll, target)
Expand All @@ -74,5 +83,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
5 changes: 0 additions & 5 deletions lib/aarch64-apple-darwin20.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/aarch64-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/aarch64-linux-musl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/armv7l-linux-gnueabihf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/armv7l-linux-musleabihf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/i686-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/i686-linux-musl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/powerpc64le-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/x86_64-apple-darwin14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/x86_64-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/x86_64-linux-musl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/x86_64-unknown-freebsd13.2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down
5 changes: 0 additions & 5 deletions lib/x86_64-w64-mingw32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,6 @@ Documentation not found.
"""
mutable struct aws_endpoints_request_context end

"""
Documentation not found.
"""
mutable struct aws_hash_table end

"""
aws_endpoints_parameter_type
Expand Down

0 comments on commit 413fc0b

Please sign in to comment.