Skip to content

Commit

Permalink
Move Lib module to subdirectory (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Mar 7, 2024
1 parent 808f157 commit 87b6cd8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ Manifest.toml
*.bat
*.sublime-project
*.json
*.txt
*.txt
deps/*.tar.bz2
deps/lib
deps/info
14 changes: 14 additions & 0 deletions src/Lib/Lib.jl
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
44 changes: 23 additions & 21 deletions src/Xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
12 changes: 0 additions & 12 deletions src/ctypes.jl

This file was deleted.

0 comments on commit 87b6cd8

Please sign in to comment.