vsc.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #
  2. # File : vsc.py
  3. # This file is part of RT-Thread RTOS
  4. # COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. #
  20. # Change Logs:
  21. # Date Author Notes
  22. # 2018-05-30 Bernard The first version
  23. """
  24. Utils for VSCode
  25. """
  26. import os
  27. import json
  28. import utils
  29. import rtconfig
  30. def GenerateCFiles(env):
  31. """
  32. Generate c_cpp_properties files
  33. """
  34. if not os.path.exists('.vscode'):
  35. os.mkdir('.vscode')
  36. vsc_file = file('.vscode/c_cpp_properties.json', 'wb')
  37. if vsc_file:
  38. info = utils.ProjectInfo(env)
  39. cc = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
  40. cc = os.path.abspath(cc).replace('\\', '/')
  41. config_obj = {}
  42. config_obj['name'] = 'Win32'
  43. config_obj['includePath'] = info['CPPPATH']
  44. config_obj['defines'] = info['CPPDEFINES']
  45. config_obj['intelliSenseMode'] = 'clang-x64'
  46. config_obj['compilerPath'] = cc
  47. config_obj['cStandard'] = "c99"
  48. config_obj['cppStandard'] = "c++11"
  49. json_obj = {}
  50. json_obj['configurations'] = [config_obj]
  51. vsc_file.write(json.dumps(json_obj))
  52. vsc_file.close()
  53. return
  54. def GenerateVSCode(env):
  55. print('Update setting files for VSCode...'),
  56. GenerateCFiles(env)
  57. print('Done!')
  58. return