summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2023-09-27 19:16:16 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-09-28 12:38:26 +0100
commit826807785e955219c4405cba41d8092910a8058f (patch)
tree9686594141a747625bc94a55eaa691919bfcee0e /bitbake/bin
parent8eeb58cf4a34546ca0c5dd6518ece317d8706c40 (diff)
downloadpoky-826807785e955219c4405cba41d8092910a8058f.tar.gz
bitbake: bitbake-getvar: Add a (suppressable) error for undefined variables
If an undefined variable or variable flag is specified, bitbake-getvar will now fail with an error message indicating this. The error can be supressed with --ignore-undefined, which matches the previous behavior. This also changes the errors related to specifying --flag or --unexpand without --value so that they are sent to stderr rather than stdout. (Bitbake rev: 136b8dda4e8b6f4d7e45a552c2d2e278b3ae1b7d) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-getvar26
1 files changed, 17 insertions, 9 deletions
diff --git a/bitbake/bin/bitbake-getvar b/bitbake/bin/bitbake-getvar
index afd2849846..53ab900693 100755
--- a/bitbake/bin/bitbake-getvar
+++ b/bitbake/bin/bitbake-getvar
@@ -26,15 +26,15 @@ if __name__ == "__main__":
26 parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None) 26 parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None)
27 parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true") 27 parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true")
28 parser.add_argument('-q', '--quiet', help='Silence bitbake server logging', action="store_true") 28 parser.add_argument('-q', '--quiet', help='Silence bitbake server logging', action="store_true")
29 parser.add_argument('--ignore-undefined', help='Suppress any errors related to undefined variables', action="store_true")
29 args = parser.parse_args() 30 args = parser.parse_args()
30 31
31 if args.unexpand and not args.value: 32 if not args.value:
32 print("--unexpand only makes sense with --value") 33 if args.unexpand:
33 sys.exit(1) 34 sys.exit("--unexpand only makes sense with --value")
34 35
35 if args.flag and not args.value: 36 if args.flag:
36 print("--flag only makes sense with --value") 37 sys.exit("--flag only makes sense with --value")
37 sys.exit(1)
38 38
39 quiet = args.quiet or args.value 39 quiet = args.quiet or args.value
40 with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil: 40 with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not quiet) as tinfoil:
@@ -44,9 +44,17 @@ if __name__ == "__main__":
44 else: 44 else:
45 tinfoil.prepare(quiet=2, config_only=True) 45 tinfoil.prepare(quiet=2, config_only=True)
46 d = tinfoil.config_data 46 d = tinfoil.config_data
47
48 value = None
47 if args.flag: 49 if args.flag:
48 print(str(d.getVarFlag(args.variable, args.flag, expand=(not args.unexpand)))) 50 value = d.getVarFlag(args.variable, args.flag, expand=not args.unexpand)
49 elif args.value: 51 if value is None and not args.ignore_undefined:
50 print(str(d.getVar(args.variable, expand=(not args.unexpand)))) 52 sys.exit(f"The flag '{args.flag}' is not defined for variable '{args.variable}'")
53 else:
54 value = d.getVar(args.variable, expand=not args.unexpand)
55 if value is None and not args.ignore_undefined:
56 sys.exit(f"The variable '{args.variable}' is not defined")
57 if args.value:
58 print(str(value))
51 else: 59 else:
52 bb.data.emit_var(args.variable, d=d, all=True) 60 bb.data.emit_var(args.variable, d=d, all=True)