|
|
@ -1,5 +1,3 @@ |
|
|
|
require "ffi-compiler/compile_task" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # @param task [FFI::Compiler::CompileTask] task to configure |
|
|
|
# # @param task [FFI::Compiler::CompileTask] task to configure |
|
|
|
def configure_common_compile_task(task) |
|
|
|
def configure_common_compile_task(task) |
|
|
|
if FileUtils.pwd.include? 'ext' |
|
|
|
if FileUtils.pwd.include? 'ext' |
|
|
@ -49,46 +47,56 @@ def with_generated_files |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
desc "Compile Protobuf library for FFI" |
|
|
|
begin |
|
|
|
namespace "ffi-protobuf" do |
|
|
|
require "ffi-compiler/compile_task" |
|
|
|
with_generated_files do |
|
|
|
|
|
|
|
# Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one |
|
|
|
desc "Compile Protobuf library for FFI" |
|
|
|
# compilation unit. |
|
|
|
namespace "ffi-protobuf" do |
|
|
|
desc "Compile UPB library for FFI" |
|
|
|
with_generated_files do |
|
|
|
namespace "ffi-upb" do |
|
|
|
# Compile Ruby UPB separately in order to limit use of -DUPB_BUILD_API to one |
|
|
|
with_generated_files do |
|
|
|
# compilation unit. |
|
|
|
FFI::Compiler::CompileTask.new('ruby-upb') do |c| |
|
|
|
desc "Compile UPB library for FFI" |
|
|
|
configure_common_compile_task c |
|
|
|
namespace "ffi-upb" do |
|
|
|
c.add_define "UPB_BUILD_API" |
|
|
|
with_generated_files do |
|
|
|
c.exclude << "/glue.c" |
|
|
|
FFI::Compiler::CompileTask.new('ruby-upb') do |c| |
|
|
|
c.exclude << "/shared_message.c" |
|
|
|
configure_common_compile_task c |
|
|
|
c.exclude << "/shared_convert.c" |
|
|
|
c.add_define "UPB_BUILD_API" |
|
|
|
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/ |
|
|
|
c.exclude << "/glue.c" |
|
|
|
c.cflags << "-fvisibility=hidden" |
|
|
|
c.exclude << "/shared_message.c" |
|
|
|
|
|
|
|
c.exclude << "/shared_convert.c" |
|
|
|
|
|
|
|
if RbConfig::CONFIG['target_os'] =~ /darwin|linux/ |
|
|
|
|
|
|
|
c.cflags << "-fvisibility=hidden" |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FFI::Compiler::CompileTask.new 'protobuf_c_ffi' do |c| |
|
|
|
FFI::Compiler::CompileTask.new 'protobuf_c_ffi' do |c| |
|
|
|
configure_common_compile_task c |
|
|
|
configure_common_compile_task c |
|
|
|
# Ruby UPB was already compiled with different flags. |
|
|
|
# Ruby UPB was already compiled with different flags. |
|
|
|
c.exclude << "/range2-neon.c" |
|
|
|
c.exclude << "/range2-neon.c" |
|
|
|
c.exclude << "/range2-sse.c" |
|
|
|
c.exclude << "/range2-sse.c" |
|
|
|
c.exclude << "/naive.c" |
|
|
|
c.exclude << "/naive.c" |
|
|
|
c.exclude << "/ruby-upb.c" |
|
|
|
c.exclude << "/ruby-upb.c" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Setup dependencies so that the .o files generated by building ffi-upb are |
|
|
|
# Setup dependencies so that the .o files generated by building ffi-upb are |
|
|
|
# available to link here. |
|
|
|
# available to link here. |
|
|
|
# TODO Can this be simplified? Can the single shared library be used |
|
|
|
# TODO Can this be simplified? Can the single shared library be used |
|
|
|
# instead of the object files? |
|
|
|
# instead of the object files? |
|
|
|
protobuf_c_task = Rake::Task[:default] |
|
|
|
protobuf_c_task = Rake::Task[:default] |
|
|
|
protobuf_c_shared_lib_task = Rake::Task[protobuf_c_task.prereqs.last] |
|
|
|
protobuf_c_shared_lib_task = Rake::Task[protobuf_c_task.prereqs.last] |
|
|
|
ruby_upb_shared_lib_task = Rake::Task[:"ffi-upb:default"].prereqs.first |
|
|
|
ruby_upb_shared_lib_task = Rake::Task[:"ffi-upb:default"].prereqs.first |
|
|
|
Rake::Task[ruby_upb_shared_lib_task].prereqs.each do |dependency| |
|
|
|
Rake::Task[ruby_upb_shared_lib_task].prereqs.each do |dependency| |
|
|
|
protobuf_c_shared_lib_task.prereqs.prepend dependency |
|
|
|
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 |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|