From fa24d616807691a732a9dfa3c8828f6f3e1f9f8f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 28 May 2017 00:30:23 +0300 Subject: [PATCH] Project generator for VSCode IDE // Issue #619 Resolve #960 --- docs | 2 +- platformio/__init__.py | 2 +- platformio/ide/tpls/vscode/.gitignore.tpl | 3 + .../vscode/.vscode/c_cpp_properties.json.tpl | 28 +++++ .../tpls/vscode/.vscode/extensions.json.tpl | 9 ++ .../ide/tpls/vscode/.vscode/launch.json.tpl | 15 +++ .../ide/tpls/vscode/.vscode/settings.json.tpl | 14 +++ .../ide/tpls/vscode/.vscode/tasks.json.tpl | 104 ++++++++++++++++++ platformio/maintenance.py | 2 + 9 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 platformio/ide/tpls/vscode/.gitignore.tpl create mode 100644 platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl create mode 100644 platformio/ide/tpls/vscode/.vscode/extensions.json.tpl create mode 100644 platformio/ide/tpls/vscode/.vscode/launch.json.tpl create mode 100644 platformio/ide/tpls/vscode/.vscode/settings.json.tpl create mode 100644 platformio/ide/tpls/vscode/.vscode/tasks.json.tpl diff --git a/docs b/docs index f49813d1..fb19765e 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f49813d1105cb4624bd6ab4c965346adb714ad5d +Subproject commit fb19765e60ff3cf29bfd6480d0b094c1ed4b448d diff --git a/platformio/__init__.py b/platformio/__init__.py index 190b6ec7..520efae3 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 4, "0b6") +VERSION = (3, 4, "0b7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/ide/tpls/vscode/.gitignore.tpl b/platformio/ide/tpls/vscode/.gitignore.tpl new file mode 100644 index 00000000..e22b3c16 --- /dev/null +++ b/platformio/ide/tpls/vscode/.gitignore.tpl @@ -0,0 +1,3 @@ +.pioenvs +.piolibdeps +.vscode/browse.vc.db* diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl new file mode 100644 index 00000000..2e7d9417 --- /dev/null +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -0,0 +1,28 @@ +{ + "configurations": [ + { + "includePath": [ +% for include in includes: + "{{include.replace('"', '\\"')}}", +% end + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "", + "path": [ +% for include in includes: + "{{include.replace('"', '\\"')}}", +% end + "" + ] + }, + "defines": [ +% for define in defines: + "{{!define.replace('"', '\\"')}}", +% end + "" + ] + } + ] +} \ No newline at end of file diff --git a/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl b/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl new file mode 100644 index 00000000..7315e95d --- /dev/null +++ b/platformio/ide/tpls/vscode/.vscode/extensions.json.tpl @@ -0,0 +1,9 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + "ms-vscode.cpptools", + "webfreak.debug" + ] +} \ No newline at end of file diff --git a/platformio/ide/tpls/vscode/.vscode/launch.json.tpl b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl new file mode 100644 index 00000000..a09b7dcd --- /dev/null +++ b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl @@ -0,0 +1,15 @@ +% from os.path import dirname, join +{ + "version": "0.2.0", + "configurations": [ + { + "type": "gdb", + "request": "launch", + "cwd": "${workspaceRoot}", + "name": "PlatformIO Debugger", + "target": "{{prog_path.replace('"', '\\"')}}", + "gdbpath": "{{join(dirname(platformio_path), "piodebuggdb").replace('"', '\\"')}}", + "autorun": [ "source .pioinit" ] + } + ] +} \ No newline at end of file diff --git a/platformio/ide/tpls/vscode/.vscode/settings.json.tpl b/platformio/ide/tpls/vscode/.vscode/settings.json.tpl new file mode 100644 index 00000000..8958d2e1 --- /dev/null +++ b/platformio/ide/tpls/vscode/.vscode/settings.json.tpl @@ -0,0 +1,14 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/.pioenvs": true, + "**/.piolibdeps": true, + ".vscode/BROWSE.VC.DB*": true + }, + "C_Cpp.intelliSenseEngine": "Default", + "C_Cpp.autocomplete": "Default" +} \ No newline at end of file diff --git a/platformio/ide/tpls/vscode/.vscode/tasks.json.tpl b/platformio/ide/tpls/vscode/.vscode/tasks.json.tpl new file mode 100644 index 00000000..87f7f656 --- /dev/null +++ b/platformio/ide/tpls/vscode/.vscode/tasks.json.tpl @@ -0,0 +1,104 @@ +{ + "version": "0.1.0", + "command": "{{platformio_path}}", + "isShellCommand": true, + "args": ["-c", "vscode"], + "showOutput": "always", + "echoCommand": false, + "suppressTaskName": true, + "tasks": [ + { + "taskName": "PlatformIO: Build", + "isBuildCommand": true, + "args": ["run"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "PlatformIO: Clean", + "args": ["run", "-t", "clean"] + }, + { + "taskName": "PlatformIO: Upload", + "args": ["run", "-t", "upload"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "PlatformIO: Upload using Programmer", + "args": ["run", "-t", "program"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "PlatformIO: Upload SPIFFS image", + "args": ["run", "-t", "uploadfs"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "PlatformIO: Test", + "args": ["test"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "PlatformIO: Update platforms and libraries", + "args": ["update"] + }, + { + "taskName": "PlatformIO: Upgrade PIO Core", + "args": ["upgrade"] + } + ] +} \ No newline at end of file diff --git a/platformio/maintenance.py b/platformio/maintenance.py index a5c9c853..183e3dd6 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -49,6 +49,8 @@ def on_platformio_start(ctx, force, caller): if not caller: if getenv("PLATFORMIO_CALLER"): caller = getenv("PLATFORMIO_CALLER") + elif getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): + caller = "vscode" elif util.is_container(): if getenv("C9_UID"): caller = "C9"