Clone of official tools

Committer:
The Other Jimmy
Date:
Thu Jun 22 11:12:28 2017 -0500
Revision:
36:96847d42f010
Child:
40:7d3fa6b99b2b
Tools release 5.5.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
The Other Jimmy 36:96847d42f010 1 # mbed SDK
The Other Jimmy 36:96847d42f010 2 # Copyright (c) 2011-2016 ARM Limited
The Other Jimmy 36:96847d42f010 3 #
The Other Jimmy 36:96847d42f010 4 # Licensed under the Apache License, Version 2.0 (the "License");
The Other Jimmy 36:96847d42f010 5 # you may not use this file except in compliance with the License.
The Other Jimmy 36:96847d42f010 6 # You may obtain a copy of the License at
The Other Jimmy 36:96847d42f010 7 #
The Other Jimmy 36:96847d42f010 8 # http://www.apache.org/licenses/LICENSE-2.0
The Other Jimmy 36:96847d42f010 9 #
The Other Jimmy 36:96847d42f010 10 # Unless required by applicable law or agreed to in writing, software
The Other Jimmy 36:96847d42f010 11 # distributed under the License is distributed on an "AS IS" BASIS,
The Other Jimmy 36:96847d42f010 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
The Other Jimmy 36:96847d42f010 13 # See the License for the specific language governing permissions and
The Other Jimmy 36:96847d42f010 14 # limitations under the License.
The Other Jimmy 36:96847d42f010 15
The Other Jimmy 36:96847d42f010 16 from os.path import join, exists, realpath, relpath, basename, isfile, splitext
The Other Jimmy 36:96847d42f010 17 from os import makedirs, listdir
The Other Jimmy 36:96847d42f010 18 import json
The Other Jimmy 36:96847d42f010 19
The Other Jimmy 36:96847d42f010 20 from tools.export.makefile import Makefile, GccArm, Armc5, IAR
The Other Jimmy 36:96847d42f010 21
The Other Jimmy 36:96847d42f010 22 class VSCode(Makefile):
The Other Jimmy 36:96847d42f010 23 """Generic VSCode project. Intended to be subclassed by classes that
The Other Jimmy 36:96847d42f010 24 specify a type of Makefile.
The Other Jimmy 36:96847d42f010 25 """
The Other Jimmy 36:96847d42f010 26 def generate(self):
The Other Jimmy 36:96847d42f010 27 """Generate Makefile and VSCode launch and task files
The Other Jimmy 36:96847d42f010 28 """
The Other Jimmy 36:96847d42f010 29 super(VSCode, self).generate()
The Other Jimmy 36:96847d42f010 30 ctx = {
The Other Jimmy 36:96847d42f010 31 'name': self.project_name,
The Other Jimmy 36:96847d42f010 32 'elf_location': join('BUILD', self.project_name)+'.elf',
The Other Jimmy 36:96847d42f010 33 'c_symbols': self.toolchain.get_symbols(),
The Other Jimmy 36:96847d42f010 34 'asm_symbols': self.toolchain.get_symbols(True),
The Other Jimmy 36:96847d42f010 35 'target': self.target,
The Other Jimmy 36:96847d42f010 36 'include_paths': self.resources.inc_dirs,
The Other Jimmy 36:96847d42f010 37 'load_exe': str(self.LOAD_EXE).lower()
The Other Jimmy 36:96847d42f010 38 }
The Other Jimmy 36:96847d42f010 39
The Other Jimmy 36:96847d42f010 40 if not exists(join(self.export_dir, '.vscode')):
The Other Jimmy 36:96847d42f010 41 makedirs(join(self.export_dir, '.vscode'))
The Other Jimmy 36:96847d42f010 42
The Other Jimmy 36:96847d42f010 43 self.gen_file('vscode/tasks.tmpl', ctx,
The Other Jimmy 36:96847d42f010 44 join('.vscode', 'tasks.json'))
The Other Jimmy 36:96847d42f010 45 self.gen_file('vscode/launch.tmpl', ctx,
The Other Jimmy 36:96847d42f010 46 join('.vscode', 'launch.json'))
The Other Jimmy 36:96847d42f010 47 self.gen_file('vscode/settings.tmpl', ctx,
The Other Jimmy 36:96847d42f010 48 join('.vscode', 'settings.json'))
The Other Jimmy 36:96847d42f010 49
The Other Jimmy 36:96847d42f010 50 # So.... I want all .h and .hpp files in self.resources.inc_dirs
The Other Jimmy 36:96847d42f010 51 all_directories = []
The Other Jimmy 36:96847d42f010 52
The Other Jimmy 36:96847d42f010 53 for directory in self.resources.inc_dirs:
The Other Jimmy 36:96847d42f010 54 if not directory:
The Other Jimmy 36:96847d42f010 55 continue
The Other Jimmy 36:96847d42f010 56
The Other Jimmy 36:96847d42f010 57 if directory == ".":
The Other Jimmy 36:96847d42f010 58 all_directories.append("${workspaceRoot}/*")
The Other Jimmy 36:96847d42f010 59 else:
The Other Jimmy 36:96847d42f010 60 all_directories.append(directory.replace("./", "${workspaceRoot}/") + "/*")
The Other Jimmy 36:96847d42f010 61
The Other Jimmy 36:96847d42f010 62 cpp_props = {
The Other Jimmy 36:96847d42f010 63 "configurations": [
The Other Jimmy 36:96847d42f010 64 {
The Other Jimmy 36:96847d42f010 65 "name": "Windows",
The Other Jimmy 36:96847d42f010 66 "includePath": [x.replace("/", "\\") for x in all_directories]
The Other Jimmy 36:96847d42f010 67 },
The Other Jimmy 36:96847d42f010 68 {
The Other Jimmy 36:96847d42f010 69 "name": "Mac",
The Other Jimmy 36:96847d42f010 70 "includePath": all_directories
The Other Jimmy 36:96847d42f010 71 },
The Other Jimmy 36:96847d42f010 72 {
The Other Jimmy 36:96847d42f010 73 "name": "Linux",
The Other Jimmy 36:96847d42f010 74 "includePath": all_directories
The Other Jimmy 36:96847d42f010 75 }
The Other Jimmy 36:96847d42f010 76 ]
The Other Jimmy 36:96847d42f010 77 }
The Other Jimmy 36:96847d42f010 78
The Other Jimmy 36:96847d42f010 79 with open(join(self.export_dir, '.vscode', 'c_cpp_properties.json'), 'w') as outfile:
The Other Jimmy 36:96847d42f010 80 json.dump(cpp_props, outfile, indent=4, separators=(',', ': '))
The Other Jimmy 36:96847d42f010 81
The Other Jimmy 36:96847d42f010 82
The Other Jimmy 36:96847d42f010 83 class VSCodeGcc(VSCode, GccArm):
The Other Jimmy 36:96847d42f010 84 LOAD_EXE = True
The Other Jimmy 36:96847d42f010 85 NAME = "VSCode-GCC-ARM"
The Other Jimmy 36:96847d42f010 86
The Other Jimmy 36:96847d42f010 87 class VSCodeArmc5(VSCode, Armc5):
The Other Jimmy 36:96847d42f010 88 LOAD_EXE = True
The Other Jimmy 36:96847d42f010 89 NAME = "VSCode-Armc5"
The Other Jimmy 36:96847d42f010 90
The Other Jimmy 36:96847d42f010 91 class VSCodeIAR(VSCode, IAR):
The Other Jimmy 36:96847d42f010 92 LOAD_EXE = True
The Other Jimmy 36:96847d42f010 93 NAME = "VSCode-IAR"
The Other Jimmy 36:96847d42f010 94
The Other Jimmy 36:96847d42f010 95