diff --git a/.travis.yml b/.travis.yml index 4890231..c840a7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,6 @@ jobs: # - conda update -q conda # - conda info -a script: - - julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()));' - - julia --project=docs -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/shipengcheng1230/Gmsh_SDK_jll.jl")); Pkg.build("GmshTools")' + - julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd())); Pkg.build("GmshTools")' - julia --project=docs --color=yes docs/make.jl after_success: skip diff --git a/Project.toml b/Project.toml index 5684997..99ca475 100644 --- a/Project.toml +++ b/Project.toml @@ -7,13 +7,16 @@ version = "0.4.0" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +Requires = "ae029012-a4dd-5104-9daa-d747884805df" [compat] MLStyle = "0.3.1" +Requires = "1.0" julia = "1.3" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [targets] -test = ["Test"] +test = ["Test", "Pkg"] diff --git a/deps/build.jl b/deps/build.jl index 2f0dc9f..a08b64e 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -5,9 +5,6 @@ const depsfile = joinpath(@__DIR__, "deps.jl") const libpath = get(ENV, "GMSH_LIB_PATH", nothing) -Pkg.activate(dirname(@__DIR__)) -Pkg.add(PackageSpec(url="https://github.com/shipengcheng1230/Gmsh_SDK_jll.jl")) - if libpath === nothing open(depsfile, "w") do io print(io, diff --git a/src/GmshTools.jl b/src/GmshTools.jl index 1b37b02..3384f3c 100644 --- a/src/GmshTools.jl +++ b/src/GmshTools.jl @@ -1,43 +1,30 @@ module GmshTools using MLStyle +using Requires 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 +# if isfile(depsfile) +# include(depsfile) +# else +# error("GmshTools is not properly installed. Please run Pkg.build(\"GmshTools\") ", +# "and restart Julia.") +# end function __init__() - check_deps() -end - -export gmsh, @gmsh_do, @gmsh_open - -macro gmsh_do(f) - quote - try - gmsh.initialize() - $(esc(f)) - finally - gmsh.finalize() - end + # check_deps() + @require Gmsh_SDK_jll="4abbd9bc-5e42-58f8-a031-9aef3230cdd8" begin + isfile(depsfile) || include(joinpath(dirname(@__DIR__), "deps", "build.jl")) + include(depsfile) end end -macro gmsh_open(name, f) - quote - try - gmsh.initialize() - gmsh.open($(esc(name))) - $(esc(f)) - finally - gmsh.finalize() - end - end -end +export + gmsh, + match_tuple, + @addField, + @gmsh_do, + @gmsh_open include("macros.jl") diff --git a/src/macros.jl b/src/macros.jl index bff9d88..73906ce 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -1,5 +1,25 @@ -export match_tuple -export @addField +macro gmsh_do(f) + quote + try + gmsh.initialize() + $(esc(f)) + finally + gmsh.finalize() + end + end +end + +macro gmsh_open(name, f) + quote + try + gmsh.initialize() + gmsh.open($(esc(name))) + $(esc(f)) + finally + gmsh.finalize() + end + end +end "To match the tuple expression inside `begin` block and discard the rest." match_tuple = @λ begin diff --git a/test/runtests.jl b/test/runtests.jl index 9406e6f..4ab0af6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,10 @@ 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()