Clone of official tools

Revision:
43:2a7da56ebd24
Parent:
40:7d3fa6b99b2b
diff -r 2cf3f29fece1 -r 2a7da56ebd24 export/vscode/__init__.py
--- a/export/vscode/__init__.py	Mon Nov 06 13:17:14 2017 -0600
+++ b/export/vscode/__init__.py	Tue Sep 25 13:43:09 2018 -0500
@@ -12,9 +12,12 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+from __future__ import print_function, absolute_import
+from builtins import str
+
 
 from os.path import join, exists, realpath, relpath, basename, isfile, splitext
-from os import makedirs, listdir
+from os import makedirs, listdir, remove, rmdir
 import json
 
 from tools.export.makefile import Makefile, GccArm, Armc5, IAR
@@ -40,12 +43,13 @@
         if not exists(join(self.export_dir, '.vscode')):
             makedirs(join(self.export_dir, '.vscode'))
 
-        self.gen_file('vscode/tasks.tmpl', ctx,
-                      join('.vscode', 'tasks.json'))
-        self.gen_file('vscode/launch.tmpl', ctx,
-                      join('.vscode', 'launch.json'))
-        self.gen_file('vscode/settings.tmpl', ctx,
-                      join('.vscode', 'settings.json'))
+        config_files = ['launch', 'settings', 'tasks']
+        for file in config_files:
+            if not exists('.vscode/%s.json' % file):
+                self.gen_file('vscode/%s.tmpl' % file, ctx,
+                              '.vscode/%s.json' % file)
+            else:
+                print('Keeping existing %s.json' % file)
 
         # So.... I want all .h and .hpp files in self.resources.inc_dirs
         all_directories = []
@@ -82,6 +86,11 @@
         with open(join(self.export_dir, '.vscode', 'c_cpp_properties.json'), 'w') as outfile:
             json.dump(cpp_props, outfile, indent=4, separators=(',', ': '))
 
+    @staticmethod
+    def clean(_):
+        for f in ['launch', 'settings', 'tasts', 'c_cpp_properties']:
+            remove(".vscode/%s.json" % f)
+        rmdir(".vscode")
 
 class VSCodeGcc(VSCode, GccArm):
     LOAD_EXE = True