@@ -64,25 +64,21 @@ def _ament_index_share_files_impl(ctx):
6464 package_marker_path : package_marker_out ,
6565 }
6666
67- def _add_files (targets ):
68- for src in targets :
69- for file in depset (transitive = [
70- src .files ,
71- src [DefaultInfo ].default_runfiles .files ,
72- ]).to_list ():
73- sp = file .short_path
74- if sp .startswith (ctx .attr .strip_prefix ):
75- sp = sp [len (ctx .attr .strip_prefix ):]
76- symlink_path = paths .join (
77- ctx .attr .prefix ,
78- "share" ,
79- ctx .attr .package_name ,
80- sp ,
81- )
82- runfiles_symlinks [symlink_path ] = file
83-
84- _add_files (ctx .attr .srcs )
85- _add_files (ctx .attr .data )
67+ for src in ctx .attr .srcs :
68+ for file in depset (transitive = [
69+ src .files ,
70+ src [DefaultInfo ].default_runfiles .files ,
71+ ]).to_list ():
72+ sp = file .short_path
73+ if sp .startswith (ctx .attr .strip_prefix ):
74+ sp = sp [len (ctx .attr .strip_prefix ):]
75+ symlink_path = paths .join (
76+ ctx .attr .prefix ,
77+ "share" ,
78+ ctx .attr .package_name ,
79+ sp ,
80+ )
81+ runfiles_symlinks [symlink_path ] = file
8682
8783 return [
8884 AmentIndex (prefix = ctx .attr .prefix ),
@@ -99,10 +95,6 @@ ament_index_share_files = rule(
9995 allow_empty = False ,
10096 allow_files = True ,
10197 ),
102- data = attr .label_list (
103- allow_empty = True ,
104- allow_files = True ,
105- ),
10698 # A prefix is required because the shim can't prepend the runfiles
10799 # root to AMENT_PREFIX_PATH
108100 prefix = attr .string (default = "ament_index_share_files" ),
@@ -141,7 +133,8 @@ with the same package.
141133
142134Args:
143135 package_name: name of a ROS 2 package to which these share files belong
144- srcs: files to put into the share directory
136+ srcs: targets whose files are placed into the share directory. Both
137+ direct files and transitive runfiles are included.
145138 prefix: optional prefix to give to the generated runfiles.
146139 strip_prefix: optional prefix to strip from the short_path of the files
147140
0 commit comments