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. 18
      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,8 +47,11 @@ def with_generated_files
end
end
desc "Compile Protobuf library for FFI"
namespace "ffi-protobuf" do
begin
require "ffi-compiler/compile_task"
desc "Compile Protobuf library for FFI"
namespace "ffi-protobuf" do
with_generated_files do
# Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one
# compilation unit.
@ -90,5 +91,12 @@ namespace "ffi-protobuf" do
protobuf_c_shared_lib_task.prereqs.prepend dependency
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