From e2ab996f7b4f5acfdc0b512aa7500972ef346227 Mon Sep 17 00:00:00 2001 From: Simon Bowly Date: Fri, 26 Apr 2024 13:15:51 +1000 Subject: [PATCH 1/7] Add test for license error message --- test/runtests.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index b5666f7..25ddcfe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -39,3 +39,13 @@ end @testset "grbgetkey" begin @test Gurobi_jll.grbgetkey_path isa String end + +@testset "license_error" begin + envptr = Ref{Ptr{Cvoid}}() + error = @ccall libgurobi.GRBemptyenv(envptr::Ptr{Ptr{Cvoid}})::Cint + @test error == 0 + error = @ccall libgurobi.GRBstartenv(envptr.x::Ptr{Cvoid})::Cint + @test error == 10009 + msg = unsafe_string(@ccall libgurobi.GRBgeterrormsg(envptr.x::Ptr{Cvoid})::Ptr{Cchar}) + @test startswith(msg, "No Gurobi license found") +end From 18af34f6ee1bd1fb795e556da4b992cc937d8f10 Mon Sep 17 00:00:00 2001 From: Simon Bowly Date: Fri, 26 Apr 2024 12:04:26 +1000 Subject: [PATCH 2/7] Delete license file from downloaded artifact --- src/wrappers/aarch64-apple-darwin.jl | 3 +++ src/wrappers/x86_64-apple-darwin.jl | 3 +++ src/wrappers/x86_64-linux-gnu.jl | 3 +++ src/wrappers/x86_64-w64-mingw32.jl | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/wrappers/aarch64-apple-darwin.jl b/src/wrappers/aarch64-apple-darwin.jl index 72e64c3..247e914 100644 --- a/src/wrappers/aarch64-apple-darwin.jl +++ b/src/wrappers/aarch64-apple-darwin.jl @@ -3,6 +3,8 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. +using Artifacts + export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -22,6 +24,7 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") + rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) JLLWrappers.@generate_init_footer() return end # __init__() diff --git a/src/wrappers/x86_64-apple-darwin.jl b/src/wrappers/x86_64-apple-darwin.jl index 72e64c3..247e914 100644 --- a/src/wrappers/x86_64-apple-darwin.jl +++ b/src/wrappers/x86_64-apple-darwin.jl @@ -3,6 +3,8 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. +using Artifacts + export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -22,6 +24,7 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") + rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) JLLWrappers.@generate_init_footer() return end # __init__() diff --git a/src/wrappers/x86_64-linux-gnu.jl b/src/wrappers/x86_64-linux-gnu.jl index a613407..d1e2fe3 100644 --- a/src/wrappers/x86_64-linux-gnu.jl +++ b/src/wrappers/x86_64-linux-gnu.jl @@ -3,6 +3,8 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. +using Artifacts + export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -22,6 +24,7 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") + rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) JLLWrappers.@generate_init_footer() return end # __init__() diff --git a/src/wrappers/x86_64-w64-mingw32.jl b/src/wrappers/x86_64-w64-mingw32.jl index 52cdfc7..54675b3 100644 --- a/src/wrappers/x86_64-w64-mingw32.jl +++ b/src/wrappers/x86_64-w64-mingw32.jl @@ -3,6 +3,8 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. +using Artifacts + export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -24,6 +26,7 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "gurobi_cl.exe") JLLWrappers.@init_executable_product(grbgetkey, "grbgetkey.exe") + rm(joinpath(artifact"Gurobi", "gurobi.lic"), force=true) JLLWrappers.@generate_init_footer() return end # __init__() From f6806c93a9988db8a723456fe1c874b6c20b6ead Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 Apr 2024 17:18:14 +1200 Subject: [PATCH 3/7] Update aarch64-apple-darwin.jl --- src/wrappers/aarch64-apple-darwin.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wrappers/aarch64-apple-darwin.jl b/src/wrappers/aarch64-apple-darwin.jl index 247e914..2140608 100644 --- a/src/wrappers/aarch64-apple-darwin.jl +++ b/src/wrappers/aarch64-apple-darwin.jl @@ -3,8 +3,6 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Artifacts - export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -24,7 +22,10 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") - rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) + gurobi_lic = joinpath(artifact_dir, "lib", "gurobi.lic") + if isfile(gurobi_lic) + rm(gurobi_lic; force = true) + end JLLWrappers.@generate_init_footer() return end # __init__() From dce533e6d326fba673227c7ac7edfe4be46b2378 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 Apr 2024 17:18:53 +1200 Subject: [PATCH 4/7] Update x86_64-apple-darwin.jl --- src/wrappers/x86_64-apple-darwin.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wrappers/x86_64-apple-darwin.jl b/src/wrappers/x86_64-apple-darwin.jl index 247e914..2140608 100644 --- a/src/wrappers/x86_64-apple-darwin.jl +++ b/src/wrappers/x86_64-apple-darwin.jl @@ -3,8 +3,6 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Artifacts - export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -24,7 +22,10 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") - rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) + gurobi_lic = joinpath(artifact_dir, "lib", "gurobi.lic") + if isfile(gurobi_lic) + rm(gurobi_lic; force = true) + end JLLWrappers.@generate_init_footer() return end # __init__() From b8903a0fc2f8fce3c0c7629fedfc59f3dced7ce8 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 Apr 2024 17:21:52 +1200 Subject: [PATCH 5/7] Update x86_64-linux-gnu.jl --- src/wrappers/x86_64-linux-gnu.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wrappers/x86_64-linux-gnu.jl b/src/wrappers/x86_64-linux-gnu.jl index d1e2fe3..fc30098 100644 --- a/src/wrappers/x86_64-linux-gnu.jl +++ b/src/wrappers/x86_64-linux-gnu.jl @@ -3,8 +3,6 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Artifacts - export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -24,7 +22,10 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "bin/gurobi_cl") JLLWrappers.@init_executable_product(grbgetkey, "bin/grbgetkey") - rm(joinpath(artifact"Gurobi", "lib/gurobi.lic"), force=true) + gurobi_lic = joinpath(artifact_dir, "lib", "gurobi.lic") + if isfile(gurobi_lic) + rm(gurobi_lic; force = true) + end JLLWrappers.@generate_init_footer() return end # __init__() From 5f9cf5ddd4220a132b17aeb49a8d1ff78091f6d4 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 Apr 2024 17:22:38 +1200 Subject: [PATCH 6/7] Update x86_64-w64-mingw32.jl --- src/wrappers/x86_64-w64-mingw32.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wrappers/x86_64-w64-mingw32.jl b/src/wrappers/x86_64-w64-mingw32.jl index 54675b3..52d6f45 100644 --- a/src/wrappers/x86_64-w64-mingw32.jl +++ b/src/wrappers/x86_64-w64-mingw32.jl @@ -3,8 +3,6 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Artifacts - export gurobi_cl, grbgetkey, libgurobi JLLWrappers.@generate_wrapper_header("Gurobi") @@ -26,7 +24,10 @@ function __init__() ) JLLWrappers.@init_executable_product(gurobi_cl, "gurobi_cl.exe") JLLWrappers.@init_executable_product(grbgetkey, "grbgetkey.exe") - rm(joinpath(artifact"Gurobi", "gurobi.lic"), force=true) + gurobi_lic = joinpath(artifact_dir, "gurobi.lic") + if isfile(gurobi_lic) + rm(gurobi_lic; force = true) + end JLLWrappers.@generate_init_footer() return end # __init__() From 8d0833d4f78b554fcc8c6d364a851d343b1c6bdd Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 26 Apr 2024 17:30:42 +1200 Subject: [PATCH 7/7] Apply suggestions from code review --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 25ddcfe..2b7b6eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,8 +44,8 @@ end envptr = Ref{Ptr{Cvoid}}() error = @ccall libgurobi.GRBemptyenv(envptr::Ptr{Ptr{Cvoid}})::Cint @test error == 0 - error = @ccall libgurobi.GRBstartenv(envptr.x::Ptr{Cvoid})::Cint + error = @ccall libgurobi.GRBstartenv(envptr[]::Ptr{Cvoid})::Cint @test error == 10009 - msg = unsafe_string(@ccall libgurobi.GRBgeterrormsg(envptr.x::Ptr{Cvoid})::Ptr{Cchar}) + msg = unsafe_string(@ccall libgurobi.GRBgeterrormsg(envptr[]::Ptr{Cvoid})::Ptr{Cchar}) @test startswith(msg, "No Gurobi license found") end