mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-31 20:05:59 +08:00
[tools] add vsc_workspace target in scons.
This commit is contained in:
@@ -58,6 +58,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
AddOptions()
|
AddOptions()
|
||||||
|
|
||||||
Env = env
|
Env = env
|
||||||
|
# export the default environment
|
||||||
|
Export('env')
|
||||||
|
|
||||||
# prepare logging and set log
|
# prepare logging and set log
|
||||||
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
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'),
|
'vs':('msvc', 'cl'),
|
||||||
'vs2012':('msvc', 'cl'),
|
'vs2012':('msvc', 'cl'),
|
||||||
'vsc' : ('gcc', 'gcc'),
|
'vsc' : ('gcc', 'gcc'),
|
||||||
|
'vsc_workspace':('gcc', 'gcc'),
|
||||||
'cb':('keil', 'armcc'),
|
'cb':('keil', 'armcc'),
|
||||||
'ua':('gcc', 'gcc'),
|
'ua':('gcc', 'gcc'),
|
||||||
'cdk':('gcc', 'gcc'),
|
'cdk':('gcc', 'gcc'),
|
||||||
@@ -848,6 +851,10 @@ def GenTargetProject(program = None):
|
|||||||
from vscpyocd import GenerateVSCodePyocdConfig
|
from vscpyocd import GenerateVSCodePyocdConfig
|
||||||
GenerateVSCodePyocdConfig(GetOption('cmsispack'))
|
GenerateVSCodePyocdConfig(GetOption('cmsispack'))
|
||||||
|
|
||||||
|
if GetOption('target') == 'vsc_workspace':
|
||||||
|
from targets.vsc import GenerateVSCodeWorkspace
|
||||||
|
GenerateVSCodeWorkspace(Env)
|
||||||
|
|
||||||
if GetOption('target') == 'cdk':
|
if GetOption('target') == 'cdk':
|
||||||
from targets.cdk import CDKProject
|
from targets.cdk import CDKProject
|
||||||
CDKProject(GetOption('project-name') + '.cdkproj', Projects)
|
CDKProject(GetOption('project-name') + '.cdkproj', Projects)
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ def AddOptions():
|
|||||||
AddOption('--target',
|
AddOption('--target',
|
||||||
dest = 'target',
|
dest = 'target',
|
||||||
type = 'string',
|
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',
|
AddOption('--cmsispack',
|
||||||
dest = 'cmsispack',
|
dest = 'cmsispack',
|
||||||
type = 'string',
|
type = 'string',
|
||||||
|
|||||||
+60
-4
@@ -30,6 +30,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import utils
|
import utils
|
||||||
import rtconfig
|
import rtconfig
|
||||||
|
from SCons.Script import *
|
||||||
|
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
def find_first_node_with_two_children(tree):
|
def find_first_node_with_two_children(tree):
|
||||||
@@ -216,14 +217,14 @@ def GenerateCFiles(env):
|
|||||||
cc = os.path.abspath(cc).replace('\\', '/')
|
cc = os.path.abspath(cc).replace('\\', '/')
|
||||||
|
|
||||||
config_obj = {}
|
config_obj = {}
|
||||||
config_obj['name'] = 'rt-thread'
|
config_obj['name'] = 'Linux'
|
||||||
config_obj['defines'] = info['CPPDEFINES']
|
config_obj['defines'] = info['CPPDEFINES']
|
||||||
|
|
||||||
intelliSenseMode = 'gcc-arm'
|
intelliSenseMode = 'linux-gcc-arm'
|
||||||
if cc.find('aarch64') != -1:
|
if cc.find('aarch64') != -1:
|
||||||
intelliSenseMode = 'gcc-arm64'
|
intelliSenseMode = 'linux-gcc-arm64'
|
||||||
elif cc.find('arm') != -1:
|
elif cc.find('arm') != -1:
|
||||||
intelliSenseMode = 'gcc-arm'
|
intelliSenseMode = 'linux-gcc-arm'
|
||||||
config_obj['intelliSenseMode'] = intelliSenseMode
|
config_obj['intelliSenseMode'] = intelliSenseMode
|
||||||
config_obj['compilerPath'] = cc
|
config_obj['compilerPath'] = cc
|
||||||
config_obj['cStandard'] = "c99"
|
config_obj['cStandard'] = "c99"
|
||||||
@@ -338,3 +339,58 @@ def GenerateVSCode(env):
|
|||||||
print('Done!')
|
print('Done!')
|
||||||
|
|
||||||
return
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user