-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from nathanemac/add_libproxtv
Add libproxtv files
- Loading branch information
Showing
10 changed files
with
689 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
[deps] | ||
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" | ||
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" | ||
proxTV_jll = "700117f8-5dbb-54dd-9908-6f3eb0e21f87" | ||
|
||
[compat] | ||
julia = "1.6" |
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,9 @@ | ||
# Wrapping headers | ||
|
||
This directory contains a script that can be used to automatically generate wrappers from C headers provided by [proxTV](https://github.com/albarji/proxTV). | ||
This is done using Clang.jl. | ||
|
||
## Usage | ||
|
||
Either run `julia wrapper.jl` directly, or include it and call the `main()` function. | ||
Be sure to activate the project environment in this folder (`julia --project`), which will install `Clang.jl` and `JuliaFormatter.jl`. |
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 @@ | ||
[general] | ||
use_julia_native_enum_type = true | ||
print_using_CEnum = false | ||
library_name = "libproxtv" | ||
|
||
[codegen] | ||
use_julia_bool = true | ||
use_ccall_macro = true |
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,41 @@ | ||
# Script to parse proxTV headers and generate Julia wrappers. | ||
using proxTV_jll | ||
using Clang | ||
using Clang.Generators | ||
using JuliaFormatter | ||
|
||
function main() | ||
cd(@__DIR__) | ||
include_dir = joinpath(proxTV_jll.artifact_dir, "include") | ||
headers = [ | ||
joinpath(include_dir, header) for | ||
header in readdir(include_dir) if endswith(header, ".h") | ||
] | ||
|
||
options = load_options(joinpath(@__DIR__, "proxtv.toml")) | ||
options["general"]["output_file_path"] = joinpath("..", "libproxtv.jl") | ||
options["general"]["output_ignorelist"] = | ||
["mxGetInf", "sign", "min", "max", "dpttrs_", "dpttrf_"] # example: "RC_OK" | ||
|
||
args = get_default_args() | ||
push!(args, "-I$include_dir") | ||
push!(args, "-DNOMATLAB") | ||
|
||
ctx = create_context(headers, args, options) | ||
build!(ctx) | ||
|
||
path = options["general"]["output_file_path"] | ||
code = read(path, String) | ||
code = "using proxTV_jll\n\n" * code | ||
code = replace(code, "Cdouble" => "Float64") | ||
code = replace(code, "Cint" => "Int32") | ||
write(path, code) | ||
|
||
format_file(path, YASStyle()) | ||
return nothing | ||
end | ||
|
||
# If we want to use the file as a script with `julia wrapper.jl` | ||
if abspath(PROGRAM_FILE) == @__FILE__ | ||
main() | ||
end |
Oops, something went wrong.