From d9c98d0c776db48a10ac0052dd079b44bc2833e1 Mon Sep 17 00:00:00 2001 From: shipengcheng1230 Date: Thu, 15 Apr 2021 12:03:01 -0400 Subject: [PATCH] test 1.6 --- .appveyor.yml | 2 +- .travis.yml | 4 +-- Project.toml | 9 ++--- README.md | 15 +------- deps/build.jl | 88 ++++++++++++++++++++++++----------------------- docs/src/index.md | 4 +-- src/GmshTools.jl | 38 +++++++++++++------- test/runtests.jl | 5 --- 8 files changed, 79 insertions(+), 86 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 21e461b..af2061d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,6 @@ environment: matrix: - - julia_version: 1.5 + - julia_version: 1.6 - julia_version: nightly platform: diff --git a/.travis.yml b/.travis.yml index 521a66e..8b9d951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: - linux - osx julia: - - 1.5 + - 1.6 - nightly notifications: email: false @@ -30,7 +30,7 @@ jobs: fast_finish: true include: - stage: "Documentation" - julia: 1.5 + julia: 1.6 os: linux install: # mkdocs-material isn't available at the default py2 on travis-ci for now diff --git a/Project.toml b/Project.toml index d85064a..9a803e0 100644 --- a/Project.toml +++ b/Project.toml @@ -1,20 +1,17 @@ name = "GmshTools" uuid = "82e2f556-b1bd-5f1a-9576-f93c0da5f0ee" authors = ["Pengcheng Shi"] -version = "0.4.2" +version = "0.5.0" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Requires = "ae029012-a4dd-5104-9daa-d747884805df" +gmsh_jll = "630162c2-fc9b-58b3-9910-8442a8a132e6" [compat] -Requires = "1.0" julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [targets] -test = ["Test", "Pkg"] +test = ["Test"] diff --git a/README.md b/README.md index ba6bcbd..47b4b89 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,4 @@ [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://shipengcheng1230.github.io/GmshTools.jl/stable/) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://shipengcheng1230.github.io/GmshTools.jl/dev/) -To use [Gmsh](http://gmsh.info/) mesh program. - -# Notice - -- Users could set the environment variable `GMSH_LIB_PATH` to your source-compiled Gmsh library - directory and rebuild this package. For windows user, you need to create a link from `gmsh-*.*.dll` to `libgmsh.dll` since something has changed with `find_library` after Julia *v1.4*. - -- Before Gmsh *v4.6.0*, if your Julia is compiled with [Intel MKL](https://github.com/JuliaComputing/MKL.jl), then it must be compiled with 32 integer interface (otherwise Julia will crash due to BLAS interface incompatibility), i.e. linking to **lp64** instead of **ipl64**. To do so, in `Make.inc`, change to - ```makefile - export MKL_INTERFACE_LAYER := LP64 - MKLLIB := $(MKLROOT)/lib/intel64 - ``` - -- Since *v0.4.0*, you will need to manually install [Gmsh_SDK_jll.jl](https://github.com/shipengcheng1230/Gmsh_SDK_jll.jl), which, due to some building issues, cannot fit into [JuliaBinaryWrappers](https://github.com/JuliaBinaryWrappers) for now. The building procedure is hosted at [GmshBuilder.jl](https://github.com/shipengcheng1230/GmshBuilder.jl). +To use [Gmsh](http://gmsh.info/) mesh program in a more convenient way. diff --git a/deps/build.jl b/deps/build.jl index a08b64e..fcecf3e 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,48 +1,50 @@ -using Libdl -using Pkg +# Copied from https://github.com/gridap/GridapGmsh.jl/blob/master/deps/build.jl +# to use the new officially registered Gmsh JLL -const depsfile = joinpath(@__DIR__, "deps.jl") +gmsh_root = nothing -const libpath = get(ENV, "GMSH_LIB_PATH", nothing) - -if libpath === nothing - open(depsfile, "w") do io - print(io, - raw""" - # This file is automatically generated - # Do not edit - using Gmsh_SDK_jll - check_deps() = nothing - include(joinpath(dirname(Gmsh_SDK_jll.libgmsh_path), "gmsh.jl")) - """ - ) - end +if haskey(ENV,"GMSHROOT") && !isempty(ENV["GMSHROOT"]) + gmsh_root = ENV["GMSHROOT"] + @info """ + Using the gmsh installation found via the GMSHROOT environment variable. + GMSHROOT=$gmsh_root""" else - # For windows, you must create a link from `gmsh-*.*.dll` to `libgmsh.dll` - libgmsh = find_library("libgmsh", [libpath]) - if isempty(libgmsh) - @static if Sys.iswindows() - @info "You may create a link from `gmsh-*.*.dll` to `libgmsh.dll`." - end - error("libgmsh is not found in $libpath.") - end - - libgmsh_size = filesize(dlpath()) + using gmsh_jll + GMSH_FOUND = gmsh_jll.is_available() + if GMSH_FOUND + gmsh_root = gmsh_jll.artifact_dir + @info """ + Using the gmsh installation installed via BinaryBuilder.""" + end +end - open(depsfile, "w") do io - println(io, - """ - # This file is automatically generated - # Do not edit - function check_deps() - if libgmsh_size != filesize(Libdl.dlpath(libgmsh_size)) - error("Gmsh library has changed, re-run Pkg.build(\\\"GmshTools\\\")") - end - end - include(joinpath(libpath, "gmsh.jl")) - """ - ) - println(io, :(const libgmsh = $libgmsh)) - println(io, :(const libgmsh_size = $libgmsh_size)) - end +GMSH_FOUND = false +if gmsh_root != nothing + gmsh_bin = (Sys.iswindows() ? joinpath(gmsh_root,"bin","gmsh.exe") : + joinpath(gmsh_root,"bin","gmsh")) + if isfile(gmsh_bin) + GMSH_FOUND = true + @info "gmsh binary found in $gmsh_bin" + else + @warn """ + gmsh binary not found in $gmsh_bin + Make sure that GMSHROOT points to a correct gmsh installation""" + end + gmsh_jl = joinpath(gmsh_root,"lib","gmsh.jl") + if isfile(gmsh_jl) + GMSH_FOUND = true + @info "Using the gmsh Julia API found in $gmsh_jl" + else + @warn """ + gmsh Julia API not found in $gmsh_jl + Make sure that you have installed the full gmsh SDK""" + end end + +open("deps.jl","w") do f + println(f, "# This file is automatically generated") + println(f, "# Do not edit") + println(f) + println(f, :(const GMSH_FOUND = $GMSH_FOUND)) + println(f, :(const gmsh_jl = $gmsh_jl)) +end \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md index ba956d3..7ecc179 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -3,7 +3,7 @@ ## Install ```julia -(v1.4) pkg> add GmshTools +(v1.6) pkg> add GmshTools ``` ## Use Existed Library @@ -18,7 +18,7 @@ julia> Pkg.build("GmshTools") ## SDK Version -We switch to use [Gmsh_SDK_jll](https://github.com/shipengcheng1230/Gmsh_jll.jl/) after *v0.4.0*. +We switch to use [gmsh_jll](https://github.com/JuliaBinaryWrappers/gmsh_jll.jl) after *v0.5.0*. ## Basic Usage diff --git a/src/GmshTools.jl b/src/GmshTools.jl index bc31755..558f2f1 100644 --- a/src/GmshTools.jl +++ b/src/GmshTools.jl @@ -1,21 +1,33 @@ module GmshTools -using Requires +using Libdl -const depsfile = joinpath(@__DIR__, "..", "deps", "deps.jl") -# if isfile(depsfile) -# include(depsfile) -# else -# error("GmshTools is not properly installed. Please run Pkg.build(\"GmshTools\") ", -# "and restart Julia.") -# end +deps_jl = joinpath(@__DIR__, "..", "deps", "deps.jl") +if !isfile(deps_jl) + s = """ + Package GmshTools not installed properly. + Run Pkg.build(\"GridapGmsh\"), restart Julia and try again. + """ + error(s) +end + +include(deps_jl) -function __init__() - # check_deps() - @require Gmsh_SDK_jll="4abbd9bc-5e42-58f8-a031-9aef3230cdd8" begin - isfile(depsfile) || include(joinpath(dirname(@__DIR__), "deps", "build.jl")) - include(depsfile) +if GMSH_FOUND + include(gmsh_jl) + # Hack taken from MPI.jl + function __init__() + @static if Sys.isunix() + Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL) end + end +else + s = """ + Gmsh not found in system paths. + Install Gmsh or export path to Gmsh and rebuild the project. + Run Pkg.build(\"GmshTools\"), restart Julia and try again. + """ + @warn s end export diff --git a/test/runtests.jl b/test/runtests.jl index 4ab0af6..9406e6f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,10 +1,5 @@ using GmshTools using Test -using Pkg - -# temporary solution to bypass General registry -Pkg.add(PackageSpec(url="https://github.com/shipengcheng1230/Gmsh_SDK_jll.jl")) -using Gmsh_SDK_jll try gmsh.initialize()