mirror of https://github.com/RT-Thread/rt-thread
[tools] add vsc_workspace target in scons.
This commit is contained in:
parent
935e1b1db1
commit
1a07d6926b
|
@ -58,6 +58,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||
AddOptions()
|
||||
|
||||
Env = env
|
||||
# export the default environment
|
||||
Export('env')
|
||||
|
||||
# prepare logging and set log
|
||||
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
||||
|
@ -89,6 +91,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||
'vs':('msvc', 'cl'),
|
||||
'vs2012':('msvc', 'cl'),
|
||||
'vsc' : ('gcc', 'gcc'),
|
||||
'vsc_workspace':('gcc', 'gcc'),
|
||||
'cb':('keil', 'armcc'),
|
||||
'ua':('gcc', 'gcc'),
|
||||
'cdk':('gcc', 'gcc'),
|
||||
|
@ -848,6 +851,10 @@ def GenTargetProject(program = None):
|
|||
from vscpyocd import GenerateVSCodePyocdConfig
|
||||
GenerateVSCodePyocdConfig(GetOption('cmsispack'))
|
||||
|
||||
if GetOption('target') == 'vsc_workspace':
|
||||
from targets.vsc import GenerateVSCodeWorkspace
|
||||
GenerateVSCodeWorkspace(Env)
|
||||
|
||||
if GetOption('target') == 'cdk':
|
||||
from targets.cdk import CDKProject
|
||||
CDKProject(GetOption('project-name') + '.cdkproj', Projects)
|
||||
|
|
|
@ -73,7 +73,7 @@ def AddOptions():
|
|||
AddOption('--target',
|
||||
dest = 'target',
|
||||
type = 'string',
|
||||
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
|
||||
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake/vsc_workspace')
|
||||
AddOption('--cmsispack',
|
||||
dest = 'cmsispack',
|
||||
type = 'string',
|
||||
|
|
|
@ -30,6 +30,7 @@ import os
|
|||
import json
|
||||
import utils
|
||||
import rtconfig
|
||||
from SCons.Script import *
|
||||
|
||||
from utils import _make_path_relative
|
||||
def find_first_node_with_two_children(tree):
|
||||
|
@ -216,14 +217,14 @@ def GenerateCFiles(env):
|
|||
cc = os.path.abspath(cc).replace('\\', '/')
|
||||
|
||||
config_obj = {}
|
||||
config_obj['name'] = 'rt-thread'
|
||||
config_obj['name'] = 'Linux'
|
||||
config_obj['defines'] = info['CPPDEFINES']
|
||||
|
||||
intelliSenseMode = 'gcc-arm'
|
||||
intelliSenseMode = 'linux-gcc-arm'
|
||||
if cc.find('aarch64') != -1:
|
||||
intelliSenseMode = 'gcc-arm64'
|
||||
intelliSenseMode = 'linux-gcc-arm64'
|
||||
elif cc.find('arm') != -1:
|
||||
intelliSenseMode = 'gcc-arm'
|
||||
intelliSenseMode = 'linux-gcc-arm'
|
||||
config_obj['intelliSenseMode'] = intelliSenseMode
|
||||
config_obj['compilerPath'] = cc
|
||||
config_obj['cStandard'] = "c99"
|
||||
|
@ -338,3 +339,58 @@ def GenerateVSCode(env):
|
|||
print('Done!')
|
||||
|
||||
return
|
||||
|
||||
def GenerateVSCodeWorkspace(env):
|
||||
"""
|
||||
Generate vscode.code files
|
||||
"""
|
||||
print('Update workspace files for VSCode...')
|
||||
|
||||
# get the launch directory
|
||||
cwd = GetLaunchDir()
|
||||
|
||||
# check if .vscode folder exists, if not, create it
|
||||
if not os.path.exists(os.path.join(cwd, '.vscode')):
|
||||
os.mkdir(os.path.join(cwd, '.vscode'))
|
||||
|
||||
vsc_file = open(os.path.join(cwd, '.vscode/c_cpp_properties.json'), 'w')
|
||||
if vsc_file:
|
||||
info = utils.ProjectInfo(env)
|
||||
|
||||
cc = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
|
||||
cc = os.path.abspath(cc).replace('\\', '/')
|
||||
|
||||
config_obj = {}
|
||||
config_obj['name'] = 'Linux'
|
||||
config_obj['defines'] = info['CPPDEFINES']
|
||||
|
||||
intelliSenseMode = 'linux-gcc-arm'
|
||||
if cc.find('aarch64') != -1:
|
||||
intelliSenseMode = 'linux-gcc-arm64'
|
||||
elif cc.find('arm') != -1:
|
||||
intelliSenseMode = 'linux-gcc-arm'
|
||||
config_obj['intelliSenseMode'] = intelliSenseMode
|
||||
config_obj['compilerPath'] = cc
|
||||
config_obj['cStandard'] = "c99"
|
||||
config_obj['cppStandard'] = "c++11"
|
||||
|
||||
# format "a/b," to a/b. remove first quotation mark("),and remove end (",)
|
||||
includePath = []
|
||||
for i in info['CPPPATH']:
|
||||
if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",':
|
||||
includePath.append(_make_path_relative(cwd, i[1:len(i) - 2]))
|
||||
else:
|
||||
includePath.append(_make_path_relative(cwd, i))
|
||||
# make sort for includePath
|
||||
includePath = sorted(includePath, key=lambda x: x.lower())
|
||||
config_obj['includePath'] = includePath
|
||||
|
||||
json_obj = {}
|
||||
json_obj['configurations'] = [config_obj]
|
||||
|
||||
vsc_file.write(json.dumps(json_obj, ensure_ascii=False, indent=4))
|
||||
vsc_file.close()
|
||||
|
||||
print('Done!')
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue