From 2f8b20eeb44c840b59df2960409bd4fec7ef210d Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 13:52:54 +0100 Subject: [PATCH 01/18] Allowing for custom installations of gmsh via Preferences.jl --- Project.toml | 2 + src/Gmsh.jl | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index b7179a2..229a04b 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,11 @@ authors = ["Jukka Aho "] version = "0.3.1" [deps] +Preferences = "21216c6a-2e73-6563-6e65-726566657250" gmsh_jll = "630162c2-fc9b-58b3-9910-8442a8a132e6" [compat] +Preferences = "1" gmsh_jll = "4.11" julia = "1" diff --git a/src/Gmsh.jl b/src/Gmsh.jl index 9691051..33cd8b5 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -1,7 +1,119 @@ module Gmsh -import gmsh_jll -include(gmsh_jll.gmsh_api) +# The logic behind the preferences is inspired by the one found in PetscCall.jl + +gmsh_provider = @load_preference("gmsh_provider","gmsh_jll"), + +if gmsh_provider ∉ ("gmsh_jll","system") + error("gmsh_provider is either gmsh_jll or system") +end + +@static if gmsh_provider == "gmsh_jll" + import gmsh_jll + gmsh_jl_path = gmsh_jll.gmsh_api +end + +@static if gmsh_provider == "system" + gmsh_jl_path = @load_preference("gmsh_jl_path","") + if gmsh_jl_path == "" + error("Using a system gmsh installation but gmsh_jl_path not found in Preferences.toml file") + end +end + +include(gmsh_jl_path) + +@static if gmsh_provider == "system" + # The definition of __init__ is taken from GridapGmsh.jl + function __init__() + @static if Sys.isunix() + Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL) + end + end +end + +""" + Gmsh.use_gmsh_jll() + +Configure Gmsh to use the binary provided by gmsh_jll. +""" +function use_gmsh_jll() + gmsh_provider = "gmsh_jll" + @set_preferences!( + "gmsh_provider"=>gmsh_provider, + ) + msg = """ + Gmsh preferences changed! + The new preferences are: + gmsh_provider = $(gmsh_provider) + Restart Julia for these changes to take effect. + """ + @info msg + nothing +end + +""" + Gmsh.use_system_gmsh([;gmsh_jl_path]) + +Configure Gmsh to use the binary provided by a system installation. +Key-word argument `gmsh_jl_path` contains the full path to `gmsh.jl`, the file containing +the Julia API of gmsh. This file needs to be installed as part of the SDK of gmsh. +If `gmsh_jl_path` is omitted, this function will look for `gmsh.jl` in `LD_LIBRARY_PATH`. +""" +function use_system_gmsh(;gmsh_jl_path=nothing) + function findindir(route,fn) + files = readdir(route,join=false) + for file in files + if file == fn + gmsh_jl_path = joinpath(route,file) + return gmsh_jl_path + end + end + nothing + end + if gmsh_jl_path === nothing + if haskey(ENV,"LD_LIBRARY_PATH") && ENV["LD_LIBRARY_PATH"] != "" + routes = split(ENV["LD_LIBRARY_PATH"],':') + for route in routes + gmsh_jl_path = findindir(route,"gmsh.jl") + if gmsh_jl_path !== nothing + @info "Gmsh Julia API found in the system at $(gmsh_jl_path)." + break + end + end + end + end + if gmsh_jl_path === nothing + msg = """ + Unable to find a Gmsh installation in the system. + + We looked for the Gmsh Julia API file gmsh.jl in the folders in LD_LIBRARY_PATH. + + You can also manualy specify the route with the key-word argument gmsh_jl_path. + + Example + ======= + + julia> using Gmsh + julia> using Gmsh.use_system_gmsh(;gmsh_jl_path="path/to/gmsh.jl") + """ + error(msg) + end + gmsh_provider = "system" + @set_preferences!( + "gmsh_provider"=>gmsh_provider, + "gmsh_jl_path"=>gmsh_jl_path, + ) + msg = """ + Gmsh preferences changed! + The new preferences are: + gmsh_provider = $(gmsh_provider) + gmsh_jl_path = $(gmsh_jl_path) + Restart Julia for these changes to take effect. + """ + @info msg + nothing +end + import .gmsh export gmsh From 26ac3e7461c7270e2973c18f51f95988a4ff76e4 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 16:00:25 +0100 Subject: [PATCH 02/18] Recover default behavior for julia < 1.6 --- Project.toml | 1 + src/Gmsh.jl | 166 ++++++++++++++++++++++++++++----------------------- 2 files changed, 91 insertions(+), 76 deletions(-) diff --git a/Project.toml b/Project.toml index 229a04b..a9fcccb 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["Jukka Aho "] version = "0.3.1" [deps] +Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" Preferences = "21216c6a-2e73-6563-6e65-726566657250" gmsh_jll = "630162c2-fc9b-58b3-9910-8442a8a132e6" diff --git a/src/Gmsh.jl b/src/Gmsh.jl index 33cd8b5..f967c70 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -1,8 +1,16 @@ module Gmsh -# The logic behind the preferences is inspired by the one found in PetscCall.jl +@static if VERSION >= v"1.6" + using Preferences +end -gmsh_provider = @load_preference("gmsh_provider","gmsh_jll"), +@static if VERSION >= v"1.6" + gmsh_provider = @load_preference("gmsh_provider","gmsh_jll") +else + gmsh_provider = "gmsh_jll" +end + +# The logic behind the preferences is inspired by the one found in PetscCall.jl if gmsh_provider ∉ ("gmsh_jll","system") error("gmsh_provider is either gmsh_jll or system") @@ -10,19 +18,21 @@ end @static if gmsh_provider == "gmsh_jll" import gmsh_jll - gmsh_jl_path = gmsh_jll.gmsh_api + gmsh_api = gmsh_jll.gmsh_api end @static if gmsh_provider == "system" - gmsh_jl_path = @load_preference("gmsh_jl_path","") - if gmsh_jl_path == "" - error("Using a system gmsh installation but gmsh_jl_path not found in Preferences.toml file") + gmsh_jl_dir = @load_preference("gmsh_jl_dir","") + if gmsh_jl_dir == "" + error("Using a system gmsh installation but gmsh_jl_dir not found in Preferences.toml file") end + gmsh_api = joinpath(gmsh_jl_dir,"gmsh.jl") end -include(gmsh_jl_path) +include(gmsh_api) @static if gmsh_provider == "system" + using Libdl # The definition of __init__ is taken from GridapGmsh.jl function __init__() @static if Sys.isunix() @@ -31,87 +41,91 @@ include(gmsh_jl_path) end end -""" - Gmsh.use_gmsh_jll() +@static if VERSION >= v"1.6" + """ + Gmsh.use_gmsh_jll() -Configure Gmsh to use the binary provided by gmsh_jll. -""" -function use_gmsh_jll() - gmsh_provider = "gmsh_jll" - @set_preferences!( - "gmsh_provider"=>gmsh_provider, - ) - msg = """ - Gmsh preferences changed! - The new preferences are: - gmsh_provider = $(gmsh_provider) - Restart Julia for these changes to take effect. + Configure Gmsh to use the binary provided by gmsh_jll. """ - @info msg - nothing + function use_gmsh_jll() + gmsh_provider = "gmsh_jll" + @set_preferences!( + "gmsh_provider"=>gmsh_provider, + ) + msg = """ + Gmsh preferences changed! + The new preferences are: + gmsh_provider = $(gmsh_provider) + Restart Julia for these changes to take effect. + """ + @info msg + nothing + end end -""" - Gmsh.use_system_gmsh([;gmsh_jl_path]) - -Configure Gmsh to use the binary provided by a system installation. -Key-word argument `gmsh_jl_path` contains the full path to `gmsh.jl`, the file containing -the Julia API of gmsh. This file needs to be installed as part of the SDK of gmsh. -If `gmsh_jl_path` is omitted, this function will look for `gmsh.jl` in `LD_LIBRARY_PATH`. -""" -function use_system_gmsh(;gmsh_jl_path=nothing) - function findindir(route,fn) - files = readdir(route,join=false) - for file in files - if file == fn - gmsh_jl_path = joinpath(route,file) - return gmsh_jl_path +@static if VERSION >= v"1.6" + """ + Gmsh.use_system_gmsh([;gmsh_jl_dir]) + + Configure Gmsh to use the binary provided by a system installation. + Key-word argument `gmsh_jl_dir` contains the path of the directory containing `gmsh.jl`, the file with + the Julia API of gmsh. This file needs to be installed as part of the SDK of gmsh. + If `gmsh_jl_dir` is omitted, this function will look for `gmsh.jl` in `LD_LIBRARY_PATH`. + """ + function use_system_gmsh(;gmsh_jl_dir=nothing) + function findindir(route,fn) + files = readdir(route,join=false) + for file in files + if file == fn + gmsh_jl_dir = joinpath(route,file) + return gmsh_jl_dir + end end + nothing end - nothing - end - if gmsh_jl_path === nothing - if haskey(ENV,"LD_LIBRARY_PATH") && ENV["LD_LIBRARY_PATH"] != "" - routes = split(ENV["LD_LIBRARY_PATH"],':') - for route in routes - gmsh_jl_path = findindir(route,"gmsh.jl") - if gmsh_jl_path !== nothing - @info "Gmsh Julia API found in the system at $(gmsh_jl_path)." - break + if gmsh_jl_dir === nothing + if haskey(ENV,"LD_LIBRARY_PATH") && ENV["LD_LIBRARY_PATH"] != "" + routes = split(ENV["LD_LIBRARY_PATH"],':') + for route in routes + gmsh_jl_dir = findindir(route,"gmsh.jl") + if gmsh_jl_dir !== nothing + @info "Gmsh Julia API found in the system at $(gmsh_jl_dir)." + break + end end end end - end - if gmsh_jl_path === nothing + if gmsh_jl_dir === nothing + msg = """ + Unable to find a Gmsh installation in the system. + + We looked for the Gmsh Julia API file gmsh.jl in the folders in LD_LIBRARY_PATH. + + You can also manualy specify the route with the key-word argument gmsh_jl_dir. + + Example + ======= + + julia> using Gmsh + julia> using Gmsh.use_system_gmsh(;gmsh_jl_dir="path/to/gmsh.jl") + """ + error(msg) + end + gmsh_provider = "system" + @set_preferences!( + "gmsh_provider"=>gmsh_provider, + "gmsh_jl_dir"=>gmsh_jl_dir, + ) msg = """ - Unable to find a Gmsh installation in the system. - - We looked for the Gmsh Julia API file gmsh.jl in the folders in LD_LIBRARY_PATH. - - You can also manualy specify the route with the key-word argument gmsh_jl_path. - - Example - ======= - - julia> using Gmsh - julia> using Gmsh.use_system_gmsh(;gmsh_jl_path="path/to/gmsh.jl") + Gmsh preferences changed! + The new preferences are: + gmsh_provider = $(gmsh_provider) + gmsh_jl_dir = $(gmsh_jl_dir) + Restart Julia for these changes to take effect. """ - error(msg) + @info msg + nothing end - gmsh_provider = "system" - @set_preferences!( - "gmsh_provider"=>gmsh_provider, - "gmsh_jl_path"=>gmsh_jl_path, - ) - msg = """ - Gmsh preferences changed! - The new preferences are: - gmsh_provider = $(gmsh_provider) - gmsh_jl_path = $(gmsh_jl_path) - Restart Julia for these changes to take effect. - """ - @info msg - nothing end import .gmsh From d6221ebbe1b37062f9161ae16e96ad20bcd27634 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:07:57 +0100 Subject: [PATCH 03/18] Fixing documentation --- src/Gmsh.jl | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index f967c70..40e4cbe 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -41,13 +41,13 @@ include(gmsh_api) end end -@static if VERSION >= v"1.6" - """ - Gmsh.use_gmsh_jll() +""" + Gmsh.use_gmsh_jll() - Configure Gmsh to use the binary provided by gmsh_jll. - """ - function use_gmsh_jll() +Configure Gmsh to use the binary provided by gmsh_jll. +""" +function use_gmsh_jll() + @static if VERSION >= v"1.6" gmsh_provider = "gmsh_jll" @set_preferences!( "gmsh_provider"=>gmsh_provider, @@ -59,20 +59,20 @@ end Restart Julia for these changes to take effect. """ @info msg - nothing end + nothing end -@static if VERSION >= v"1.6" - """ - Gmsh.use_system_gmsh([;gmsh_jl_dir]) - - Configure Gmsh to use the binary provided by a system installation. - Key-word argument `gmsh_jl_dir` contains the path of the directory containing `gmsh.jl`, the file with - the Julia API of gmsh. This file needs to be installed as part of the SDK of gmsh. - If `gmsh_jl_dir` is omitted, this function will look for `gmsh.jl` in `LD_LIBRARY_PATH`. - """ - function use_system_gmsh(;gmsh_jl_dir=nothing) +""" + Gmsh.use_system_gmsh([;gmsh_jl_dir]) + +Configure Gmsh to use the binary provided by a system installation. +Key-word argument `gmsh_jl_dir` contains the path of the directory containing `gmsh.jl`, the file with +the Julia API of gmsh. This file needs to be installed as part of the SDK of gmsh. +If `gmsh_jl_dir` is omitted, this function will look for `gmsh.jl` in `LD_LIBRARY_PATH`. +""" +function use_system_gmsh(;gmsh_jl_dir=nothing) + @static if VERSION >= v"1.6" function findindir(route,fn) files = readdir(route,join=false) for file in files @@ -98,14 +98,14 @@ end if gmsh_jl_dir === nothing msg = """ Unable to find a Gmsh installation in the system. - + We looked for the Gmsh Julia API file gmsh.jl in the folders in LD_LIBRARY_PATH. - + You can also manualy specify the route with the key-word argument gmsh_jl_dir. - + Example ======= - + julia> using Gmsh julia> using Gmsh.use_system_gmsh(;gmsh_jl_dir="path/to/gmsh.jl") """ @@ -119,13 +119,13 @@ end msg = """ Gmsh preferences changed! The new preferences are: - gmsh_provider = $(gmsh_provider) - gmsh_jl_dir = $(gmsh_jl_dir) + gmsh_provider = $(gmsh_provider) + gmsh_jl_dir = $(gmsh_jl_dir) Restart Julia for these changes to take effect. """ @info msg - nothing end + nothing end import .gmsh From 281cff7e08b0f0425a5353226208727cf576dcb6 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:15:10 +0100 Subject: [PATCH 04/18] Testing custom installation in CI --- .github/workflows/CI.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 589aa49..742a911 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -36,3 +36,28 @@ jobs: - uses: codecov/codecov-action@v1 with: file: lcov.info + name: Custom Gmsh installation with Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - '1' + os: + - ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + - uses: julia-actions/julia-buildpkg@v1 + - run: curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz + - run: tar xvf gmsh-4.12.2-Linux64-sdk.tgz + - run: | + julia --project=. -e ' + using Gmsh + using Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") ' + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info From 31b19467e999f9ad0d0074a93ccadfd2de2b4018 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:16:46 +0100 Subject: [PATCH 05/18] Minor to trigger CI --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 742a911..9663b5a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,8 @@ jobs: - run: | julia --project=. -e ' using Gmsh - using Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") ' + using Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") + ' - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v1 From 856775d87592e8a4c76aed6d83a94f3251c5f090 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:17:57 +0100 Subject: [PATCH 06/18] Fix CI --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9663b5a..15ddbed 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -36,6 +36,7 @@ jobs: - uses: codecov/codecov-action@v1 with: file: lcov.info + test-custom-gmsh: name: Custom Gmsh installation with Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} strategy: From 2d9d9a0552816c9280945eb16d8ea7bc9b89ec78 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:19:49 +0100 Subject: [PATCH 07/18] Typo in CI --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 15ddbed..addf543 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -56,7 +56,7 @@ jobs: - run: | julia --project=. -e ' using Gmsh - using Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") + Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") ' - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 From ec13df6bd09416363f3b1054491359a2fc186934 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Mar 2024 18:21:50 +0100 Subject: [PATCH 08/18] Another typo in CI --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index addf543..e125a63 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -56,7 +56,7 @@ jobs: - run: | julia --project=. -e ' using Gmsh - Gmsh.use_system_binary(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") + Gmsh.use_system_gmsh(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") ' - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 From b0e0983bd1231403656db3ec62624c83987d3397 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 09:20:52 +0100 Subject: [PATCH 09/18] Enhancing CI --- .github/workflows/CI.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e125a63..818861d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,7 +37,7 @@ jobs: with: file: lcov.info test-custom-gmsh: - name: Custom Gmsh installation with Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} + name: Custom Gmsh with Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -51,13 +51,16 @@ jobs: with: version: ${{ matrix.version }} - uses: julia-actions/julia-buildpkg@v1 - - run: curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz - - run: tar xvf gmsh-4.12.2-Linux64-sdk.tgz - - run: | - julia --project=. -e ' + - name: install gmsh sdk + run: | + curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz + tar xvf gmsh-4.12.2-Linux64-sdk.tgz + mv gmsh-4.12.2-Linux64-sdk /opt/ + - name: configure Gmsh preferences + shell: julia --color=yes --project=. {0} + run: | using Gmsh - Gmsh.use_system_gmsh(;gmsh_jl_dir="gmsh-4.12.2-Linux64-sdk/lib") - ' + Gmsh.use_system_gmsh(;gmsh_jl_dir="/opt/gmsh-4.12.2-Linux64-sdk/lib") - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v1 From 4152de30bdef81c3952f357b5caf2532a76f7b54 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 09:25:37 +0100 Subject: [PATCH 10/18] CI debug --- src/Gmsh.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index 40e4cbe..8a1c6d9 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -35,6 +35,7 @@ include(gmsh_api) using Libdl # The definition of __init__ is taken from GridapGmsh.jl function __init__() + @show Sys.isunix() @static if Sys.isunix() Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL) end From 6885afc00a34032014e9fe5e6fcb8a25abb64b37 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 09:41:24 +0100 Subject: [PATCH 11/18] Debug ci --- .github/workflows/CI.yml | 6 +++--- src/Gmsh.jl | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 818861d..f7c966c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,7 +37,7 @@ jobs: with: file: lcov.info test-custom-gmsh: - name: Custom Gmsh with Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} + name: Gmsh SDK - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -51,12 +51,12 @@ jobs: with: version: ${{ matrix.version }} - uses: julia-actions/julia-buildpkg@v1 - - name: install gmsh sdk + - name: Install Gmsh SDK run: | curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz tar xvf gmsh-4.12.2-Linux64-sdk.tgz mv gmsh-4.12.2-Linux64-sdk /opt/ - - name: configure Gmsh preferences + - name: Configure Gmsh preferences shell: julia --color=yes --project=. {0} run: | using Gmsh diff --git a/src/Gmsh.jl b/src/Gmsh.jl index 8a1c6d9..7ee6b6f 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -18,26 +18,28 @@ end @static if gmsh_provider == "gmsh_jll" import gmsh_jll - gmsh_api = gmsh_jll.gmsh_api + const gmsh_api = gmsh_jll.gmsh_api end @static if gmsh_provider == "system" - gmsh_jl_dir = @load_preference("gmsh_jl_dir","") + const gmsh_jl_dir = @load_preference("gmsh_jl_dir","") if gmsh_jl_dir == "" error("Using a system gmsh installation but gmsh_jl_dir not found in Preferences.toml file") end - gmsh_api = joinpath(gmsh_jl_dir,"gmsh.jl") + const gmsh_api = joinpath(gmsh_jl_dir,"gmsh.jl") end include(gmsh_api) +import .gmsh +export gmsh @static if gmsh_provider == "system" using Libdl # The definition of __init__ is taken from GridapGmsh.jl function __init__() - @show Sys.isunix() @static if Sys.isunix() Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL) + println("gmsh.lib loaded") end end end @@ -129,9 +131,6 @@ function use_system_gmsh(;gmsh_jl_dir=nothing) nothing end -import .gmsh -export gmsh - """ Gmsh.initialize(argv=String[]; finalize_atexit=true) @@ -179,4 +178,4 @@ function finalize() end end -end +end # module From 0fb22da25e20768ce00fecd984c80bbd5940ff9a Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 09:52:33 +0100 Subject: [PATCH 12/18] debug ci --- src/Gmsh.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index 7ee6b6f..d9ea9bd 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -35,11 +35,9 @@ export gmsh @static if gmsh_provider == "system" using Libdl - # The definition of __init__ is taken from GridapGmsh.jl function __init__() @static if Sys.isunix() - Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL) - println("gmsh.lib loaded") + Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) end end end From 8c374a806ef9624361e3c9fa326b9e4c45a829be Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 10:07:25 +0100 Subject: [PATCH 13/18] debug ci --- src/Gmsh.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index d9ea9bd..c900101 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -33,14 +33,14 @@ include(gmsh_api) import .gmsh export gmsh -@static if gmsh_provider == "system" - using Libdl - function __init__() - @static if Sys.isunix() - Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) - end - end -end +#@static if gmsh_provider == "system" +# using Libdl +# function __init__() +# @static if Sys.isunix() +# Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) +# end +# end +#end """ Gmsh.use_gmsh_jll() From 0eb7cff168b4853b047062a74058b6a3a7421c5a Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 10:19:14 +0100 Subject: [PATCH 14/18] debug ci --- src/Gmsh.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index c900101..ebf24ea 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -33,14 +33,15 @@ include(gmsh_api) import .gmsh export gmsh -#@static if gmsh_provider == "system" -# using Libdl -# function __init__() -# @static if Sys.isunix() -# Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) -# end -# end -#end +@static if gmsh_provider == "system" + using Libdl + function __init__() + @static if Sys.isunix() + @show gmsh.lib + Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) + end + end +end """ Gmsh.use_gmsh_jll() From 91d42a9ce75abcb28a44b9ba6a4f4a8510434056 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 10:28:05 +0100 Subject: [PATCH 15/18] debug ci --- src/Gmsh.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index ebf24ea..dc3aabc 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -37,8 +37,12 @@ export gmsh using Libdl function __init__() @static if Sys.isunix() + @show gmsh.libdir + @show gmsh.libname @show gmsh.lib - Libdl.dlopen(gmsh.lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) + gmsh_lib = joinpath(gmsh_jl_dir,"libgmsh.so") + @show gmsh_lib + Libdl.dlopen(gmsh_lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) end end end From 508f90fe872b4c7f6aa7069119cffe483edb5d0f Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 10:36:52 +0100 Subject: [PATCH 16/18] debug ci --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f7c966c..16b256f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -51,6 +51,8 @@ jobs: with: version: ${{ matrix.version }} - uses: julia-actions/julia-buildpkg@v1 + - name: Install Gmsh SDK dependencies + run: sudo apt-get install -y libglu1-mesa - name: Install Gmsh SDK run: | curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz From a5900ab030c20cbdc82a8046561be4af1daf2e8f Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 10:37:44 +0100 Subject: [PATCH 17/18] debug ci --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 16b256f..85577d9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -52,7 +52,7 @@ jobs: version: ${{ matrix.version }} - uses: julia-actions/julia-buildpkg@v1 - name: Install Gmsh SDK dependencies - run: sudo apt-get install -y libglu1-mesa + run: sudo apt-get install -y libglu1-mesa - name: Install Gmsh SDK run: | curl -OL https://gmsh.info/bin/Linux/gmsh-4.12.2-Linux64-sdk.tgz From a469cde975ba6dd046c8e64d53b675a18b29e972 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Mar 2024 11:09:52 +0100 Subject: [PATCH 18/18] Fix CI --- src/Gmsh.jl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Gmsh.jl b/src/Gmsh.jl index dc3aabc..3c9956e 100644 --- a/src/Gmsh.jl +++ b/src/Gmsh.jl @@ -36,13 +36,15 @@ export gmsh @static if gmsh_provider == "system" using Libdl function __init__() + # This is just to have a better idea why gmsh.lib is empty @static if Sys.isunix() - @show gmsh.libdir - @show gmsh.libname - @show gmsh.lib - gmsh_lib = joinpath(gmsh_jl_dir,"libgmsh.so") - @show gmsh_lib - Libdl.dlopen(gmsh_lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) + if gmsh.lib == "" + gmsh_lib = joinpath(gmsh_jl_dir,"libgmsh") + Libdl.dlopen(gmsh_lib, Libdl.RTLD_LAZY | Libdl.RTLD_DEEPBIND) + end + end + if gmsh.lib == "" + error("The gmsh.jl API file was not able to find a gmsh libary. Some dependencies are provably not installed in the system.") end end end