Skip to content

Commit

Permalink
bitbake-listflags: add new script
Browse files Browse the repository at this point in the history
to list all bitbake flags of a variable, potentially
including values

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Oct 20, 2024
1 parent 1d465e8 commit 6ee67c2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ A collection of build utils to be used with YOCTO

## Available scripts

| script | summary | documentation |
| ---------------- | ------------------------------------------------------------------- | --------------------------------------- |
| bitbake-listvars | list all defined bitbake variable | [docu](docs/scripts-bitbakelistvars.md) |
| dot2tree | create filterable trees from recipe info | [docu](docs/scripts-dot2tree.md) |
| newlayercheck | check a layer for possible corruptions/changes of an existing stack | [docu](docs/scripts-newlayercheck.md) |
| unused | identify unused recipes in a layer | [docu](docs/scripts-unused.md) |
| script | summary | documentation |
| ----------------- | ------------------------------------------------------------------- | ---------------------------------------- |
| bitbake-listflags | list all defined flgas of a bitbake variable | [docu](docs/scripts-bitbakelistflags.md) |
| bitbake-listvars | list all defined bitbake variable | [docu](docs/scripts-bitbakelistvars.md) |
| dot2tree | create filterable trees from recipe info | [docu](docs/scripts-dot2tree.md) |
| newlayercheck | check a layer for possible corruptions/changes of an existing stack | [docu](docs/scripts-newlayercheck.md) |
| unused | identify unused recipes in a layer | [docu](docs/scripts-unused.md) |
11 changes: 11 additions & 0 deletions docs/scripts-bitbake-listflags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# bitbake-listflags

List all defined variable flags

## Usage

From a setup OE/Yocto build

```shell
<path to checkout>/scripts/bitbake-listflags $(which bitbake) <var>
```
54 changes: 54 additions & 0 deletions scripts/bitbake-listflags
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /usr/bin/env python3
# Copyright (C) 2021 Richard Purdie
# Copyright (c) 2024, Konrad Weihmann
# SPDX-License-Identifier: GPL-2.0-only

# Based on bitbake-getvar
# Lists all defined flags of a variable

import argparse
import os
import sys
import warnings


def main(args=None):
parser = argparse.ArgumentParser(description="Bitbake List Flags")
parser.add_argument(
'-q', '--quiet', help='Silence bitbake server logging', action="store_true")
parser.add_argument('-v', '--value', action='store_true',
help='Print with value')
parser.add_argument('bitbake', help='Path to bitbake binary')
parser.add_argument('var', help='Variable to poll for')
args = parser.parse_args()

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

import bb.tinfoil

quiet = args.quiet
with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil:
tinfoil.prepare(quiet=2, config_only=True)
d = tinfoil.config_data

for k, v in d.getVarFlags(args.var).items():
if ':' in k:
continue
if k.startswith('_'):
continue
if args.value:
yield (k, v)
else:
yield k


if __name__ == "__main__":
warnings.simplefilter("default")
result = main()
for item in result:
if isinstance(item, tuple):
print(f'{item[0]}:{item[1]}')
else:
print(item)

0 comments on commit 6ee67c2

Please sign in to comment.