sdk_dist.py 1.3 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. def dist_modify_relative_path(board_kconfig_path):
  7. # Read in the file
  8. with open(board_kconfig_path, 'r') as file :
  9. filedata = file.read()
  10. # Replace the target string
  11. filedata = filedata.replace('$BSP_DIR/../libraries', './libraries')
  12. # Write the file out again
  13. with open(board_kconfig_path, 'w') as file:
  14. file.write(filedata)
  15. # BSP dist function
  16. def dist_do_building(BSP_ROOT, dist_dir):
  17. from mkdist import bsp_copy_files
  18. import rtconfig
  19. library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
  20. library_dir = os.path.join(dist_dir, 'libraries')
  21. print('=> copy nuvoton bsp drivers')
  22. bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
  23. os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
  24. print('=> copy nu_packages')
  25. bsp_copy_files(os.path.join(library_path, 'nu_packages'),
  26. os.path.join(library_dir, 'nu_packages'))
  27. print('=> copy Kconfig')
  28. shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
  29. print('=> Modify libraries relative path in board/Kconfig ')
  30. dist_modify_relative_path(os.path.join(dist_dir, 'board', 'Kconfig'))