Skip to content
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
19 changes: 12 additions & 7 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function get_de_libnames()
# Use a function for this because I F. CAN'T MAKE ANY SENSE ABOUT GLOBAL-LOCAL SCOPES INSIDE TRY-CATCH
errou = false
GMT_bindir, libgmt, libpostscriptlight, libgdal, libproj, ver, userdir, devdate = "", "", "", "", "", "", "", "0001.01.01"
GMT_bindir, libgmt, libpostscriptlight, libgs, libgdal, libproj, ver, userdir, devdate = "", "", "", "", "", "", "", "", "0001.01.01"

try # First try to find an existing GMT installation (RECOMENDED WAY)
(Sys.iswindows() && get(ENV, "UPDATE_GMTWIN", "") != "") && error("Forcing automatic Win install")
Expand All @@ -13,6 +13,8 @@ function get_de_libnames()
pato, fname = splitdir(libgmt)
libpostscriptlight = joinpath(pato, replace(fname, "gmt" => "postscriptlight"))

libgs = joinpath(pato, "gsdll64.dll")

@static Sys.iswindows() ? libgdal = "gdal_w64.dll" : (
Sys.isapple() ? (libgdal = string(split(readlines(pipeline(`otool -L $(libgmt)`, `grep libgdal`))[1])[1])) : (
Sys.isunix() ? (libgdal = string(split(readlines(pipeline(`ldd $(libgmt)`, `grep libgdal`))[1])[3])) :
Expand Down Expand Up @@ -41,12 +43,13 @@ function get_de_libnames()
rm(fn, force=true)
libgmt = "gmt_w64.dll"
libpostscriptlight = "postscriptlight_w64.dll"
libgs = "gsdll64.dll"
libgdal = "gdal_w64.dll"
libproj = "proj_w64.dll"
GMT_bindir = "C:\\programs\\gmt6\\bin"
else
println("\n\nNo GMT system wide installation found\n\n")
return true, ver, libgmt, libpostscriptlight, libgdal, libproj, GMT_bindir, userdir, devdate
return true, ver, libgmt, libpostscriptlight, libgs, libgdal, libproj, GMT_bindir, userdir, devdate
end

try
Expand All @@ -55,30 +58,31 @@ function get_de_libnames()
ver = ((ind = findfirst('_', out)) === nothing) ? VersionNumber(out) : VersionNumber(out[1:ind-1])
end
catch
return false, v"6.6", libgmt, libpostscriptlight, libgdal, libproj, GMT_bindir, joinpath(homedir(), ".gmt"), devdate
return false, v"6.6", libgmt, libpostscriptlight, libgs, libgdal, libproj, GMT_bindir, joinpath(homedir(), ".gmt"), devdate
end

catch err2; println(err2)
return true, ver, libgmt, libpostscriptlight, libgdal, libproj, GMT_bindir, userdir, devdate
return true, ver, libgmt, libpostscriptlight, libgs, libgdal, libproj, GMT_bindir, userdir, devdate
end
end
userdir = readlines(`gmt --show-userdir`)[1]
Sys.iswindows() && (userdir = replace(userdir, "/" => "\\"))
out = readlines(`gmt --version`)[1]
devdate = ((ind = findlast('_', out)) !== nothing) ? out[ind+1:end] : "2022.06.18" # 2022.06.18 is the 6.4 release date
Sys.iswindows() && (GMT_bindir = readlines(`gmt --show-bindir`)[1]) # Only on Win is that all dlls are in same bin dir
return errou, ver, libgmt, libpostscriptlight, libgdal, libproj, GMT_bindir, userdir, devdate
return errou, ver, libgmt, libpostscriptlight, libgs, libgdal, libproj, GMT_bindir, userdir, devdate
end

force_winjll = (get(ENV, "FORCE_WINJLL", "") != "") # Use this env var to also force use of the JLL on Windows
if (force_winjll || (!Sys.iswindows() && get(ENV, "SYSTEMWIDE_GMT", "") == "")) # That is: the JLL case
# Just to have something. They won't be used in main. There, wee only need that a "deps.jl" exists
libgmt, libpostscriptlight, libgdal, libproj, ver, userdir, devdate = "nikles", "nikles", "nikles", "nikles", "0.0", "nikles", "0001.01.01"
libgmt, libpostscriptlight, libgs, libgdal, libproj, ver, userdir, devdate =
"nikles", "nikles", "nikles", "nikles", "nikles", "0.0", "nikles", "0001.01.01"
GMT_bindir = ""
is_jll = 1
errou = false
else
errou, ver, libgmt, libpostscriptlight, libgdal, libproj, GMT_bindir, userdir, devdate = get_de_libnames()
errou, ver, libgmt, libpostscriptlight, libgs, libgdal, libproj, GMT_bindir, userdir, devdate = get_de_libnames()
is_jll = 0
end

Expand All @@ -88,6 +92,7 @@ if (!errou) # Save shared names in file so that GMT.jl can read them at pre-com
open(depfile, "w") do f
println(f, "_libgmt = \"", escape_string(joinpath(GMT_bindir, libgmt)), '"')
println(f, "_libpostscriptlight = \"", escape_string(joinpath(GMT_bindir, libpostscriptlight)), '"')
println(f, "_libgs = \"", escape_string(joinpath(GMT_bindir, libgs)), '"')
println(f, "_libgdal = \"", escape_string(joinpath(GMT_bindir, libgdal)), '"')
println(f, "_libproj = \"", escape_string(joinpath(GMT_bindir, libproj)), '"')
println(f, "_GMTver = v\"" * string(ver) * "\"")
Expand Down
2 changes: 1 addition & 1 deletion src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if ((!(@isdefined have_jll) || have_jll == 1) && get(ENV, "SYSTEMWIDE_GMT", "")
libpostscriptlight = joinpath(pato, replace(fname, "gmt" => "postscriptlight"))
else
const isJLL = false
const GMTver, libgmt, libpostscriptlight, libgdal, libproj, GMTuserdir, GMTbin = _GMTver, _libgmt, _libpostscriptlight, _libgdal, _libproj, [userdir], "gmt"
const GMTver, libgmt, libpostscriptlight, libgs, libgdal, libproj, GMTuserdir, GMTbin = _GMTver, _libgmt, _libpostscriptlight, _libgs, _libgdal, _libproj, [userdir], "gmt"
const GMTdevdate = Date(devdate, dateformat"y.m.d") # 'devdate' comes from reading 'deps.jl'
end

Expand Down
9 changes: 6 additions & 3 deletions test/test_imgtiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
quadbounds(quadtree[1]);
quadbounds(quadtree);
GMT.meridionalRad(6371007.0, 0.0)
D = geocoder("Universidade do Algarve, Gambelas");
mosaic(D, zoom=2, quadonly=1);
mosaic(D, zoom=2, bb=1, quadonly=1);
try # This bloody things fails so many tines in Github
D = geocoder("Universidade do Algarve, Gambelas");
mosaic(D, zoom=2, quadonly=1);
mosaic(D, zoom=2, bb=1, quadonly=1);
catch
end
mosaic(R=(91,110,6,22), quadonly=1);
mosaic(-90,25, zoom=1, provider="nimb",key="0", quadonly=1);
G = peaks(); G.proj4 = "+proj=lonlat";
Expand Down
Loading