From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: Simon Glass <sjg@chromium.org>,
U-Boot Mailing List <u-boot@lists.denx.de>
Cc: huang lin <hl@rock-chips.com>,
Jeffy Chen <jeffy.chen@rock-chips.com>,
Kever Yang <kever.yang@rock-chips.com>,
Tom Rini <trini@konsulko.com>,
Philippe Reynes <philippe.reynes@softathome.com>,
Ivan Mikhaylov <ivan.mikhaylov@siemens.com>,
Walter Lozano <walter.lozano@collabora.com>
Subject: Re: [PATCH 09/24] dtoc: Support reading a list of arguments
Date: Tue, 15 Feb 2022 14:43:39 +0300 [thread overview]
Message-ID: <4f45167f-ec28-7535-940c-c7bb8f96db02@gmail.com> (raw)
In-Reply-To: <20220208185008.35843-8-sjg@chromium.org>
On 08/02/2022 21:49, Simon Glass wrote:
> It is helpful to support a string or stringlist containing a list of
> space-separated arguments, for example:
>
> args = "-n fred", "-a", "123";
>
> This resolves to the list:
>
> -n fred -a 123
Would be clearer as ['-n', 'fred', '-a', '123']
>
> which can be passed to a program as arguments.
>
> Add a helper to do the required processing.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> tools/dtoc/fdt_util.py | 12 ++++++++++++
> tools/dtoc/test/dtoc_test_simple.dts | 1 +
> tools/dtoc/test_fdt.py | 15 +++++++++++++++
> 3 files changed, 28 insertions(+)
>
> diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
> index 19eb13aef3..59e065884f 100644
> --- a/tools/dtoc/fdt_util.py
> +++ b/tools/dtoc/fdt_util.py
> @@ -184,6 +184,18 @@ def GetStringList(node, propname, default=None):
> return [strval]
> return value
>
> +def GetArgs(node, propname):
> + prop = node.props.get(propname)
> + if not prop:
> + raise ValueError(f"Node '{node.path}': Expected property '{propname}'")
> + if prop.bytes:
> + value = GetStringList(node, propname)
> + else:
> + value = []
Isn't GetStringList(node, propname, default=[]) enough here, why check
prop.bytes?
> + lists = [v.split() for v in value]
Use shlex.split() to handle quotes inside the strings, so that we can
pass args with spaces inside them. e.g. mkimage -n "U-Boot v2022.04".
Or each list element could be a single argument with no splitting done.
I also wish mkimage -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" from
Makefile was possible, but can't think of a great way.
> + args = [x for l in lists for x in l]
> + return args
> +
Anyway, I don't think this belongs here as argument lists are not really
a device-tree construct. It would be better in a new binman entry type
("command"?) which mkimage can subclass from.
> def GetBool(node, propname, default=False):
> """Get an boolean from a property
>
> diff --git a/tools/dtoc/test/dtoc_test_simple.dts b/tools/dtoc/test/dtoc_test_simple.dts
> index 4c2c70af22..2d321fb034 100644
> --- a/tools/dtoc/test/dtoc_test_simple.dts
> +++ b/tools/dtoc/test/dtoc_test_simple.dts
> @@ -62,5 +62,6 @@
>
> orig-node {
> orig = <1 23 4>;
> + args = "-n first", "second", "-p", "123,456", "-x";
Could be useful to add an argument with single quotes, and one with
escaped double quotes.
> };
> };
> diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
> index c8fe5fc1de..5d46e69b8b 100755
> --- a/tools/dtoc/test_fdt.py
> +++ b/tools/dtoc/test_fdt.py
> @@ -652,6 +652,21 @@ class TestFdtUtil(unittest.TestCase):
> self.assertEqual(['test'],
> fdt_util.GetStringList(self.node, 'missing', ['test']))
>
> + def testGetArgs(self):
> + node = self.dtb.GetNode('/orig-node')
> + self.assertEqual(['message'], fdt_util.GetArgs(self.node, 'stringval'))
> + self.assertEqual(
> + ['multi-word', 'message'],
> + fdt_util.GetArgs(self.node, 'stringarray'))
> + self.assertEqual([], fdt_util.GetArgs(self.node, 'boolval'))
> + self.assertEqual(['-n', 'first', 'second', '-p', '123,456', '-x'],
> + fdt_util.GetArgs(node, 'args'))
> + with self.assertRaises(ValueError) as exc:
> + fdt_util.GetArgs(self.node, 'missing')
> + self.assertIn(
> + "Node '/spl-test': Expected property 'missing'",
> + str(exc.exception))
> +
> def testGetBool(self):
> self.assertEqual(True, fdt_util.GetBool(self.node, 'boolval'))
> self.assertEqual(False, fdt_util.GetBool(self.node, 'missing'))
next prev parent reply other threads:[~2022-02-15 11:53 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 18:49 [PATCH 00/24] binman: rockchip: Migrate from rockchip SPL_FIT_GENERATOR script Simon Glass
2022-02-08 18:49 ` [PATCH 01/24] moveconfig: Show the config name rather than the defconfig Simon Glass
2022-02-15 11:40 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-23 2:43 ` Simon Glass
2022-02-08 18:49 ` [PATCH 02/24] moveconfig: Allow regex matches when finding combinations Simon Glass
2022-02-15 11:41 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-08 18:49 ` [PATCH 03/24] spl: x86: Correct the binman symbols for SPL Simon Glass
2022-02-15 11:42 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-23 22:58 ` Simon Glass
2022-03-03 21:06 ` Alper Nebi Yasak
2022-03-06 3:07 ` Simon Glass
2022-02-08 18:49 ` [PATCH 04/24] spl: Allow disabling binman symbols in SPL Simon Glass
2022-02-15 11:42 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-08 18:49 ` [PATCH 05/24] rockchip: evb-rk3288: Drop raw-image support Simon Glass
2022-02-08 18:49 ` [PATCH 06/24] dtoc: Support adding a string list to a device tree Simon Glass
2022-02-15 11:43 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-23 22:58 ` Simon Glass
2022-03-03 21:07 ` Alper Nebi Yasak
2022-03-06 3:07 ` Simon Glass
2022-02-08 18:49 ` [PATCH 07/24] dtoc: Support deleting a node Simon Glass
2022-02-08 18:49 ` [PATCH 08/24] dtoc: Allow deleting nodes and adding them in the same sync Simon Glass
2022-02-08 18:49 ` [PATCH 09/24] dtoc: Support reading a list of arguments Simon Glass
2022-02-15 11:43 ` Alper Nebi Yasak [this message]
2022-02-23 2:35 ` Simon Glass
2022-02-23 22:58 ` Simon Glass
2022-03-03 21:07 ` Alper Nebi Yasak
2022-02-08 18:49 ` [PATCH 10/24] binman: Update docs to indicate mkimage is supported Simon Glass
2022-02-23 2:35 ` Simon Glass
2022-02-08 18:49 ` [PATCH 11/24] elf: Add a way to read segment information from an ELF file Simon Glass
2022-02-15 11:44 ` Alper Nebi Yasak
2022-02-23 2:35 ` Simon Glass
2022-02-23 22:58 ` Simon Glass
2022-02-08 18:49 ` [PATCH 12/24] WIP: binman: Add support for OP-TEE Simon Glass
2022-02-08 18:49 ` [PATCH 13/24] binman: Add to the TODO Simon Glass
2022-02-08 18:49 ` [PATCH 14/24] binman: Support a list of strings with the mkimage etype Simon Glass
2022-02-15 11:45 ` Alper Nebi Yasak
2022-02-23 2:34 ` Simon Glass
2022-02-23 22:59 ` Simon Glass
2022-02-08 18:49 ` [PATCH 15/24] binman: Add a ELF test file with disjoint text sections Simon Glass
2022-02-08 18:50 ` [PATCH 16/24] binman: Move entry-data collection into a Entry method Simon Glass
2022-02-15 11:45 ` Alper Nebi Yasak
2022-02-23 2:34 ` Simon Glass
2022-02-08 18:50 ` [PATCH 17/24] binman: fit: Refactor to reduce function size Simon Glass
2022-02-15 11:45 ` Alper Nebi Yasak
2022-02-23 2:34 ` Simon Glass
2022-02-23 22:59 ` Simon Glass
2022-02-08 18:50 ` [PATCH 18/24] binman: Tidy up the docs a little with fit Simon Glass
2022-02-08 18:50 ` [PATCH 19/24] binman: Allow different operations in FIT generator nodes Simon Glass
2022-02-23 2:34 ` Simon Glass
2022-02-08 18:50 ` [PATCH 20/24] binman: Support splitting an ELF file into multiple nodes Simon Glass
2022-02-15 11:46 ` Alper Nebi Yasak
2022-02-23 22:59 ` Simon Glass
2022-03-03 21:07 ` Alper Nebi Yasak
2022-03-06 3:07 ` Simon Glass
2022-02-08 18:50 ` [PATCH 21/24] rockchip: Include binman script in 64-bit boards Simon Glass
2022-02-08 18:50 ` [PATCH 22/24] rockchip: Support building the all output files in binman Simon Glass
2022-02-10 15:03 ` Peter Geis
2022-02-10 18:57 ` Simon Glass
2022-02-10 19:32 ` Peter Geis
2022-02-14 1:28 ` Peter Geis
2022-02-15 11:48 ` Alper Nebi Yasak
2022-02-08 18:50 ` [PATCH 23/24] rockchip: Convert all boards to use binman Simon Glass
2022-02-08 18:50 ` [PATCH 24/24] rockchip: Drop the FIT generator script Simon Glass
2022-02-11 15:22 ` [PATCH 00/24] binman: rockchip: Migrate from rockchip SPL_FIT_GENERATOR script Alper Nebi Yasak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f45167f-ec28-7535-940c-c7bb8f96db02@gmail.com \
--to=alpernebiyasak@gmail.com \
--cc=hl@rock-chips.com \
--cc=ivan.mikhaylov@siemens.com \
--cc=jeffy.chen@rock-chips.com \
--cc=kever.yang@rock-chips.com \
--cc=philippe.reynes@softathome.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=walter.lozano@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox