Skip to content

Commit

Permalink
Adapt the layout for usage of rake-compiler and allowing gem creation
Browse files Browse the repository at this point in the history
  • Loading branch information
2maz committed Jan 9, 2014
1 parent 7f3e539 commit f8f86c1
Show file tree
Hide file tree
Showing 24 changed files with 83 additions and 90 deletions.
Empty file added .gemtest
Empty file.
38 changes: 19 additions & 19 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ lib/orocos/uri.rb
lib/orocos/async.rb
lib/orocos/logging.rb
lib/orocos/scripts.rb
lib/orocos/roby/gui/orocos_composer_ui.rb
lib/orocos/ros.rb
lib/orocos/ros/async.rb
lib/orocos/ros/rpc.rb
Expand Down Expand Up @@ -167,21 +166,22 @@ lib/orocos/corba.rb
lib/orocos/ports.rb
lib/orocos/mqueue.rb
lib/orocos.rb
ext/corba.cc
ext/datahandling.cc
ext/operations.cc
ext/rblocking_call.h
ext/FindRTTPlugin.cmake
ext/ros.cc
ext/CMakeLists.txt
ext/RubyExtensions.cmake
ext/datahandling.hh
ext/corba.hh
ext/rorocos.hh
ext/ruby_task_context.hh
ext/rorocos.cc
ext/lib/corba_name_service_client.cc
ext/lib/corba_name_service_client.hh
ext/FindRuby.cmake
ext/LibFindMacros.cmake
ext/ruby_task_context.cc
ext/rorocos/corba.cc
ext/rorocos/datahandling.cc
ext/rorocos/operations.cc
ext/rorocos/rblocking_call.h
ext/rorocos/FindRTTPlugin.cmake
ext/rorocos/ros.cc
ext/rorocos/CMakeLists.txt
ext/rorocos/extconf.rb
ext/rorocos/RubyExtensions.cmake
ext/rorocos/datahandling.hh
ext/rorocos/corba.hh
ext/rorocos/rorocos.hh
ext/rorocos/ruby_task_context.hh
ext/rorocos/rorocos.cc
ext/rorocos/lib/corba_name_service_client.cc
ext/rorocos/lib/corba_name_service_client.hh
ext/rorocos/FindRuby.cmake
ext/rorocos/LibFindMacros.cmake
ext/rorocos/ruby_task_context.cc
100 changes: 38 additions & 62 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
require 'rake'
require 'rake/extensiontask'
require './lib/orocos/version'
require 'utilrb/doc/rake'

hoe_spec = nil

begin
require 'hoe'
Hoe::plugin :yard

namespace 'dist' do
config = Hoe.spec('orocos.rb') do |p|
self.developer("Sylvain Joyeux", "[email protected]")

self.summary = 'Controlling Orocos modules from Ruby'
self.description = paragraphs_of('README.markdown', 3..5).join("\n\n")
self.urls = ["http://doudou.github.com/orocos-rb", "http://github.com/doudou/orocos.rb.git"]
self.changes = ""
licenses << "GPL v2 or later"
hoe_spec = Hoe.spec('orocos.rb') do |p|
self.developer("Sylvain Joyeux", "[email protected]")

self.extra_deps <<
['utilrb', ">= 1.1"] <<
['rake', ">= 0.8"] <<
["hoe-yard", ">= 0.1.2"]
self.summary = 'Controlling Orocos modules from Ruby'
self.description = paragraphs_of('README.markdown', 3..5).join("\n\n")
self.urls = ["http://doudou.github.com/orocos-rb", "http://github.com/doudou/orocos.rb.git"]
self.changes = ""
licenses << "GPL v2 or later"

#self.spec.extra_rdoc_files.reject! { |file| file =~ /Make/ }
#self.spec.extensions << 'ext/extconf.rb'
end

Rake.clear_tasks(/dist:(re|clobber_|)docs/)
self.extra_deps <<
['utilrb', ">= 1.1"] <<
['rake', ">= 0.8"] <<
["rake-compiler", "~> 0.8.0"] <<
["hoe-yard", ">= 0.1.2"]
end

rescue LoadError
Expand All @@ -46,28 +42,30 @@ def build_orogen(name)
Orocos::Rake.generate_and_build File.join(data_dir, name, "#{name}.orogen"), work_dir
end

task :default => ["setup:ext", "setup:uic"]

namespace :setup do
desc "builds Orocos.rb C extension"
task :ext do
builddir = File.join('ext', 'build')
prefix = File.join(Dir.pwd, 'ext')

FileUtils.mkdir_p builddir
orocos_target = ENV['OROCOS_TARGET'] || 'gnulinux'
Dir.chdir(builddir) do
FileUtils.rm_f "CMakeCache.txt"
if !system("cmake", "-DRUBY_PROGRAM_NAME=#{FileUtils::RUBY}", "-DCMAKE_INSTALL_PREFIX=#{prefix}", "-DOROCOS_TARGET=#{orocos_target}", "-DCMAKE_BUILD_TYPE=Debug", "..")
raise "unable to configure the extension using CMake"
end
Rake.clear_tasks(/^default$/)
task :default => ["setup:ext", "setup:uic"]

