From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 16/16 v2] Makefile: introduce show-vars, a json-formatted equivalent to printvars
Date: Thu, 30 Dec 2021 21:47:09 +0100 [thread overview]
Message-ID: <20211230214709.6e77b534@windsurf> (raw)
In-Reply-To: <dac8f92abae72426b9b1c19f1a3ee5e173d101e3.1636810092.git.yann.morin.1998@free.fr>
On Sat, 13 Nov 2021 14:28:27 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> The current printvars output suffers from a serious design flaw:
> variables are not delimited, which makes it impossible to reliably
> retrieve the value of variables; only variables that are known to
> not contain a \n can be relatively safely extracted.
>
> However, in some cases, it is important to be able to retrieve the
> multi-line value of a variable, notably the CMDS or the hooks. One
> such use-case (to follow in an unscheduled future) would be to hash
> the variables that make up a package "configuration", and cache or
> extract the files for that package to speed up the build.
>
> Modeled after printvars and show-info, we introduce show-vars (what a
> lack of imagination here) that outputs a json dictionary which keys are
> the variable names, and for each variable, provides the raw and expanded
> values.
>
> Unlike printvars, we do not provide a way to get either the raw or
> expanded value; both are systematically printed; a user will get just
> the one is needs. Additionally, strings in JSON are quoted, so there is
> no need to provide a way to quote variables; that would not make sense.
>
> Note: for printvars, we require that the user provides an explicit
> pattern to filter variables on. This is historical (see fd5bd12379dc,
> Makefile: printvars: don't print anything when VARS is not set). The
> underlying reasoning was that printvars is too "raw", and variables are
> not well delimited, so printvars was mostly used to extract a few values
> here and there, from scripts, or to quickly inspect a specific package's
> variables during debugging.
>
> But show-vars, although technically plain-text, being JSON, is not very
> human-readable, and is mostly aimed at tools that will parse it with a
> real JSON parser, and which will want to have a complete view of a lot
> of variables at once. As such, and contrary to printvars, it makes sense
> to report on all variables by default, unless the user explicitly
> requested a subset.
>
> As a final note: a lot of our variables only make sense in the context
> of an actual make target. For example, a variable of package foo, that
> contains $(@D)/bar, would expand to .../build/FOO-VERSION/bar. This is
> because our CMDS and hooks are expanded as the recipe of a stamp file
> that lies in the package build directory.
>
> But for show-info, this falls flat on its face: it is not the stamp file
> of a package, so there is no package directory, and show-info itself has
> not directory part, so $(@D) expands to '.' (dot).
>
> Additionally, some variables may contain calls to $(shell) (e.g. to call
> pkg-config), and this also does not work with show-info.
>
> These two issues make it impossible to emit the correct expanded value
> of variables. To be noted: printvars has the exact same limitations for
> the exact same reasons.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
> Makefile | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
Applied to master, thanks.
However, there are two things that are missing:
(1) Update to the Buildroot manual
(2) At least one test case in supporting/testing/
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2021-12-30 20:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-13 13:28 [Buildroot] [PATCH 00/16 v2] core: add show-vars, a json-formatted equivalent to printvars (branch yem/show-vars) Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 01/16 v2] core/show-info: report build_dir relative to CONFIG_DIR Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 02/16 v2] package/kodi-*: run pkg-config at build time, not at parse time Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 03/16 v2] support/dependencies: avoid spurious warning on print-vars Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 04/16 v2] package/infras: do not conditionally set empty variables Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 05/16 v2] package/pkg-python: do not " Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 06/16 v2] core/pkg-generic: also list files installed in images/ Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 07/16 v2] Makefile: really comment syntax colouring Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 08/16 v2] core/show-info: 'name' only applies to packages Yann E. MORIN
2021-12-12 22:18 ` Peter Korsgaard
2021-11-13 13:28 ` [Buildroot] [PATCH 09/16 v2] support/utils: make-comma-list does just that, not quoting Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 10/16 v2] support/misc/utils: introduce $(tab)=\t and $(escape)=\x1b Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 11/16 v2] package/pkg-utils: introduce helper to properly json-escape a string Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 12/16 v2] package/pkg-utils: generate proper JSON strings where they are emitted Yann E. MORIN
2021-12-30 20:43 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 13/16 v2] core/show-info: report whether a package is overriden Yann E. MORIN
2021-12-30 20:45 ` Thomas Petazzoni
2021-12-31 17:28 ` Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 14/16 v2] core/show-info: also export source and stamp directories in show-info Yann E. MORIN
2021-12-30 20:45 ` Thomas Petazzoni
2021-11-13 13:28 ` [Buildroot] [PATCH 15/16 v2] core/show-info: report package build steps and stamp files Yann E. MORIN
2021-12-30 20:46 ` Thomas Petazzoni
2021-12-31 18:03 ` Yann E. MORIN
2021-11-13 13:28 ` [Buildroot] [PATCH 16/16 v2] Makefile: introduce show-vars, a json-formatted equivalent to printvars Yann E. MORIN
2021-12-30 20:47 ` Thomas Petazzoni [this message]
2021-12-04 19:12 ` [Buildroot] [PATCH 00/16 v2] core: add show-vars, a json-formatted equivalent to printvars (branch yem/show-vars) Yann E. MORIN
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=20211230214709.6e77b534@windsurf \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@buildroot.org \
--cc=yann.morin.1998@free.fr \
/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