track.py 1.9 KB

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