From b18c7b04a76355e763b58752513c343b28ed3d0b Mon Sep 17 00:00:00 2001 From: Nick Exton Date: Fri, 6 Oct 2023 09:15:22 +1100 Subject: [PATCH] tools: Add option to mavgen.py to return exit code if generation fails --- tools/mavgen.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/mavgen.py b/tools/mavgen.py index 672e97404..85d73e26f 100755 --- a/tools/mavgen.py +++ b/tools/mavgen.py @@ -25,7 +25,10 @@ parser.add_argument("--no-validate", action="store_false", dest="validate", default=mavgen.DEFAULT_VALIDATE, help="Do not perform XML validation. Can speed up code generation if XML files are known to be correct.") parser.add_argument("--error-limit", default=mavgen.DEFAULT_ERROR_LIMIT, help="maximum number of validation errors to display") parser.add_argument("--strict-units", action="store_true", dest="strict_units", default=mavgen.DEFAULT_STRICT_UNITS, help="Perform validation of units attributes.") +parser.add_argument("--exit-code", action="store_true", dest="exit_code", default=False, help="Return an error code if generation fails.") parser.add_argument("definitions", metavar="XML", nargs="+", help="MAVLink definitions") args = parser.parse_args() -mavgen.mavgen(args, args.definitions) +ok = mavgen.mavgen(args, args.definitions) +if not ok and args.exit_code: + exit(1)