sdk_dist.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. print("library_path ",library_path)
  12. library_dir = os.path.join(dist_dir, 'libraries')
  13. print("library_dir ",library_dir)
  14. print("=> copy bsp drivers")
  15. bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers'))
  16. print("=> copy bsp CMSIS")
  17. bsp_copy_files(os.path.join(library_path, 'bl_mcu_sdk'), os.path.join(library_dir, 'bl_mcu_sdk'))
  18. print("=> copy bsp library")
  19. shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
  20. # change RTT_ROOT in Kconfig
  21. if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
  22. return
  23. with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
  24. data = f.readlines()
  25. with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
  26. found = 0
  27. for line in data:
  28. if line.find('RTT_ROOT') != -1:
  29. found = 1
  30. if line.find('../../libraries') != -1 and found:
  31. position = line.find('../../libraries')
  32. line = line[0:position] + 'libraries"\n'
  33. found = 0
  34. f.write(line)