Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D177C433F5 for ; Thu, 3 Mar 2022 21:15:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AC38283CD9; Thu, 3 Mar 2022 22:14:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="etEZeDzG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43B1783CDF; Thu, 3 Mar 2022 22:14:52 +0100 (CET) Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CBC4383A34 for ; Thu, 3 Mar 2022 22:14:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x62b.google.com with SMTP id p15so13361988ejc.7 for ; Thu, 03 Mar 2022 13:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=sm8BiF3jDji6b4jJdGqmITNWi7OBIUY1/MxumPKaXBE=; b=etEZeDzGW7OGkKHEqhk20eDfch9YOaSmCxmLkB7tXGE+4QuHcLHc1KXqGzdarztT4p S3IshvalHWzp9uUplh/SZi9nX6YLmtSVHvpt+BmJRlWxpXmc7jT0HivvGUvnFoq7QGFS D0q/8XrgeP78l/Yy4bfxKzyuE5yyIMC8EDSSQF7/U4r0Y6evgTOoUbbOH8nX4On7xNuO AcL29t2x91hdh68Z1vGDuAfXUZMmcmL38umIur3quCLrWTLJA5fO9xPZwP4SzpVEwR1R oDc7FT61MU3Z62G8mX6vPSwTGhngKVBzEJlNTqEcChFw2Qo3rrR99T5DSK5r+hw6eGai mwLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=sm8BiF3jDji6b4jJdGqmITNWi7OBIUY1/MxumPKaXBE=; b=CX7oXUhPkn47LTFbx9kDjGiUyhFFaEk+OtIPH+Jb+RMQvafJDC34/r9/9wUzBjfDWX 91Q54n2AAjWUfcLLB7Wo3t3qkzkwaBToHA46ETBtZSwjT7iGXMZBCaRzL51FhsPbreYB 7eWaKae2dTNx5t8nCXnuxRm64pQ4LI3ecC/0UWuHanEMQvdoW9D/txFWXTzjjufMHX6v VeQqv3e8j3JQrx3ehHhvEcl+NHE/C2L4HG5eydeHuMJA0Cj3MPlvB6+yJ/YKMYfsT83q YFkkgakyMYkOUUgTynix85I8UpMGeyOo1aBxj1Sp+SFQsioWsWdF0kpqMnnBFvHOiytd 2v+w== X-Gm-Message-State: AOAM532ea/fng65b85lfuhFl1ekudJEntWvyvij2p7g63WfX66gudhPm ID03TjubRw0FiW3gjo2CMWE= X-Google-Smtp-Source: ABdhPJyxadp6yVTexH8HRnCkDKvCyTY1AAGLowERqzrxI6GaYNo6RwVEsiiOmMmbt++QiQstNJ4fbw== X-Received: by 2002:a17:907:728b:b0:6da:97db:b66d with SMTP id dt11-20020a170907728b00b006da97dbb66dmr2781814ejc.636.1646342086427; Thu, 03 Mar 2022 13:14:46 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id o21-20020a170906289500b006d144662b24sm1060095ejd.152.2022.03.03.13.14.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 13:14:45 -0800 (PST) Message-ID: Date: Fri, 4 Mar 2022 00:07:22 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Alper Nebi Yasak Subject: Re: [PATCH 09/24] dtoc: Support reading a list of arguments To: Simon Glass Cc: U-Boot Mailing List , huang lin , Jeffy Chen , Kever Yang , Tom Rini , Philippe Reynes , Ivan Mikhaylov , Walter Lozano References: <20220208185008.35843-1-sjg@chromium.org> <20220208185008.35843-8-sjg@chromium.org> <4f45167f-ec28-7535-940c-c7bb8f96db02@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 24/02/2022 01:58, Simon Glass wrote: > On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: >>> 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? > > Because the default value is for when there is no such property. In > this case there is a property, so the default will not be used. Ah, it's the same as dict.get(). Don't know why I got confused there. >>> + 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. > > That's actually not what I was trying to do. I want "-n first" to mean > two args. It is like normally command-line processing. > > Of course this means that it isn't possible to do what you want here. > I am not sure of a good way to support that. > > One way would be to only split into args if there is a single string > in the list? I will try that for now. That sounds like a reasonable middle ground if you really want to do splitting. >>> + 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. > > Well I am trying to keep all typing stuff in here, i.e. everything > that guesses what is meant by a DT property. That way I can have DT > tests and expand as needed. I agree this is a borderline case, but I'm > not sure it is a good to have lots of logic (that depends on the > internal working of Fdt) in a different file. E.g. I hate all of this > code and would like to refactor it to put more stuff in pylibfdt one > day. That's fair, and I like the idea of refactoring things into pylibfdt. >> >>> 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. > > I reverted the shlex change in the end...can we do that in a separate > patch? I think it has interesting implications for the Makefile and we > should think about what tests to add and what the use cases are. OK, but I'll need to focus on other things and might forget to ping later for this...