-
Notifications
You must be signed in to change notification settings - Fork 13
/
gen.jl
28 lines (24 loc) · 891 Bytes
/
gen.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright (c) 2019 Mathieu Besançon, Oscar Dowson, and 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.
using Clang.Generators
import HiGHS_jll
highs = joinpath(HiGHS_jll.artifact_dir, "include", "highs")
c_api = joinpath(highs, "interfaces", "highs_c_api.h")
build!(
create_context(
[c_api, joinpath(highs, "util", "HighsInt.h")],
vcat(get_default_args(), "-I$highs"),
load_options(joinpath(@__DIR__, "generate.toml")),
),
)
open(joinpath(@__DIR__, "..", "src", "gen", "libhighs.jl"), "a") do io
for line in readlines(c_api)
m = match(r"const HighsInt kHighs([a-zA-Z]+) = (-?[0-9]+);", line)
if m === nothing
continue
end
println(io, "const kHighs$(m[1]) = HighsInt($(m[2]))")
end
end