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

Move Lib module to subdirectory #223

Merged
merged 1 commit into from
Mar 7, 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
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 @@
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("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))

Check warning on line 37 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L37

Added line #L37 was not covered by tests

function _is_xprs_attribute(name::String)
return startswith(name, "XPRS_") &&

Check warning on line 40 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L39-L40

Added lines #L39 - L40 were not covered by tests
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

Check warning on line 55 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L55

Added line #L55 was not covered by tests
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.

Loading