-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade the wrapper script and rework the pacakge for multi-platform …
…support
- Loading branch information
Showing
34 changed files
with
27,258 additions
and
3,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[deps] | ||
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" | ||
LibCURL_jll = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" | ||
MozillaCACerts_jll = "14a3606d-f60d-562e-9121-12d972cd8159" | ||
|
||
[compat] | ||
LibCURL_jll = "7.66" | ||
MozillaCACerts_jll = ">= 2020" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/aarch64-linux-gnu.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/aarch64-linux-musl.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/armv7l-linux-gnueabihf.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/armv7l-linux-musleabihf.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/i686-linux-gnu.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/i686-linux-musl.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/i686-w64-mingw32.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/powerpc64le-linux-gnu.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/x86_64-apple-darwin14.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/x86_64-linux-gnu.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/x86_64-linux-musl.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/x86_64-unknown-freebsd11.1.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/wrappers/x86_64-w64-mingw32.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
auto_mutability = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,40 @@ | ||
using Clang.cindex | ||
using Clang.wrap_c | ||
using Printf | ||
using Pkg | ||
using Pkg.Artifacts | ||
using Clang.Generators | ||
using Clang.Generators.JLLEnvs | ||
using LibCURL_jll | ||
|
||
# Set these to correspond to your local filesystem's curl and clang include paths | ||
const CURL_PATH = "/usr/local/opt/curl/include/curl" | ||
const CLANG_INCLUDES = [ | ||
"/usr/local/opt/llvm/include", | ||
] | ||
cd(@__DIR__) | ||
|
||
const SRC_DIR = abspath(@__DIR__, "..", "src") | ||
artifact_toml = joinpath(dirname(Pkg.pathof(LibCURL_jll)), "..", "StdlibArtifacts.toml") | ||
artifact_dir = Pkg.Artifacts.ensure_artifact_installed("LibCURL", artifact_toml) | ||
|
||
headers = map(x -> joinpath(CURL_PATH, x), ["curl.h", "easy.h", "multi.h"]) | ||
context = wrap_c.init(; | ||
headers = headers, | ||
clang_args = String[], | ||
common_file = joinpath(SRC_DIR, "lC_common_h.jl"), | ||
clang_includes = CLANG_INCLUDES, | ||
clang_diagnostics = true, | ||
header_wrapped = (top_header, cursor_header) -> in(cursor_header, headers), | ||
header_library = header -> "libcurl", | ||
header_outputfile = header -> joinpath(SRC_DIR, "lC_") * replace(basename(header), "." => "_") * ".jl", | ||
) | ||
context.options.wrap_structs = true | ||
include_dir = joinpath(artifact_dir, "include") |> normpath | ||
curl_h = joinpath(include_dir, "curl", "curl.h") | ||
@assert isfile(curl_h) | ||
|
||
begin | ||
context.headers = [joinpath(CURL_PATH, "curl.h")] | ||
run(context) | ||
end | ||
|
||
function write_constants(filename::AbstractString, startswith_identifier::AbstractString, exports_file) | ||
open(filename, "r") do file | ||
lines = split(read(file, String), "\n") | ||
# mprintf_h = joinpath(include_dir, "curl", "mprintf.h") | ||
# stdcheaders_h = joinpath(include_dir, "curl", "stdcheaders.h") | ||
|
||
for line in lines | ||
if startswith(line, startswith_identifier) | ||
@printf exports_file "export %s\n" split(line, r" |\(")[2] | ||
end | ||
end | ||
end | ||
end | ||
target = "aarch64-linux-gnu" | ||
for target in JLLEnvs.JLL_ENV_TRIPLES | ||
target == "aarch64-apple-darwin20" && continue | ||
|
||
# Generate export statements | ||
open(joinpath(SRC_DIR, "lC_exports_h.jl"), "w+") do exports_file | ||
println(exports_file, "# Generating exports") | ||
@info "processing $target" | ||
|
||
write_constants(joinpath(SRC_DIR, "lC_curl_h.jl"), "function", exports_file) | ||
write_constants(joinpath(SRC_DIR, "lC_common_h.jl"), "const", exports_file) | ||
options = load_options(joinpath(@__DIR__, "configs", "$target.toml")) | ||
|
||
# Generate define constants | ||
open(joinpath(SRC_DIR, "lC_defines_h.jl"), "w+") do defines_file | ||
println(defines_file, "# Generating #define constants") | ||
args = get_default_args(target) | ||
push!(args, "-I$include_dir") | ||
|
||
hashdefs = split(read(`gcc -E -dD -P $(joinpath(CURL_PATH, "curl.h"))`, String), "\n") | ||
# header_files = detect_headers(include_dir, args) | ||
header_files = [curl_h] | ||
|
||
for line in hashdefs | ||
m = match(r"^\s*#define\s+CURL(\w+)\s+(.+)", line) | ||
ctx = create_context(header_files, args, options) | ||
|
||
if m !== nothing | ||
c2 = replace(m.captures[2], "(unsigned long)" => "") | ||
@printf defines_file "const CURL%-30s = %s\n" m.captures[1] c2 | ||
@printf exports_file "export CURL%s\n" m.captures[1] | ||
end | ||
end | ||
end | ||
build!(ctx) | ||
end | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[general] | ||
library_name = "libcurl" | ||
output_file_path = "../src/LibCURL.jl" | ||
|
||
use_julia_native_enum_type = true | ||
use_deterministic_symbol = true | ||
|
||
printer_blacklist = [ | ||
"CURL_SUFFIX_CURL_OFF_T", | ||
"CURL_SUFFIX_CURL_OFF_TU", | ||
"CURL_ZERO_TERMINATED", | ||
] | ||
|
||
auto_mutability = true | ||
|
||
[codegen.macro] | ||
macro_mode = "basic" |
Oops, something went wrong.