SConscript 960 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import os
  2. from building import *
  3. def modify_board_h_file(filepath, include_str):
  4. is_include_file_exist = False
  5. with open(filepath, mode='r') as f:
  6. for line in f:
  7. if include_str.strip() in line:
  8. is_include_file_exist = True
  9. break
  10. if not is_include_file_exist:
  11. w_str = ""
  12. with open(filepath, mode='r') as f:
  13. for line in f:
  14. if '#define __BOARD_H__' in line:
  15. w_str += line
  16. w_str += include_str
  17. else:
  18. w_str += line
  19. with open(filepath, mode='w') as f:
  20. f.write(w_str)
  21. cwd = GetCurrentDir()
  22. group = DefineGroup('', [], depend=[''], CPPPATH=[])
  23. file_path = "board.h"
  24. include_str = """
  25. #include <stm32f4xx.h>
  26. #include <drv_common.h>
  27. """
  28. modify_board_h_file(os.path.join(cwd, file_path), include_str)
  29. os.remove(os.path.join(cwd,"SConscript"))
  30. Return('group')