1#!/usr/bin/env python3 2# Copyright (c) 2021 Intel Corporation 3# 4# SPDX-License-Identifier: Apache-2.0 5 6import csv 7import subprocess 8from git import Git 9import pathlib 10import shutil 11import argparse 12 13def parse_args(): 14 parser = argparse.ArgumentParser( 15 description="Generate footprint data based on a predefined plan.", 16 allow_abbrev=False) 17 parser.add_argument("-p", "--plan", help="Path of test plan", required=True) 18 19 return parser.parse_args() 20 21def main(): 22 args = parse_args() 23 g = Git(".") 24 version = g.describe("--abbrev=12") 25 pathlib.Path(f'footprint_data/{version}').mkdir(exist_ok=True, parents=True) 26 27 with open(args.plan) as csvfile: 28 csvreader = csv.reader(csvfile) 29 for row in csvreader: 30 name=row[0] 31 feature=row[1] 32 board=row[2] 33 app=row[3] 34 options=row[4] 35 36 cmd = ['west', 37 'build', 38 '-d', 39 f'out/{name}/{feature}/{board}', 40 '-b', 41 board, 42 f'{app}', 43 '-t', 44 'footprint'] 45 46 if options != '': 47 cmd += ['--', f'{options}'] 48 49 print(" ".join(cmd)) 50 51 52 try: 53 subprocess.check_output(cmd, stderr=subprocess.STDOUT, timeout=120, universal_newlines=True) 54 print("Copying files...") 55 pathlib.Path(f'footprint_data/{version}/{name}/{feature}/{board}').mkdir(parents=True, exist_ok=True) 56 57 shutil.copy(f'out/{name}/{feature}/{board}/ram.json', f'footprint_data/{version}/{name}/{feature}/{board}') 58 shutil.copy(f'out/{name}/{feature}/{board}/rom.json', f'footprint_data/{version}/{name}/{feature}/{board}') 59 except subprocess.CalledProcessError as exc: 60 print("Status : FAIL", exc.returncode, exc.output) 61 62 63if __name__ == "__main__": 64 main() 65