From df099e15c0cd18a08244965999720ff8c95b9fd9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 Jan 2016 02:15:43 +0200 Subject: [PATCH] Add generic targets for IDE // Resolve #427 --- HISTORY.rst | 5 +-- docs/ide/clion.rst | 11 ++++--- docs/ide/eclipse.rst | 12 +++++-- docs/ide/emacs.rst | 6 ++-- docs/ide/sublimetext.rst | 9 ++++++ examples/ide/clion/.idea/workspace.xml | 27 +++++++++++++--- examples/ide/clion/CMakeLists.txt | 26 ++++++++++++++-- examples/ide/eclipse/.cproject | 8 +++++ .../sublimetext/platformio.sublime-project | 31 +++++++++++++++++++ platformio/commands/update.py | 1 + .../ide/tpls/clion/.idea/workspace.xml.tpl | 27 +++++++++++++--- platformio/ide/tpls/clion/CMakeLists.txt.tpl | 18 +++++++++++ platformio/ide/tpls/eclipse/.cproject.tpl | 8 +++++ .../.settings/language.settings.xml.tpl | 4 +-- .../platformio.sublime-project.tpl | 31 ++++++++++++++++++- 15 files changed, 196 insertions(+), 28 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index afda1a3d..28a5e1e7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,8 +7,9 @@ PlatformIO 2.0 2.7.1 (2016-01-??) ~~~~~~~~~~~~~~~~~~ -* Added generic targets to Eclipse IDE: Build, Clean, Upload, Upload SPIFFS - image, Upload using Programmer +* Added generic targets for Eclipse IDE, Emacs, Sublime Text: Build, Clean, + Upload, Upload SPIFFS image, Upload using Programmer, Update installed + platforms and libraries (`issue #427 `_) * Updated Teensy Arduino Framework to 1.26 (`issue #434 `_) diff --git a/docs/ide/clion.rst b/docs/ide/clion.rst index cd697d6f..f96912db 100644 --- a/docs/ide/clion.rst +++ b/docs/ide/clion.rst @@ -50,12 +50,15 @@ Then: 2. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``) 3. Build project (*DO NOT RUN*): ``Menu: Run > Build``. -There are 3 predefined targets for building (*NOT FOR RUNNING*, see marks on +There are 6 predefined targets for building (*NOT FOR RUNNING*, see marks on the screenshot below): -* ``PLATFORMIO_BUILD`` - build project without auto-uploading -* ``PLATFORMIO_UPLOAD`` - build and upload (if no errors) -* ``PLATFORMIO_CLEAN`` - clean compiled objects and etc. +* ``PLATFORMIO_BUILD`` - Build project without auto-uploading +* ``PLATFORMIO_UPLOAD`` - Build and upload (if no errors). +* ``PLATFORMIO_CLEAN`` - Clean compiled objects. +* ``PLATFORMIO_PROGRAM`` - Build and upload using external programmer (if no errors), see :ref:`atmelavr_upload_via_programmer`. +* ``PLATFORMIO_UPLOADFS`` - Upload files to file system SPIFFS, see :ref:`platform_espressif_uploadfs`. +* ``PLATFORMIO_UPDATE`` - Update installed platforms and libraries. .. warning:: The libraries which are added, installed or used in the project diff --git a/docs/ide/eclipse.rst b/docs/ide/eclipse.rst index 30093541..d8eba1b2 100644 --- a/docs/ide/eclipse.rst +++ b/docs/ide/eclipse.rst @@ -56,11 +56,17 @@ Then: 3. Build project using ``Menu: Project > Build Project`` or preconfigured Make Targets (see screenshot below): - + ``PlatformIO: Build`` - + ``PlatformIO: Clean`` - + ``PlatformIO: Upload`` + + ``PlatformIO: Build`` - Build project without auto-uploading + + ``PlatformIO: Clean`` - Clean compiled objects. + + ``PlatformIO: Upload`` - Build and upload (if no errors) + ``PlatformIO: Upload using Programmer`` see :ref:`atmelavr_upload_via_programmer` + ``PlatformIO: Upload SPIFFS image`` see :ref:`platform_espressif_uploadfs` + + ``PlatformIO: Update platforms and libraries`` - Update installed platforms and libraries + +If you have some problems with unresolved includes, defines, etc., then + +* Restart Eclipse IDE +* Rebuild index using ``Menu: Project > C/C++ Index > Rebuild``. .. warning:: The libraries which are added, installed or used in the project diff --git a/docs/ide/emacs.rst b/docs/ide/emacs.rst index db530846..1afe40f1 100644 --- a/docs/ide/emacs.rst +++ b/docs/ide/emacs.rst @@ -60,10 +60,10 @@ command and generate project via :option:`platformio init --ide` command: There are 6 predefined targets for building. * ``platformio_build`` - Build project without auto-uploading. (``C-c i b``) -* ``platformio_upload`` - Build and upload (if no errors). (``C-c i u``) -* ``platformio_programmer_upload`` - Build and upload using external programmer (if no errors). (``C-c i p``) -* ``platformio_spiffs_upload`` - Upload files to file system SPIFFS). (``C-c i s``) * ``platformio_clean`` - Clean compiled objects. (``C-c i c``) +* ``platformio_upload`` - Build and upload (if no errors). (``C-c i u``) +* ``platformio_programmer_upload`` - Build and upload using external programmer (if no errors, see :ref:`atmelavr_upload_via_programmer`). (``C-c i p``) +* ``platformio_spiffs_upload`` - Upload files to file system SPIFFS (see :ref:`platform_espressif_uploadfs`). (``C-c i s``) * ``platformio_update`` - Update installed platforms and libraries. (``C-c i d``) .. warning:: diff --git a/docs/ide/sublimetext.rst b/docs/ide/sublimetext.rst index 66957c99..535185b6 100644 --- a/docs/ide/sublimetext.rst +++ b/docs/ide/sublimetext.rst @@ -50,6 +50,15 @@ Then: 3. Open source file from ``src`` directory (``*.c, *.cpp, *.ino, etc.``) 4. Build project: ``Menu: Tools > Build``. +Also, you can access to all pre-configured targets via +``Menu: Tools > Builds With...`` (ST3) + ++ ``PlatformIO - Build`` - Build project without auto-uploading ++ ``PlatformIO - Clean`` - Clean compiled objects. ++ ``PlatformIO - Upload`` - Build and upload (if no errors) ++ ``PlatformIO - Upload using Programmer`` see :ref:`atmelavr_upload_via_programmer` ++ ``PlatformIO - Upload SPIFFS image`` see :ref:`platform_espressif_uploadfs` ++ ``PlatformIO - Update platforms and libraries`` - Update installed platforms and libraries Manual Integration ^^^^^^^^^^^^^^^^^^ diff --git a/examples/ide/clion/.idea/workspace.xml b/examples/ide/clion/.idea/workspace.xml index 95694b4f..a4c03d98 100644 --- a/examples/ide/clion/.idea/workspace.xml +++ b/examples/ide/clion/.idea/workspace.xml @@ -2,13 +2,15 @@ - - - + + + + + @@ -185,11 +187,26 @@ - + + + + + + + + + + + + + - + + + + diff --git a/examples/ide/clion/CMakeLists.txt b/examples/ide/clion/CMakeLists.txt index c6cfed5a..3c67b267 100644 --- a/examples/ide/clion/CMakeLists.txt +++ b/examples/ide/clion/CMakeLists.txt @@ -13,8 +13,8 @@ include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/ add_definitions(-DF_CPU=16000000L) add_definitions(-DARDUINO_ARCH_AVR) add_definitions(-DARDUINO_AVR_UNO) -add_definitions(-DARDUINO=10605) -add_definitions(-DPLATFORMIO=020304) +add_definitions(-DARDUINO=10607) +add_definitions(-DPLATFORMIO=020701) add_definitions(-D__AVR_ATmega328P__) add_custom_target( @@ -35,4 +35,24 @@ add_custom_target( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -add_executable(clion src/blink.cpp) +add_custom_target( + PLATFORMIO_PROGRAM ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target program + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + PLATFORMIO_UPLOADFS ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target uploadfs + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + PLATFORMIO_UPDATE_ALL ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion update + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(clion + src/blink.cpp +) diff --git a/examples/ide/eclipse/.cproject b/examples/ide/eclipse/.cproject index bf040f4c..496ac80b 100644 --- a/examples/ide/eclipse/.cproject +++ b/examples/ide/eclipse/.cproject @@ -131,6 +131,14 @@ true false + + platformio + -f -c eclipse + update + true + true + false + diff --git a/examples/ide/sublimetext/platformio.sublime-project b/examples/ide/sublimetext/platformio.sublime-project index 88a0f925..d6dca18f 100644 --- a/examples/ide/sublimetext/platformio.sublime-project +++ b/examples/ide/sublimetext/platformio.sublime-project @@ -32,6 +32,37 @@ "upload" ], "name": "Upload" + }, + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "run", + "--target", + "program" + ], + "name": "Upload using Programmer" + }, + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "run", + "--target", + "uploadfs" + ], + "name": "Upload SPIFFS image" + }, + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "update" + ], + "name": "Update platforms and libraries" } ], "working_dir": "${project_path:${folder}}", diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 49032927..52627a7a 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -24,4 +24,5 @@ from platformio.commands.platforms import \ @click.pass_context def cli(ctx): ctx.invoke(cmd_platforms_update) + click.echo() ctx.invoke(cmd_lib_update) diff --git a/platformio/ide/tpls/clion/.idea/workspace.xml.tpl b/platformio/ide/tpls/clion/.idea/workspace.xml.tpl index d76300c8..582177fb 100644 --- a/platformio/ide/tpls/clion/.idea/workspace.xml.tpl +++ b/platformio/ide/tpls/clion/.idea/workspace.xml.tpl @@ -2,13 +2,15 @@ - - - + + + + + @@ -187,11 +189,26 @@ - + + + + + + + + + + + + + - + + + + diff --git a/platformio/ide/tpls/clion/CMakeLists.txt.tpl b/platformio/ide/tpls/clion/CMakeLists.txt.tpl index 8704357a..4ad26cb6 100644 --- a/platformio/ide/tpls/clion/CMakeLists.txt.tpl +++ b/platformio/ide/tpls/clion/CMakeLists.txt.tpl @@ -38,6 +38,24 @@ add_custom_target( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_custom_target( + PLATFORMIO_PROGRAM ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target program + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + PLATFORMIO_UPLOADFS ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion run --target uploadfs + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + PLATFORMIO_UPDATE_ALL ALL + COMMAND ${PLATFORMIO_CMD} -f -c clion update + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + % if src_files and any([f.endswith((".c", ".cpp")) for f in src_files]): add_executable({{project_name}} % for f in src_files: diff --git a/platformio/ide/tpls/eclipse/.cproject.tpl b/platformio/ide/tpls/eclipse/.cproject.tpl index cf2fc211..b21e2aa5 100644 --- a/platformio/ide/tpls/eclipse/.cproject.tpl +++ b/platformio/ide/tpls/eclipse/.cproject.tpl @@ -158,6 +158,14 @@ true false + + platformio + -f -c eclipse + update + true + true + false + diff --git a/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl b/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl index 3da3c37d..53c9c72f 100644 --- a/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl +++ b/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl @@ -6,9 +6,9 @@ % if "windows" in systype: - + % else: - + % end diff --git a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl index 2e9dd213..5db5397f 100644 --- a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl +++ b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl @@ -11,6 +11,15 @@ "name": "PlatformIO", "variants": [ + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "run" + ], + "name": "Build" + }, { "cmd": [ @@ -33,6 +42,17 @@ ], "name": "Upload" }, + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "run", + "--target", + "program" + ], + "name": "Upload using Programmer" + }, { "cmd": [ @@ -42,7 +62,16 @@ "--target", "uploadfs" ], - "name": "Upload SPIFFS" + "name": "Upload SPIFFS image" + }, + { + "cmd": + [ + "platformio", + "-f", "-c", "sublimetext", + "update" + ], + "name": "Update platforms and libraries" } ], "working_dir": "${project_path:${folder}}",