if !system("make") || !system("make", "install")
throw "unable to build the extension"
end
end
FileUtils.ln_sf "../ext/rorocos_ext.so", "lib/rorocos_ext.so"
# Leave in top level namespace to allow rake-compiler to build native gem: 'rake native gem'
desc "builds Orocos.rb C extension"
rorocos_task = Rake::ExtensionTask.new('rorocos', hoe_spec.spec) do |ext|
# Same info as in ext/rocoros/extconf.rb where cmake
# is used to generate the Makefile
ext.name = "rorocos"
ext.ext_dir = "ext/rorocos"
ext.lib_dir = "lib/orocos"
ext.tmp_dir = "ext/build"
ext.gem_spec = hoe_spec.spec
ext.source_pattern = "*.{c,cpp,cc}"

if not Dir.exists?(ext.tmp_dir)
FileUtils.mkdir_p ext.tmp_dir
end
end

namespace :setup do
# Rake-compiler provides task: 'compile'
task :ext => :compile

desc "builds the oroGen modules that are needed by the tests"
task :orogen_all do
Expand Down Expand Up @@ -120,29 +118,7 @@ namespace :setup do
end
end
task :setup => "setup:ext"
desc "remove by-products of setup"
task :clean do
FileUtils.rm_rf "ext/build"
FileUtils.rm_rf "ext/rorocos_ext.so"
FileUtils.rm_rf "lib/rorocos_ext.so"
FileUtils.rm_rf "test/working_copy"
end

if Utilrb.doc?
namespace 'doc' do
Utilrb.doc 'api', :include => ['lib/**/*.rb'],
:exclude => [],
:target_dir => 'doc',
:title => 'orocos.rb'

# desc 'generate all documentation'
# task 'all' => 'doc:api'
end

task 'redocs' => 'doc:reapi'
task 'doc' => 'doc:api'
task 'docs' => 'doc'
else
STDERR.puts "WARN: cannot load yard or rdoc , documentation generation disabled"
end
# Add removal of by-products of test setup to the clean task
CLEAN.include("test/working_copy")

9 changes: 5 additions & 4 deletions ext/CMakeLists.txt → ext/rorocos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,20 @@ ENDMACRO(OMNIORB)
link_directories(${RTT_ROS_LIBRARY_DIRS})

OMNIORB()
ADD_RUBY_EXTENSION(rorocos_ext
SET(EXTENSION_NAME rorocos)
ADD_RUBY_EXTENSION(${EXTENSION_NAME}
ruby_task_context.cc rorocos.cc corba.cc datahandling.cc operations.cc
lib/corba_name_service_client.cc ${ORB_IDL_FILES} ${ROS_FILES})
target_link_libraries(rorocos_ext ${ORB_LIBRARIES} ${RTT_LIBRARIES}
target_link_libraries(${EXTENSION_NAME} ${ORB_LIBRARIES} ${RTT_LIBRARIES}
${RTT_CORBA_LIBRARIES} ${TYPELIB_LIBRARIES}
${RTT_PLUGIN_rtt-typekit_LIBRARY}
${RTT_PLUGIN_rtt-transport-corba_LIBRARY}
${RTT_Typelib_LIBRARIES}
${RTT_ROS_LIBRARIES})
if (RTT_MQUEUE_FOUND)
target_link_libraries(rorocos_ext
target_link_libraries(${EXTENSION_NAME}
${RTT_PLUGIN_rtt-transport-mqueue_LIBRARY})
endif()

INSTALL(TARGETS rorocos_ext LIBRARY DESTINATION ".")
INSTALL(TARGETS ${EXTENSION_NAME} LIBRARY DESTINATION ".")

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions ext/rorocos/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'rake'

name = "rorocos"
ext_dir = "ext/rorocos"
lib_dir = "lib/orocos"
# Use absolute main package directory as starting point, since rake-compiler uses a build directory which depends on the system architecture and ruby version
main_dir = File.join(File.dirname(__FILE__),"..","..")


orocos_target = ENV['OROCOS_TARGET'] || 'gnulinux'
FileUtils.rm_f "CMakeCache.txt"
if !system("cmake", "-DRUBY_PROGRAM_NAME=#{FileUtils::RUBY}", "-DCMAKE_INSTALL_PREFIX=#{File.join(main_dir,lib_dir)}", "-DOROCOS_TARGET=#{orocos_target}", "-DCMAKE_BUILD_TYPE=Debug", File.join(main_dir, ext_dir))
raise "unable to configure the extension using CMake"
end


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ext/rorocos.cc → ext/rorocos/rorocos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ static VALUE mqueue_transportable_type_names(VALUE mod)
}
#endif

extern "C" void Init_rorocos_ext()
extern "C" void Init_rorocos()
{
mOrocos = rb_define_module("Orocos");
mCORBA = rb_define_module_under(mOrocos, "CORBA");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/orocos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
end

begin
require 'rorocos_ext'
rescue LoadError
STDERR.puts "Cannot require orocos.rb's Ruby/C extension"
require 'orocos/rorocos'
rescue LoadError => e
STDERR.puts "Cannot require orocos.rb's Ruby/C extension #{e}"
STDERR.puts "If you are using Rock, this should have been done automatically."
STDERR.puts "Run"
STDERR.puts " amake orocos.rb"
Expand Down
2 changes: 1 addition & 1 deletion lib/orocos/corba.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rorocos_ext'
require 'orocos/rorocos'
require 'typelib'

module Orocos
Expand Down

0 comments on commit f8f86c1

Please sign in to comment.