Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from ZachMassia/develop
Emacs IDE integration support
- Loading branch information
Showing
5 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ IDE Integration | |
ide/atom | ||
ide/clion | ||
ide/eclipse | ||
ide/emacs | ||
ide/energia | ||
ide/qtcreator | ||
ide/sublimetext | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.. Copyright 2014-2015 Ivan Kravets <me@ikravets.com> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
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. | ||
.. _ide_emacs: | ||
|
||
Emacs | ||
===== | ||
|
||
GNU Emacs is an extensible, customizable text editor - and more. At its core is | ||
an interpreter for Emacs Lisp, a dialect of the | ||
`Lisp programming language <http://en.wikipedia.org/wiki/Lisp_programming_language>`_ | ||
with extensions to support text editing. | ||
|
||
|
||
This software can be used with: | ||
|
||
* all available :ref:`platforms` | ||
* all available :ref:`frameworks` | ||
|
||
Refer to the `Emacs Documentation <https://www.gnu.org/software/emacs/#Manuals>`_ | ||
page for more detailed information. | ||
|
||
.. contents:: | ||
|
||
Integration | ||
----------- | ||
|
||
PlatformIO-Mode | ||
^^^^^^^^^^^^^^^ | ||
|
||
An Emacs minor mode has been written to facilitate building and uploading from within Emacs. | ||
It can be installed from the MELPA repository using ``M-x package-install``. | ||
See the MELPA `Getting Started <https://melpa.org/#/getting-started>`_ page for more information. | ||
|
||
Setup instructions for the minor mode can be found at the `Github page <https://github.com/ZachMassia/platformio-mode>`_. | ||
|
||
Code completion can optionally be provided by installing `irony-mode <https://github.com/Sarcasm/irony-mode>`_ | ||
|
||
|
||
Project Generator | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
You can generate an Emacs compatible project using | ||
:option:`platformio init --ide` command. Please choose board type using | ||
:ref:`cmd_boards` command and run: | ||
|
||
.. code-block:: shell | ||
platformio init --ide emacs --board %TYPE% | ||
cmake . | ||
There are 4 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_clean`` - Clean compiled objects. (``C-c i c``) | ||
* ``platformio_update`` - Update installed platforms and libraries. (``C-C i d``) | ||
|
||
.. warning:: | ||
The libraries which are added, installed or used in the project | ||
after generating process wont be reflected in IDE. To fix it you | ||
need to reinitialize project using :ref:`cmd_init` (repeat it). | ||
|
||
|
||
Screenshot | ||
---------- | ||
|
||
.. image:: ../_static/ide-platformio-emacs.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
MakeFile | ||
cmake_install.cmake | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project({{project_name}}) | ||
|
||
set(ENV{PATH} "{{env_path}}") | ||
set(PLATFORMIO_CMD "{{platformio_path}}") | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
% for include in includes: | ||
% if include.startswith(user_home_dir): | ||
% if "windows" in systype: | ||
include_directories("$ENV{HOMEDRIVE}$ENV{HOMEPATH}{{include.replace(user_home_dir, '').replace("\\", "/")}}") | ||
% else: | ||
include_directories("$ENV{HOME}{{include.replace(user_home_dir, '').replace("\\", "/")}}") | ||
% end | ||
% else: | ||
include_directories("{{include.replace("\\", "/")}}") | ||
% end | ||
% end | ||
|
||
% for define in defines: | ||
add_definitions(-D{{!define}}) | ||
% end | ||
|
||
add_custom_target( | ||
platformio_build ALL | ||
COMMAND ${PLATFORMIO_CMD} -f -c emacs run | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_custom_target( | ||
platformio_upload ALL | ||
COMMAND ${PLATFORMIO_CMD} -f -c emacs run --target upload | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_custom_target( | ||
platformio_clean ALL | ||
COMMAND ${PLATFORMIO_CMD} -f -c emacs run --target clean | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_custom_target( | ||
platformio_update ALL | ||
COMMAND ${PLATFORMIO_CMD} -f -c emacs update | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
% if main_src_file: | ||
add_executable({{project_name}} {{main_src_file.replace("\\", "/")}}) | ||
% else: | ||
# | ||
# To enable code auto-completion, please specify path | ||
# to main source file (*.c, *.cpp) and uncomment line below | ||
# | ||
# add_executable({{project_name}} src/main_change_me.cpp) | ||
% end |