Skip to content

Commit e285fa3

Browse files
committed
fix generation path and install path of the TaskStates.hpp header
One major improvement is that the full-to-include mapping is saved in the pending_loads array, instead of re-guessing what had already been guessed in #load. Other than this, it's basically cleaning up the mess little by little
1 parent 62c04da commit e285fa3

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

lib/orogen/gen/project.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,9 @@ def generate
684684
if self_tasks.any?(&:extended_state_support?)
685685
state_types = Generation.render_template(
686686
"tasks", "TaskStates.hpp", binding)
687-
header = Generation.save_automatic(
688-
'typekit', 'types', project.name, "TaskStates.hpp", state_types)
689-
typekit(true).load(header)
687+
header = typekit(true).save_automatic_public_header(
688+
'types', "TaskStates.hpp", state_types)
689+
typekit(true).load(header, relative_path_from: typekit.automatic_public_header_dir)
690690
end
691691

692692
if typekit

lib/orogen/gen/typekit.rb

+18-17
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,6 @@ def self.register_plugin(klass)
591591
# Changes the typekit base directory
592592
def base_dir=(path)
593593
@base_dir = path
594-
if path
595-
include_dirs << path
596-
end
597594
end
598595

599596
INCLUDE_DIR_NAME = 'types'
@@ -803,7 +800,7 @@ def find_type(type, is_normalized = false)
803800
end
804801

805802
rescue Typelib::NotFound => e
806-
if !pending_loads.empty?
803+
if has_pending_loads?
807804
perform_pending_loads
808805
retry
809806
end
@@ -1181,15 +1178,18 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
11811178
if File.file?(file) # Local file
11821179
file = File.expand_path(file)
11831180
include_statement = handle_local_load(file, relative_path_from: relative_path_from)
1181+
# Local loads are inserted in a normalized install path at
1182+
# loading and build time. They have no full path until then
1183+
full_path = nil
11841184
else # File from used libraries/task libraries
11851185
dir = include_dirs.find { |dir| File.file?(File.join(dir, file)) }
11861186
if !dir
11871187
raise LoadError, "cannot find #{file} in #{include_dirs.to_a.join(":")}"
11881188
end
11891189
loaded_files_dirs << dir
1190-
file = File.join(dir, file)
1190+
full_path = File.join(dir, file)
11911191
include_path = include_dirs.map { |d| Pathname.new(d) }
1192-
include_statement = resolve_full_include_path_to_relative(file, include_path)
1192+
include_statement = resolve_full_include_path_to_relative(full_path, include_path)
11931193
end
11941194

11951195
included_files << include_statement
@@ -1203,7 +1203,7 @@ def load(file, add = true, relative_path_from: base_dir, **user_options)
12031203
end
12041204

12051205
@pending_load_options = this_options
1206-
pending_loads << file
1206+
pending_loads << [full_path, include_statement]
12071207
end
12081208

12091209
def filter_unsupported_types(registry)
@@ -1430,9 +1430,9 @@ def resolve_toplevel_include_mapping(toplevel_files, options)
14301430
return preprocessed, owners
14311431
end
14321432

1433-
def make_load_options(pending_loads, user_options)
1433+
def make_load_options(required_files, user_options)
14341434
user_options = user_options.dup
1435-
options = { :opaques_ignore => true, :merge => false, :required_files => pending_loads.to_a }
1435+
options = { opaques_ignore: true, merge: false, required_files: required_files }
14361436
# GCCXML can't parse vectorized code, and the Typelib internal
14371437
# parser can't parse eigen at all. It is therefore safe to do it
14381438
# here
@@ -1475,16 +1475,22 @@ def has_pending_loads?
14751475
end
14761476

14771477
def perform_pending_loads
1478-
return if pending_loads.empty?
1479-
loads = pending_loads.dup
1480-
pending_loads.clear
1478+
return if !has_pending_loads?
14811479

14821480
fake_include_dir = Dir.mktmpdir
14831481
@local_loads_symlinks.each do |target, link|
14841482
FileUtils.mkdir_p File.join(fake_include_dir, File.dirname(link))
14851483
FileUtils.cp target, File.join(fake_include_dir, link)
14861484
end
14871485

1486+
pending_loads_to_relative = Hash.new
1487+
loads = pending_loads.map do |full_path, include_statement|
1488+
full_path ||= File.join(fake_include_dir, include_statement)
1489+
pending_loads_to_relative[full_path] = include_statement
1490+
full_path
1491+
end
1492+
pending_loads.clear
1493+
14881494
add, user_options = *pending_load_options
14891495

14901496
file_registry = Typelib::Registry.new
@@ -1494,11 +1500,6 @@ def perform_pending_loads
14941500
preprocessed, include_mappings = resolve_toplevel_include_mapping(loads, preprocess_options)
14951501

14961502
include_paths = options[:include].map { |p| Pathname.new(p) }
1497-
pending_loads_to_relative = loads.inject(Hash.new) do |map, path|
1498-
map[path] = resolve_full_include_path_to_relative(path, include_paths)
1499-
map
1500-
end
1501-
15021503
include_mappings.each do |file, lines|
15031504
lines.map! { |inc| pending_loads_to_relative[inc] }
15041505
end

lib/orogen/templates/config/Base.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/<%= Generation::AUTOMATIC
8888
<% if project.typekit %>
8989
# Take care of the typekit
9090
ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/<%= Generation::AUTOMATIC_AREA_NAME %>/typekit )
91-
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/<%= Generation::AUTOMATIC_AREA_NAME %>/typekit")
92-
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/<%= Generation::AUTOMATIC_AREA_NAME %>/typekit/types")
9391
if (NOT DISABLE_REGEN_CHECK)
9492
add_dependencies(check-uptodate check-typekit-uptodate)
9593
endif()

lib/orogen/templates/config/TaskLib.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
3131

3232
<% if project.typekit %>
33-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/typekit)
33+
include_directories(${PROJECT_SOURCE_DIR}/.orogen/typekit/__include_dir__/)
34+
include_directories(${PROJECT_BINARY_DIR}/.orogen/typekit/__include_dir__/)
3435
list(APPEND <%= project.name.upcase %>_TASKLIB_DEPENDENT_LIBRARIES
3536
<%= project.name %>-typekit-${OROCOS_TARGET})
3637
<% end %>

lib/orogen/templates/tasks/TaskBase.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <rtt/Port.hpp>
1515
<% end %>
1616
<% if task.extended_state_support? %>
17-
#include <<%= project.typekit.name %>/TaskStates.hpp>
17+
#include <<%= project.typekit.name %>/typekit/types/TaskStates.hpp>
1818
<% end %>
1919

2020
<% task.self_properties.sort_by(&:name).each do |p| %>

0 commit comments

Comments
 (0)