diff --git a/.gitignore b/.gitignore index acf5cff7..8eb3649e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ Manifest.toml *.bat *.sublime-project *.json -*.txt \ No newline at end of file +*.txt +deps/*.tar.bz2 +deps/lib +deps/info diff --git a/src/Lib/Lib.jl b/src/Lib/Lib.jl new file mode 100644 index 00000000..046468e5 --- /dev/null +++ b/src/Lib/Lib.jl @@ -0,0 +1,14 @@ +# Copyright (c) 2016: Joaquim Garcia, 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. + +module Lib + +import ..Xpress +const libxprs = Xpress.libxprs + +include("common.jl") +include("xprs.jl") + +end # Lib diff --git a/src/common.jl b/src/Lib/common.jl similarity index 100% rename from src/common.jl rename to src/Lib/common.jl diff --git a/src/lib.jl b/src/Lib/xprs.jl similarity index 100% rename from src/lib.jl rename to src/Lib/xprs.jl diff --git a/src/Xpress.jl b/src/Xpress.jl index 35f32f61..ee0e5e75 100644 --- a/src/Xpress.jl +++ b/src/Xpress.jl @@ -20,15 +20,12 @@ else const xpressdlpath = "" end -const libxprs = joinpath(xpressdlpath, string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext)) +const libxprs = joinpath( + xpressdlpath, + string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext), +) -module Lib - import ..Xpress - const libxprs = Xpress.libxprs - include("ctypes.jl") - include("common.jl") - include("lib.jl") -end +include("Lib/Lib.jl") include("utils.jl") include("helper.jl") @@ -37,30 +34,35 @@ include("api.jl") include("xprs_callbacks.jl") include("license.jl") -const XPRS_ATTRIBUTES = Dict{String, Any}( - replace(string(name), "XPRS_"=>"") => getfield(Lib, name) - for name in names(Lib; all = true) - if startswith(string(name), "XPRS_") && all(isuppercase(c) || isdigit(c) for c in string(name) if c != '_') +_is_xprs_attribute(name::Symbol) = _is_xprs_attribute(string(name)) + +function _is_xprs_attribute(name::String) + return startswith(name, "XPRS_") && + all(isuppercase(c) || isdigit(c) for c in name if c != '_') +end + +const XPRS_ATTRIBUTES = Dict{String,Any}( + replace("$name", "XPRS_" => "") => getfield(Lib, name) for + name in filter(_is_xprs_attribute, names(Lib; all = true)) ) function initialize() Libdl.dlopen(libxprs) userlic() - init() # Call XPRSinit for initialization - # free is not strictly necessary since destroyprob is called - # inthe finalizer. - # the user can call free if needed. - # leaving it uncommented results in many print errors becaus - # it is called prior to finalizers. - # atexit(free) # Call free when process terminates + init() + # Calling free is not necessary since destroyprob is called + # in the finalizer. + return end include("MOI/MOI_wrapper.jl") function __init__() - if !haskey(ENV, "XPRESS_JL_NO_AUTO_INIT") && get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") != "true" - Xpress.initialize() + if !haskey(ENV, "XPRESS_JL_NO_AUTO_INIT") && + get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") != "true" + initialize() end + return end end # Xpress diff --git a/src/ctypes.jl b/src/ctypes.jl deleted file mode 100644 index 57a97cfd..00000000 --- a/src/ctypes.jl +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2016: Joaquim Garcia, 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. - -## TODO: pending https://github.com/JuliaLang/julia/issues/29420 -# this one is suggested in the issue, but it looks like time_t and tm are two different things? -# const Ctime_t = Base.Libc.TmStruct - -const Ctm = Base.Libc.TmStruct -const Ctime_t = UInt -const Cclock_t = UInt