Files
poky/bitbake/bin/bitbake-getvar
Peter Kjellerstedt 0dbc45e52f bitbake: bitbake-getvar: Make --value imply --quiet
It does not make any sense to get log output from bitbake-getvar when
the --value option is used as the log output is sent to stdout and thus
interferes with the output of the variable's value.

(Bitbake rev: 6b7883533af9c14d80a9f1ae5142644f155b5dee)

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-26 10:37:17 +01:00

1.9 KiB
Executable File

#! /usr/bin/env python3

Copyright (C) 2021 Richard Purdie

SPDX-License-Identifier: GPL-2.0-only

import argparse import io import os import sys import warnings warnings.simplefilter("default")

bindir = os.path.dirname(file) topdir = os.path.dirname(bindir) sys.path[0:0] = [os.path.join(topdir, 'lib')]

import bb.tinfoil

if name == "main": parser = argparse.ArgumentParser(description="Bitbake Query Variable") parser.add_argument("variable", help="variable name to query") parser.add_argument("-r", "--recipe", help="Recipe name to query", default=None, required=False) parser.add_argument('-u', '--unexpand', help='Do not expand the value (with --value)', action="store_true") parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None) parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true") parser.add_argument('-q', '--quiet', help='Silence bitbake server logging', action="store_true") args = parser.parse_args()

if args.unexpand and not args.value:
    print("--unexpand only makes sense with --value")
    sys.exit(1)

if args.flag and not args.value:
    print("--flag only makes sense with --value")
    sys.exit(1)

quiet = args.quiet or args.value
with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil:
    if args.recipe:
        tinfoil.prepare(quiet=3 if quiet else 2)
        d = tinfoil.parse_recipe(args.recipe)
    else:
        tinfoil.prepare(quiet=2, config_only=True)
        d = tinfoil.config_data
    if args.flag:
        print(str(d.getVarFlag(args.variable, args.flag, expand=(not args.unexpand))))
    elif args.value:
        print(str(d.getVar(args.variable, expand=(not args.unexpand))))
    else:
        bb.data.emit_var(args.variable, d=d, all=True)