Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate libknitro.jl with KNITRO v14.1 #306

Merged
merged 4 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
3 changes: 0 additions & 3 deletions gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ julia --project -e "using Pkg ; Pkg.instantiate()"

Once the project installed, you can regenerate the C wrapper directly with:
```julia
using Clang
include("generate_wrapper.jl")

```
This takes as input the header file `knitro.h` in the `KNITRODIR`
directory and generates automatically all the Julia bindings with Clang.jl.

5 changes: 5 additions & 0 deletions gen/generate_wrapper.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Clang
using Clang.Generators
using JuliaFormatter

cd(@__DIR__)

Expand All @@ -13,3 +15,6 @@ push!(args, "-I$HEADER_BASE")

ctx = create_context(headers, args, options)
build!(ctx)

path = options["general"]["output_file_path"]
format_file(path)
1 change: 1 addition & 0 deletions gen/generator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ prologue_file_path = "./prologue.jl"

[codegen]
opaque_as_mutable_struct = false
use_ccall_macro = true

[codegen.macro]
macro_mode = "basic"
5 changes: 5 additions & 0 deletions gen/prologue.jl
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Copyright (c) 2016: Ng Yee Sian, Miles Lubin, other contributors
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

const DBL_MAX = Float64(0x1.fffffffffffffp+1023)
7 changes: 4 additions & 3 deletions src/KNITRO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ function __init__()
end

function knitro_version()
buffer = zeros(Cchar, 15)
ccall((:KTR_get_release, libknitro), Cint, (Cint, Ptr{Cchar}), 15, buffer)
version_string = GC.@preserve(buffer, unsafe_string(pointer(buffer)))
length = 15
release = zeros(Cchar, length)
KN_get_release(length, release)
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
return VersionNumber(split(version_string, " ")[2])
end

Expand Down
Loading
Loading