export_project.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. import shutil
  3. import argparse
  4. parser = argparse.ArgumentParser()
  5. parser.description='please enter two parameters <project-name> and <export-path> ...'
  6. parser.add_argument("-n", "--name", help="project name", type=str, default="phytium-a32")
  7. parser.add_argument("-o", "--output", help="export path", type=str, default="./phytium-a32")
  8. args = parser.parse_args()
  9. print('=== Exporting Phytium BSP for RT-Studio ====')
  10. board_src_path = os.path.abspath(r'../board')
  11. librs_src_path = os.path.abspath(r'../libraries')
  12. board_dst_path = os.path.abspath(r'./board')
  13. librs_dst_path = os.path.abspath(r'./libraries')
  14. print(' Copying BSP board from {} to {}'.format(board_src_path, board_dst_path))
  15. print(' Copying BSP libraries from {} to {}'.format(librs_src_path, librs_dst_path))
  16. if os.path.exists(board_dst_path):
  17. shutil.rmtree(board_dst_path)
  18. if os.path.exists(librs_dst_path):
  19. shutil.rmtree(librs_dst_path)
  20. shutil.copytree(board_src_path, board_dst_path)
  21. shutil.copytree(librs_src_path, librs_dst_path)
  22. os.system('scons --dist-ide --project-name={} --project-path={}'.format(args.name, args.output))
  23. if os.path.exists(board_dst_path):
  24. shutil.rmtree(board_dst_path)
  25. if os.path.exists(librs_dst_path):
  26. shutil.rmtree(librs_dst_path)