/
build.jl
96 lines (82 loc) · 2.47 KB
/
build.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using Libdl
depsfile = joinpath(dirname(@__FILE__),"deps.jl")
if isfile(depsfile)
rm(depsfile)
end
function my_download(url::AbstractString, filename::AbstractString)
if Sys.iswindows() && VERSION < v"1.1"
# from https://github.com/JuliaLang/julia/blob/788b2c77c10c2160f4794a4d4b6b81a95a90940c/base/download.jl#L26
# otherwise files are not properly downloaded - check sizes
curl_exe = joinpath(get(ENV, "SYSTEMROOT", "C:\\Windows"), "System32\\curl.exe")
process = run(`$curl_exe -s -S -g -L -f -o $filename $url`)#, wait=false)
return filename
else
return download(url, filename)
end
end
function write_depsfile(path)
f = open(depsfile,"w")
if Sys.iswindows()
path = replace(path, "\\" => "\\\\")
end
print(f,"""
const xpressdlpath = \"$(path)\"
""")
close(f)
end
function local_installation()
libname = string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext)
paths_to_try = String[]
push!(paths_to_try, "")
push!(paths_to_try, @__DIR__)
if haskey(ENV, "XPRESSDIR")
push!(paths_to_try, joinpath(ENV["XPRESSDIR"], Sys.iswindows() ? "bin" : "lib"))
end
global found = false
for l in paths_to_try
path = joinpath(l, libname)
d = Libdl.dlopen_e(path)
if d != C_NULL
global found = true
@info("Found $path")
write_depsfile(l)
break
end
end
if !found
error("""
Unable to locate Xpress installation.
Please check your enviroment variable XPRESSDIR.
Note that Xpress must be obtained separately from fico.com.
""")
end
end
function ci_installation()
files = if Sys.iswindows()
[
(ENV["SECRET_XPRS_WIN_8110"], "xprs.dll")
(ENV["SECRET_XPRL_WIN_8110"], "xprl.dll")
(ENV["SECRET_XPRA_WIN_8130"], "xpauth.xpr")
]
end
for (url, file) in files
local_filename = joinpath(@__DIR__, file)
my_download(url, local_filename)
end
path = joinpath(@__DIR__, files[1][2])
d = Libdl.dlopen_e(path)
if d != C_NULL
write_depsfile(@__DIR__)
else
error("Could not open xprs.dll")
end
end
if haskey(ENV, "XPRESS_JL_SKIP_LIB_CHECK")
# Skip!
elseif get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true"
write_depsfile("julia_registryci_automerge")
elseif get(ENV, "SECRET_XPRS_WIN_8110", "") != ""
ci_installation()
else
local_installation()
end