Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup plugin loading #94

Merged
merged 5 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/orops
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'orocos'
require 'pp'
require 'utilrb/pkgconfig'
require 'optparse'

do_cleanup = false
parser = OptionParser.new do |opt|
Expand Down
1 change: 1 addition & 0 deletions bin/oroshell
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'irb'
require 'orocos'
require 'optparse'

parser = OptionParser.new do |opt|
opt.on('--host=HOST', String, "the host we should connect to for naming") do |hostname|
Expand Down
16 changes: 8 additions & 8 deletions lib/orocos/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ def self.resolve_prefix(model, prefix)
# starting the process and cleaning up when the process
# dies.
class Process < ProcessBase
# The component PkgConfig instance
attr_reader :pkg
# The path to the binary file
attr_reader :binfile
# The component process ID
attr_reader :pid

Expand Down Expand Up @@ -430,7 +430,11 @@ def initialize(name, model = name, loader: Orocos.default_pkgconfig_loader)
loader.deployment_model_from_name(model)
else model
end
@pkg = loader.available_deployments[model.name]
@binfile =
if loader.respond_to?(:find_deployment_binfile)
loader.find_deployment_binfile(model.name)
else loader.available_deployments[model.name].binfile
end
super(name, model)
end

Expand Down Expand Up @@ -951,11 +955,7 @@ def spawn(log_level: nil, working_directory: Orocos.default_working_directory,
ENV['ORBInitRef'] = "NameService=corbaname::#{name_service.ip}"
end

module_bin = pkg.binfile
if !module_bin # assume an older orogen version
module_bin = "#{pkg.exec_prefix}/bin/#{name}"
end
cmdline = [module_bin]
cmdline = [binfile]

# check arguments for log_level
if log_level
Expand Down
21 changes: 12 additions & 9 deletions lib/orocos/typekits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ def self.export_types=(value); default_loader.export_types = value end
# Given a pkg-config file and a base name for a shared library, finds the
# full path to the library
def self.find_plugin_library(pkg, libname)
pkg.library_dirs.find do |dir|
libs = pkg.expand_field('Libs', pkg.raw_fields['Libs'])
libs = libs.grep(/^-L/).map { |s| s[2..-1] }
libs.find do |dir|
full_path = File.join(dir, "lib#{libname}.#{Orocos.shared_library_suffix}")
break(full_path) if File.file?(full_path)
if File.file?(full_path)
return full_path, libs
end
end
end

Expand Down Expand Up @@ -72,13 +76,12 @@ def self.load_plugin_library(libpath) # :nodoc:
def self.load_typekit(name)
@lock.synchronize do
typekit = default_pkgconfig_loader.typekit_model_from_name(name)
typekit_pkg = find_typekit_pkg(name)
load_typekit_plugins(name, typekit_pkg)
load_typekit_plugins(name)
end
end

def self.find_typekit_pkg(name)
Utilrb::PkgConfig.new("#{name}-typekit-#{Orocos.orocos_target}")
Utilrb::PkgConfig.get("#{name}-typekit-#{Orocos.orocos_target}", minimal: true)
rescue Utilrb::PkgConfig::NotFound
raise TypekitNotFound, "the '#{name}' typekit is not available to pkgconfig"
end
Expand Down Expand Up @@ -142,7 +145,7 @@ def self.find_typekit_plugin_paths(name, typekit_pkg = nil)
AUTOLOADED_TRANSPORTS.each do |transport_name, required|
plugin_name = transport_library_name(name, transport_name, Orocos.orocos_target)
begin
pkg = Utilrb::PkgConfig.new(plugin_name)
pkg = Utilrb::PkgConfig.get(plugin_name, minimal: true)
if pkg.disabled != "true"
plugins[plugin_name] = [pkg, required]
elsif required
Expand All @@ -157,12 +160,12 @@ def self.find_typekit_plugin_paths(name, typekit_pkg = nil)
end

plugins.each_pair do |file, (pkg, required)|
lib = find_plugin_library(pkg, file)
lib, lib_dirs = find_plugin_library(pkg, file)
if !lib
if required
raise NotFound, "cannot find shared library #{file} for #{name} (searched in #{pkg.library_dirs.join(", ")})"
raise NotFound, "cannot find shared library #{file} for #{name} (searched in #{lib_dirs})"
else
Orocos.warn "plugin #{file} is registered through pkg-config, but the library cannot be found in #{pkg.library_dirs.join(", ")}"
Orocos.warn "plugin #{file} is registered through pkg-config, but the library cannot be found in #{lib_dirs}"
end
else
libs << [lib, required]
Expand Down
2 changes: 2 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<depend package="tools/pocolog" optional="1"/>
<depend package="omniorb" />
<depend package="tools/rtt_transports/ros" optional="1"/>
<depend package="hoe" />
<depend package="rake-compiler" />

<test_depend package='flexmock' />
<test_depend package='fakefs' />
Expand Down