Skip to content

Commit 62c04da

Browse files
committed
gen: cleanup the installation of local headers
The old code was full of weird assumptions that have been made at least partially obsolete by the latest changes. Update the codegen.
1 parent 1c01918 commit 62c04da

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

lib/orogen/gen/typekit.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,8 @@ def has_opaques_with_templates?
11251125
attr_reader :local_loads_symlinks
11261126

11271127
# Handle a load that points to a file in this typekit's source tree
1128-
def handle_local_load(file)
1129-
rel = Pathname.new(file).relative_path_from(Pathname.new(base_dir))
1128+
def handle_local_load(file, relative_path_from: base_dir)
1129+
rel = Pathname.new(file).relative_path_from(Pathname.new(relative_path_from))
11301130
return file if rel.each_filename.first == ".."
11311131

11321132
# If the type is within a subdirectory called as the
@@ -1166,11 +1166,7 @@ def handle_local_load(file)
11661166
# the exact offsets for all the fields in the structures).
11671167
#
11681168
# @raises LoadError if the file does not exist
1169-
def load(file, add = true, user_options = Hash.new)
1170-
if !user_options.respond_to?(:to_hash)
1171-
raise ArgumentError, "expected an option has as third argument, got #{user_options.inspect}"
1172-
end
1173-
1169+
def load(file, add = true, relative_path_from: base_dir, **user_options)
11741170
if match = /(\w+)\/Types\.hpp$/.match(file)
11751171
project_name = match[1]
11761172
if project.has_typekit?(project_name) || project.name == project_name
@@ -1184,7 +1180,7 @@ def load(file, add = true, user_options = Hash.new)
11841180
# Get the full path for +file+
11851181
if File.file?(file) # Local file
11861182
file = File.expand_path(file)
1187-
include_statement = handle_local_load(file)
1183+
include_statement = handle_local_load(file, relative_path_from: relative_path_from)
11881184
else # File from used libraries/task libraries
11891185
dir = include_dirs.find { |dir| File.file?(File.join(dir, file)) }
11901186
if !dir
@@ -1808,7 +1804,7 @@ def handle_opaques_generation(generated_types)
18081804
render_template 'typekit', 'marshalling_types.hpp', binding
18091805

18101806
path = save_automatic_public_header "m_types", "#{type.method_name(true)}.hpp", marshalling_code
1811-
self.load(path, true, options)
1807+
self.load(path, true, relative_path_from: automatic_public_header_dir, **options)
18121808

18131809
m_type = intermediate_type_for(type)
18141810
copy_metadata_to_intermediate_type(type.metadata, m_type.metadata)

lib/orogen/templates/typekit/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,23 @@ install(FILES
155155
relatives.sort.join("\n ") %>
156156
DESTINATION include/orocos/<%= typekit.name %>/typekit)
157157

158-
<% (public_header_files + typekit.included_files).each do |inc|
159-
full_path = Pathname.new(typekit.automatic_dir).join('types', inc)
160-
next if !full_path.exist?
161-
target_dir = File.dirname(inc)
162-
if full_path.symlink?
163-
full_path = full_path.readlink
164-
end
165-
source_file = full_path.relative_path_from(Pathname.new(typekit.automatic_dir)) %>
158+
<% automatic_public_header_dir = Pathname.new(typekit.automatic_public_header_dir)
159+
automatic_dir = Pathname.new(typekit.automatic_dir) %>
160+
161+
<% public_header_files.each do |full_path|
162+
full_path = Pathname.new(full_path)
163+
target_dir = full_path.dirname.relative_path_from(automatic_public_header_dir)
164+
if full_path.symlink?
165+
full_path = full_path.readlink
166+
end
167+
source_file = full_path.relative_path_from(automatic_dir) %>
168+
install(FILES <%= source_file.to_path %>
169+
DESTINATION include/orocos/<%= target_dir.to_path %>)
170+
<% end %>
171+
172+
<% typekit.local_loads_symlinks.each do |full_path, include_statement|
173+
source_file = Pathname.new(full_path).relative_path_from(automatic_dir)
174+
target_dir = File.dirname(include_statement) %>
166175
install(FILES <%= source_file.to_path %>
167176
DESTINATION include/orocos/<%= target_dir %>)
168177
<% end %>

0 commit comments

Comments
 (0)