self.buf('\t},\n')
def generate_uclasses(self):
- if not self.check_instantiate(True):
- return
self.out('\n')
self.out('#include <common.h>\n')
self.out('#include <dm.h>\n')
self.out(''.join(self.get_buf()))
- def check_instantiate(self, require):
- """Check if self._instantiate is set to the required value
-
- If not, this outputs a message into the current file
-
- Args:
- require: True to require --instantiate, False to require that it not
- be enabled
- """
- if require != self._instantiate:
- self.out(
- '/* This file is not used: --instantiate was %senabled */\n' %
- ('not ' if require else ''))
- return False
- return True
-
def generate_plat(self):
"""Generate device defintions for the platform data
See the documentation in doc/driver-model/of-plat.rst for more
information.
"""
- if not self.check_instantiate(False):
- return
self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n')
self.out('#define DT_PLAT_C\n')
self.out('\n')
See the documentation in doc/driver-model/of-plat.rst for more
information.
"""
- if not self.check_instantiate(True):
- return
self.out('#include <common.h>\n')
self.out('#include <dm.h>\n')
self.out('#include <dt-structs.h>\n')
plat.assign_seqs()
# Figure out what output files we plan to generate
- output_files = OUTPUT_FILES_COMMON
+ output_files = dict(OUTPUT_FILES_COMMON)
if instantiate:
output_files.update(OUTPUT_FILES_INST)
else:
*/
'''
-UCLASS_HEADER = UCLASS_HEADER_COMMON + '''
-/* This file is not used: --instantiate was not enabled */
-'''
-
# Scanner saved from a previous run of the tests (to speed things up)
saved_scan = None
};
'''
- uclass_text = UCLASS_HEADER
uclass_text_inst = '''
#include <common.h>
},
};
-'''
- device_text = '''/*
- * DO NOT MODIFY
- *
- * Declares the DM_DEVICE_INST() records.
- * This was generated by dtoc from a .dtb (device tree binary) file.
- */
-
-/* This file is not used: --instantiate was not enabled */
'''
device_text_inst = '''/*
* DO NOT MODIFY
self.run_test(['all'], dtb_file, output)
data = tools.ReadFile(output, binary=False)
self._check_strings(
- self.decl_text + self.device_text + self.platdata_text +
- self.struct_text + self.uclass_text, data)
+ self.decl_text + self.platdata_text + self.struct_text, data)
def test_driver_alias(self):
"""Test output from a device tree file with a driver alias"""
self.run_test(['all'], dtb_file, output)
data = tools.ReadFile(output, binary=False)
self._check_strings(
- self.decl_text + self.device_text + self.platdata_text +
- self.struct_text + self.uclass_text, data)
+ self.decl_text + self.platdata_text + self.struct_text, data)
def test_no_command(self):
"""Test running dtoc without a command"""
self.assertIn("Must specify either output or output_dirs, not both",
str(exc.exception))
- def test_output_dirs(self):
- """Test outputting files to a directory"""
+ def check_output_dirs(self, instantiate):
# Remove the directory so that files from other tests are not there
tools._RemoveOutputDir()
tools.PrepareOutputDir(None)
self.assertEqual(2, len(fnames))
dtb_platdata.run_steps(
- ['all'], dtb_file, False, None, [outdir], None, False,
+ ['all'], dtb_file, False, None, [outdir], None, instantiate,
warning_disabled=True, scan=copy_scan())
fnames = glob.glob(outdir + '/*')
- self.assertEqual(7, len(fnames))
+ return fnames
+
+ def test_output_dirs(self):
+ """Test outputting files to a directory"""
+ fnames = self.check_output_dirs(False)
+ self.assertEqual(5, len(fnames))
leafs = set(os.path.basename(fname) for fname in fnames)
self.assertEqual(
{'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb',
+ 'dt-decl.h'},
+ leafs)
+
+ def test_output_dirs_inst(self):
+ """Test outputting files to a directory with instantiation"""
+ fnames = self.check_output_dirs(True)
+ self.assertEqual(6, len(fnames))
+
+ leafs = set(os.path.basename(fname) for fname in fnames)
+ self.assertEqual(
+ {'dt-structs-gen.h', 'source.dts', 'source.dtb',
'dt-uclass.c', 'dt-decl.h', 'dt-device.c'},
leafs)
self._check_strings(self.decl_text_inst, data)
- self.run_test(['platdata'], dtb_file, output, True)
- with open(output) as infile:
- data = infile.read()
-
- self._check_strings(C_HEADER_PRE + '''
-/* This file is not used: --instantiate was enabled */
-''', data)
-
self.run_test(['uclass'], dtb_file, output, True)
with open(output) as infile:
data = infile.read()