SConscript 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import os
  2. import sys
  3. import rtconfig
  4. from building import *
  5. def get_source(ic_model, file_path, system_path, base_path):
  6. source_path = []
  7. files_list = []
  8. readafter = 0
  9. if not os.path.isfile(file_path):
  10. return
  11. with open(file_path, 'r') as file:
  12. # content = file.read()
  13. for line in file:
  14. if readafter == 2 and line.find('>') != -1:
  15. break
  16. if readafter == 2:
  17. files_list.append(line.strip())
  18. if line.find(ic_model) != -1:
  19. readafter = 1
  20. if readafter == 1 and line.find('<') != -1:
  21. readafter = 2
  22. for line in files_list:
  23. if line.find('system') != -1:
  24. source_path.append(os.path.join(system_path, line.strip()))
  25. else:
  26. source_path.append(os.path.join(base_path, line.strip()))
  27. return source_path
  28. Import('rtconfig')
  29. tools_path = os.path.normpath(os.getcwd() + '../../..' + '/tools')
  30. sys.path.append(tools_path)
  31. source_file_path = os.path.join(os.getcwd(), 'Source_file')
  32. base_path = 'library/HT32F1xxxx_Driver/src/'
  33. system_path = 'library/Device/Holtek/HT32F1xxxx/Source/'
  34. source_path = []
  35. ic_list = [
  36. 'HT32F1654',
  37. 'HT32F1656',
  38. 'HT32F12345',
  39. 'HT32F12364',
  40. 'HT32F12366'
  41. ]
  42. cwd = GetCurrentDir()
  43. src = []
  44. for ic_name in ic_list:
  45. if GetDepend(['SOC_' + ic_name]):
  46. source_path = get_source(ic_name,source_file_path,system_path,base_path)
  47. src = Split(source_path)
  48. path = [
  49. cwd + '/library/HT32F1xxxx_Driver/inc',
  50. cwd + '/library/CMSIS/Include',
  51. cwd + '/library/Device/Holtek/HT32F1xxxx/Include'
  52. ]
  53. CPPDEFINES = ['USE_HT32_DRIVER']
  54. group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
  55. Return('group')