unleashed-firmware/scripts/meta.py
Anna Prosvetova f8542af653
[FL-1989] CI: bootloader & firmware JSON manifests (#786)
* [FL-1989] CI: bootloader & firmware JSON manifests
* CI: reorder steps

Co-authored-by: あく <alleteam@gmail.com>
2021-10-26 18:33:38 +03:00

32 lines
977 B
Python

#!/usr/bin/env python3
import argparse
import json
class Main:
def __init__(self):
# parse CFLAGS
self.parser = argparse.ArgumentParser(allow_abbrev=False)
self.parser.add_argument("-p", dest="project", required=True)
self.parser.add_argument("-DBUILD_DATE", dest="build_date", required=True)
self.parser.add_argument("-DGIT_COMMIT", dest="commit", required=True)
self.parser.add_argument("-DGIT_BRANCH", dest="branch", required=True)
self.parser.add_argument("-DTARGET", dest="target", type=int, required=True)
def __call__(self):
self.args, _ = self.parser.parse_known_args()
meta = {}
for k, v in vars(self.args).items():
if k == "project":
continue
if isinstance(v, str):
v = v.strip('"')
meta[self.args.project + "_" + k] = v
print(json.dumps(meta, indent=4))
if __name__ == "__main__":
Main()()