sdk_dist.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. import sys
  3. import shutil
  4. cwd_path = os.getcwd()
  5. sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
  6. # BSP dist function
  7. def dist_do_building(BSP_ROOT, dist_dir):
  8. from mkdist import bsp_copy_files
  9. import rtconfig
  10. library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
  11. library_dir = os.path.join(dist_dir, 'Libraries')
  12. print("=> copy bsp drivers")
  13. bsp_copy_files(os.path.join(library_path, 'drivers'), os.path.join(library_dir, 'drivers'))
  14. print("=> copy bsp CMSIS")
  15. bsp_copy_files(os.path.join(library_path, 'CMSIS'), os.path.join(library_dir, 'CMSIS'))
  16. print("=> copy bsp library")
  17. bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
  18. shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
  19. # change RTT_ROOT in Kconfig
  20. if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
  21. return
  22. with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
  23. data = f.readlines()
  24. with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
  25. found = 0
  26. for line in data:
  27. if line.find('RTT_ROOT') != -1:
  28. found = 1
  29. if line.find('../Libraries') != -1 and found:
  30. position = line.find('../Libraries')
  31. line = line[0:position] + 'Libraries/Kconfig"\n'
  32. found = 0
  33. f.write(line)