mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 22:20:45 +00:00
dtoc: Add a header comment to each generated file
It is currently fairly obvious what the two generated files are for, but this will change as more are added. It is helpful for readers to describe the purpose of each file. Add a header commment field to OutputFile and use it to generate a comment at the top of each file. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5d9a3aa99c
commit
d1055d681a
2 changed files with 24 additions and 12 deletions
|
@ -56,8 +56,10 @@ class Ftype(IntEnum):
|
|||
|
||||
# This holds information about each type of output file dtoc can create
|
||||
# type: Type of file (Ftype)
|
||||
# fname: Filename excluding directory, e.g. 'dt-platdata.c'
|
||||
OutputFile = collections.namedtuple('OutputFile', ['ftype', 'fname'])
|
||||
# fname: Filename excluding directory, e.g. 'dt-plat.c'
|
||||
# hdr_comment: Comment explaining the purpose of the file
|
||||
OutputFile = collections.namedtuple('OutputFile',
|
||||
['ftype', 'fname', 'hdr_comment'])
|
||||
|
||||
# This holds information about a property which includes phandles.
|
||||
#
|
||||
|
@ -331,15 +333,20 @@ class DtbPlatdata():
|
|||
self._lines = []
|
||||
return lines
|
||||
|
||||
def out_header(self):
|
||||
"""Output a message indicating that this is an auto-generated file"""
|
||||
def out_header(self, outfile):
|
||||
"""Output a message indicating that this is an auto-generated file
|
||||
|
||||
Args:
|
||||
outfile: OutputFile describing the file being generated
|
||||
"""
|
||||
self.out('''/*
|
||||
* DO NOT MODIFY
|
||||
*
|
||||
* This file was generated by dtoc from a .dtb (device tree binary) file.
|
||||
* %s.
|
||||
* This was generated by dtoc from a .dtb (device tree binary) file.
|
||||
*/
|
||||
|
||||
''')
|
||||
''' % outfile.hdr_comment)
|
||||
|
||||
def get_phandle_argc(self, prop, node_name):
|
||||
"""Check if a node contains phandles
|
||||
|
@ -646,7 +653,6 @@ class DtbPlatdata():
|
|||
value: Prop object with field information
|
||||
|
||||
"""
|
||||
self.out_header()
|
||||
self.out('#include <stdbool.h>\n')
|
||||
self.out('#include <linux/libfdt.h>\n')
|
||||
|
||||
|
@ -789,7 +795,6 @@ class DtbPlatdata():
|
|||
See the documentation in doc/driver-model/of-plat.rst for more
|
||||
information.
|
||||
"""
|
||||
self.out_header()
|
||||
self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n')
|
||||
self.out('#define DT_PLATDATA_C\n')
|
||||
self.out('\n')
|
||||
|
@ -823,8 +828,12 @@ class DtbPlatdata():
|
|||
# key: Command used to generate this file
|
||||
# value: OutputFile for this command
|
||||
OUTPUT_FILES = {
|
||||
'struct': OutputFile(Ftype.HEADER, 'dt-structs-gen.h'),
|
||||
'platdata': OutputFile(Ftype.SOURCE, 'dt-platdata.c'),
|
||||
'struct':
|
||||
OutputFile(Ftype.HEADER, 'dt-structs-gen.h',
|
||||
'Defines the structs used to hold devicetree data'),
|
||||
'platdata':
|
||||
OutputFile(Ftype.SOURCE, 'dt-platdata.c',
|
||||
'Declares the U_BOOT_DRIVER() records and platform data'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -872,6 +881,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs,
|
|||
(cmd, ', '.join(sorted(OUTPUT_FILES.keys()))))
|
||||
plat.setup_output(outfile.ftype,
|
||||
outfile.fname if output_dirs else output)
|
||||
plat.out_header(outfile)
|
||||
if cmd == 'struct':
|
||||
plat.generate_structs(structs)
|
||||
elif cmd == 'platdata':
|
||||
|
|
|
@ -32,7 +32,8 @@ OUR_PATH = os.path.dirname(os.path.realpath(__file__))
|
|||
HEADER = '''/*
|
||||
* DO NOT MODIFY
|
||||
*
|
||||
* This file was generated by dtoc from a .dtb (device tree binary) file.
|
||||
* Defines the structs used to hold devicetree data.
|
||||
* This was generated by dtoc from a .dtb (device tree binary) file.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
@ -41,7 +42,8 @@ HEADER = '''/*
|
|||
C_HEADER = '''/*
|
||||
* DO NOT MODIFY
|
||||
*
|
||||
* This file was generated by dtoc from a .dtb (device tree binary) file.
|
||||
* Declares the U_BOOT_DRIVER() records and platform data.
|
||||
* This was generated by dtoc from a .dtb (device tree binary) file.
|
||||
*/
|
||||
|
||||
/* Allow use of U_BOOT_DRVINFO() in this file */
|
||||
|
|
Loading…
Reference in a new issue