[tools] add project.json generation in vsc.py.
This commit is contained in:
parent
eb79397557
commit
d243031e17
40
tools/vsc.py
40
tools/vsc.py
|
@ -30,6 +30,7 @@ import os
|
||||||
import json
|
import json
|
||||||
import utils
|
import utils
|
||||||
import rtconfig
|
import rtconfig
|
||||||
|
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
|
|
||||||
def delete_repeatelist(data):
|
def delete_repeatelist(data):
|
||||||
|
@ -113,8 +114,47 @@ def GenerateCFiles(env):
|
||||||
vsc_space_file.close()
|
vsc_space_file.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def GenerateProjectFiles(env):
|
||||||
|
"""
|
||||||
|
Generate c_cpp_properties files
|
||||||
|
"""
|
||||||
|
if not os.path.exists('.vscode'):
|
||||||
|
os.mkdir('.vscode')
|
||||||
|
|
||||||
|
project = env['project']
|
||||||
|
vsc_file = open('.vscode/project.json', 'w')
|
||||||
|
if vsc_file:
|
||||||
|
groups = []
|
||||||
|
for group in project:
|
||||||
|
if len(group['src']) > 0:
|
||||||
|
item = {}
|
||||||
|
item['name'] = group['name']
|
||||||
|
item['path'] = _make_path_relative(os.getcwd(), group['path'])
|
||||||
|
item['files'] = []
|
||||||
|
|
||||||
|
for fn in group['src']:
|
||||||
|
item['files'].append(str(fn))
|
||||||
|
|
||||||
|
# append SConscript if exist
|
||||||
|
if os.path.exists(os.path.join(item['path'], 'SConscript')):
|
||||||
|
item['files'].append(os.path.join(item['path'], 'SConscript'))
|
||||||
|
|
||||||
|
groups.append(item)
|
||||||
|
|
||||||
|
json_dict = {}
|
||||||
|
json_dict['RT-Thread'] = env['RTT_ROOT']
|
||||||
|
json_dict['Groups'] = groups
|
||||||
|
|
||||||
|
# write groups to project.json
|
||||||
|
vsc_file.write(json.dumps(json_dict, ensure_ascii=False, indent=4))
|
||||||
|
vsc_file.close()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
def GenerateVSCode(env):
|
def GenerateVSCode(env):
|
||||||
print('Update setting files for VSCode...')
|
print('Update setting files for VSCode...')
|
||||||
|
|
||||||
|
GenerateProjectFiles(env)
|
||||||
GenerateCFiles(env)
|
GenerateCFiles(env)
|
||||||
print('Done!')
|
print('Done!')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue