@ -178,7 +178,7 @@ Output is CcFileList and/or ProtoFileList. Example:
# fragment generator function.
# fragment generator function.
################################################################################
################################################################################
def _create_file_list_impl ( fragment_generator ) :
def _create_file_list_impl ( ctx , fragment_generator ) :
# `fragment_generator` is a function like:
# `fragment_generator` is a function like:
# def fn(originating_rule: Label,
# def fn(originating_rule: Label,
# varname: str,
# varname: str,
@ -191,7 +191,6 @@ def _create_file_list_impl(fragment_generator):
# When dealing with `File` objects, the `short_path` is used to strip
# When dealing with `File` objects, the `short_path` is used to strip
# the output prefix for generated files.
# the output prefix for generated files.
def _impl ( ctx ) :
out = ctx . outputs . out
out = ctx . outputs . out
fragments = [ ]
fragments = [ ]
@ -276,8 +275,6 @@ def _create_file_list_impl(fragment_generator):
return [ DefaultInfo ( files = depset ( [ out ] ) ) ]
return [ DefaultInfo ( files = depset ( [ out ] ) ) ]
return _impl
# Common rule attrs for rules that use `_create_file_list_impl`:
# Common rule attrs for rules that use `_create_file_list_impl`:
# (note that `_header` is also required)
# (note that `_header` is also required)
_source_list_common_attrs = {
_source_list_common_attrs = {
@ -343,6 +340,9 @@ def _cmake_var_fragment(owner, varname, prefix, entries):
entries = " \n " . join ( [ " %s %s " % ( prefix , f ) for f in entries ] ) ,
entries = " \n " . join ( [ " %s %s " % ( prefix , f ) for f in entries ] ) ,
)
)
def _cmake_file_list_impl ( ctx ) :
_create_file_list_impl ( ctx , _cmake_var_fragment )
gen_cmake_file_lists = rule (
gen_cmake_file_lists = rule (
doc = """
doc = """
Generates a CMake - syntax file with lists of files .
Generates a CMake - syntax file with lists of files .
@ -361,7 +361,7 @@ For proto_library, the following are generated:
{ libname } _hdrs : contains syntesized paths for generated C + + headers .
{ libname } _hdrs : contains syntesized paths for generated C + + headers .
""" ,
""" ,
implementation = _create_file_list_impl ( _cmake_var_fragment ) ,
implementation = _cmake_file_list_impl ,
attrs = dict (
attrs = dict (
_source_list_common_attrs ,
_source_list_common_attrs ,
_header = attr . string (
_header = attr . string (
@ -416,6 +416,9 @@ def _automake_var_fragment(owner, varname, prefix, entries):
)
)
return fragment . rstrip ( " \\ " ) + " \n "
return fragment . rstrip ( " \\ " ) + " \n "
def _automake_file_list_impl ( ctx ) :
_create_file_list_impl ( ctx , _automake_var_fragment )
gen_automake_file_lists = rule (
gen_automake_file_lists = rule (
doc = """
doc = """
Generates an Automake - syntax file with lists of files .
Generates an Automake - syntax file with lists of files .
@ -434,7 +437,7 @@ For proto_library, the following are generated:
{ libname } _hdrs : contains syntesized paths for generated C + + headers .
{ libname } _hdrs : contains syntesized paths for generated C + + headers .
""" ,
""" ,
implementation = _cre ate_file_list_impl ( _automake_var_fragment ) ,
implementation = _au tomak e_file_list_impl ,
attrs = dict (
attrs = dict (
_source_list_common_attrs . items ( ) ,
_source_list_common_attrs . items ( ) ,
_header = attr . string (
_header = attr . string (