From 9f4dde4b5ea99ed25ec0dc530039bf84b800dd86 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 13 Dec 2018 17:24:08 +0200 Subject: [PATCH] Use full path to PlatformIO CLI when generate project for IDE --- platformio/ide/projectgenerator.py | 4 +- .../platformio.sublime-project.tpl | 66 +++++++++++-------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index efec49ad..8ec43aed 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -15,6 +15,7 @@ import json import os import re +import sys from os.path import abspath, basename, expanduser, isdir, isfile, join, relpath import bottle @@ -146,7 +147,8 @@ class ProjectGenerator(object): "project_libdeps_dir": util.get_projectlibdeps_dir(), "systype": util.get_systype(), "platformio_path": self._fix_os_path( - util.where_is_program("platformio")), + sys.argv[0] if isfile(sys.argv[0]) + else util.where_is_program("platformio")), "env_pathsep": os.pathsep, "env_path": self._fix_os_path(os.getenv("PATH")) }) # yapf: disable diff --git a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl index 6f24d6a1..160cd6ba 100644 --- a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl +++ b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl @@ -4,7 +4,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run" ], @@ -14,7 +14,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run" ], @@ -23,27 +23,7 @@ { "cmd": [ - "platformio", - "-f", "-c", "sublimetext", - "run", - "--target", - "clean" - ], - "name": "Clean" - }, - { - "cmd": - [ - "platformio", - "-f", "-c", "sublimetext", - "test" - ], - "name": "Test" - }, - { - "cmd": - [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -54,7 +34,27 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "run", + "--target", + "clean" + ], + "name": "Clean" + }, + { + "cmd": + [ + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "test" + ], + "name": "Test" + }, + { + "cmd": + [ + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -65,7 +65,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -76,16 +76,24 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "update" ], "name": "Update platforms and libraries" + }, + { + "cmd": + [ + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "upgrade" + ], + "name": "Upgrade PlatformIO Core" } ], "working_dir": "${project_path:${folder}}", - "selector": "source.c, source.c++", - "path": "{{env_path}}" + "selector": "source.c, source.c++" } ], "folders": @@ -98,7 +106,7 @@ { "sublimegdb_workingdir": "{{project_dir}}", "sublimegdb_exec_cmd": "", - "sublimegdb_commandline": "{{platformio_path}} -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit" + "sublimegdb_commandline": "{{ platformio_path }} -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit" } }