[PATCH 1/2] tools: dtoc: Allow passing optional input directories

Simon Glass sjg at chromium.org
Wed Nov 20 14:47:30 CET 2024


Hi Paul,

On Wed, 20 Nov 2024 at 03:37, Paul HENRYS
<paul.henrys_ext at softathome.com> wrote:
>
> An optional list of input directories can be passed to EnsureCompiled() which
> allows to pass a list of directories where input files can be searched.
>
> Signed-off-by: Paul HENRYS <paul.henrys_ext at softathome.com>
> ---
>  tools/dtoc/fdt_util.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

>
> diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
> index f1f70568cf..3e5832fb07 100644
> --- a/tools/dtoc/fdt_util.py
> +++ b/tools/dtoc/fdt_util.py
> @@ -55,7 +55,7 @@ def fdt_cells_to_cpu(val, cells):
>          out = out << 32 | fdt32_to_cpu(val[1])
>      return out
>
> -def EnsureCompiled(fname, tmpdir=None, capture_stderr=False):
> +def EnsureCompiled(fname, tmpdir=None, capture_stderr=False, indir=[]):

Just a note that I tend to avoid a default argument of a list, since I
understood that changing indir within this function will apparently
change the default from then on. I've never tried it though, so could
be wrong. So I tend to use None as a default rather than a list or
dict.

>      """Compile an fdt .dts source file into a .dtb binary blob if needed.
>
>      Args:
> @@ -63,6 +63,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False):
>              left alone
>          tmpdir: Temporary directory for output files, or None to use the
>              tools-module output directory
> +        indir: List of directories where input files can be found
>
>      Returns:
>          Filename of resulting .dtb file
> @@ -79,6 +80,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False):
>          dtb_output = tools.get_output_filename('source.dtb')
>
>      search_paths = [os.path.join(os.getcwd(), 'include')]
> +    search_paths += indir
>      root, _ = os.path.splitext(fname)
>      cc, args = tools.get_target_compile_tool('cc')
>      args += ['-E', '-P', '-x', 'assembler-with-cpp', '-D__ASSEMBLY__']
> --
> 2.43.0
>
[..]

Regards,
Simon


More information about the U-Boot mailing list