Check that ffi-compiler loads before using it to define tasks. (#14538)

Fixes #14509

Closes #14538

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/14538 from JasonLunn:fix_14509 a3f9d0bd4f
PiperOrigin-RevId: 577837541
pull/14550/head
Jason Lunn 1 year ago committed by Copybara-Service
parent c9f9d99172
commit 6a16ab6147
  1. 14
      ruby/lib/google/tasks/ffi.rake

@ -1,5 +1,3 @@
require "ffi-compiler/compile_task"
# # @param task [FFI::Compiler::CompileTask] task to configure
def configure_common_compile_task(task)
if FileUtils.pwd.include? 'ext'
@ -49,6 +47,9 @@ def with_generated_files
end
end
begin
require "ffi-compiler/compile_task"
desc "Compile Protobuf library for FFI"
namespace "ffi-protobuf" do
with_generated_files do
@ -91,4 +92,11 @@ namespace "ffi-protobuf" do
end
end
end
rescue LoadError
desc "Compile Protobuf library for FFI"
namespace "ffi-protobuf" do
task :default do
warn "Skipping build of FFI; `gem install ffi-compiler` to enable."
end
end
end

Loading…
Cancel
Save