@@ -6,41 +6,41 @@ FilesInfo = provider(
66 },
77)
88
9- def _get_hdrs (ctx ):
10- files = []
9+ def get_cc_hdrs (ctx ):
10+ hdrs = []
1111
1212 if hasattr (ctx .rule .attr , "hdrs" ):
1313 for hdr in ctx .rule .attr .hdrs :
14- for file in hdr .files .to_list ():
15- if not file .path .startswith (ctx .genfiles_dir .path ):
16- files .append (file )
17- return files
14+ hdrs += [hdr for hdr in hdr .files .to_list () if hdr .is_source ]
1815
19- def _get_srcs (ctx ):
20- files = []
16+ return hdrs
17+
18+ def get_cc_srcs (ctx ):
19+ srcs = []
2120
2221 if hasattr (ctx .rule .attr , "srcs" ):
2322 for src in ctx .rule .attr .srcs :
24- for file in src .files .to_list ():
25- if file .is_source and not file .path .startswith (ctx .genfiles_dir .path ):
26- files .append (file )
27- return files
23+ srcs += [src for src in src .files .to_list () if src .is_source ]
2824
29- def _get_cc_target_files_impl (target , ctx ):
25+ return srcs
26+
27+ def get_cc_files (ctx ):
3028 files = []
3129
30+ files .extend (get_cc_srcs (ctx ))
31+ files .extend (get_cc_hdrs (ctx ))
32+
33+ return files
34+
35+ def _get_cc_target_files_impl (target , ctx ):
3236 if not CcInfo in target :
3337 return [FilesInfo (files = [])]
3438
3539 tags = getattr (ctx .rule .attr , "tags" , [])
3640 if not LIBRARY in tags and not TEST_LIBRARY in tags and not BINARY in tags :
3741 return [FilesInfo (files = [])]
3842
39- files .extend (_get_srcs (ctx ))
40-
41- files .extend (_get_hdrs (ctx ))
42-
43- return [FilesInfo (files = files )]
43+ return [FilesInfo (files = get_cc_files (ctx ))]
4444
4545get_cc_target_files = aspect (
4646 implementation = _get_cc_target_files_impl ,
@@ -50,7 +50,7 @@ def _get_cc_target_hdrs_impl(target, ctx):
5050 if not CcInfo in target :
5151 return [FilesInfo (files = [])]
5252
53- return [FilesInfo (files = _get_hdrs (ctx ))]
53+ return [FilesInfo (files = get_cc_hdrs (ctx ))]
5454
5555get_cc_target_hdrs = aspect (
5656 implementation = _get_cc_target_hdrs_impl ,
0 commit comments