Skip to content

Commit 3022759

Browse files
author
Irit Arkin
committed
Cleaning up headers a bit
1 parent be3302d commit 3022759

File tree

3 files changed

+47
-45
lines changed

3 files changed

+47
-45
lines changed

docs/creating_apps/adding_exporters.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Adding exporters
1+
## Adding exporters
22

33
This is a guide for adding exporters to the mbed OS tools. First, this document describes what an exporter is and what rules it follows. Then, it covers the structure of the export subsystem and the individual exporter. Finally, this document gives some implementation suggestions.
44

55
<span class="notes">**Note:** All paths are relative to [https://github.com/ARMmbed/mbed-os/](https://github.com/ARMmbed/mbed-os/).</span>
66

7-
## What an exporter is
7+
### What an exporter is
88

99
An exporter is a Python plugin to the mbed OS tools that converts a project using mbed CLI into one specialized for a particular IDE. For the best user experience, an exporter:
1010

@@ -13,7 +13,7 @@ An exporter is a Python plugin to the mbed OS tools that converts a project usin
1313
- Has a single template file for each file type they produce. For example, an eclipse CDT project would have one template for `.project` files and one for `.cproject` files.
1414
- Does not call mbed CLI. It is possible to export from the website, which will not include mbed CLI in the resulting zip.
1515

16-
## Export subsystem structure
16+
### Export subsystem structure
1717

1818
The export subsystem is organized as a group of common code and a group of IDE or toolchain specific plugins.
1919

@@ -25,11 +25,11 @@ The **common code** is contained in three files:
2525

2626
An **IDE or toolchain specific plugin** is a Python class that inherits from the `Exporter` class and is listed in the `tools/export/__init__.py` exporter map.
2727

28-
### Common code
28+
#### Common code
2929

3030
The common code does two things: setting things up for the plugins, and providing a library of useful tools for plugins to use.
3131

32-
#### Setup
32+
##### Setup
3333

3434
The setup code scans for the resources used in the export process and collects the configuration required to build the project at hand.
3535

@@ -41,15 +41,15 @@ These steps construct an object of one of the exporter plugin classes listed in
4141
* `flags` the flags that the mbedToolchain instance will use to compile the `c/cpp/asm` files if invoked.
4242
* `resources` a `Resources` object that contains many lists of files that an exporter will find useful, such as C and Cpp sources and header search paths. The plugin should use only the attributes of the Resources object because the methods are only used during setup time. You can view all available Resources class attributes in `tools/toolchains/__init__.py`.
4343

44-
#### Plugin tools
44+
##### Plugin tools
4545

4646
The other half of the common code is a library for use by a plugin. This API includes:
4747

4848
* `gen_file` use Jinja2 to generate a file from a template.
4949
* `get_source_paths` returns a list of directories that contain assembly, C, C++ files and so on.
50-
* `group_project_files` group all files passed in by their containing directory. The groups are suitable for an IDE.
50+
* `group_project_files` group all files passed in by their containing directory. The groups are suitable for an IDE.
5151

52-
### Plugin code
52+
#### Plugin code
5353

5454
Plugin code is contained within a subdirectory of the `tools/export` directory named after the IDE or toolchain that the plugin is exporting for.
5555
For example, the uVision exporter's templates and Python code is contained within the directory `tools/export/uvision` and the Makefile exporter's code and templates within `tools/export/makefile`.
@@ -60,39 +60,39 @@ The Python code for the plugin should be:
6060
1. Imported into `tools/export/__init__.py`.
6161
1. Added to the exporter map.
6262

63-
#### The `generate` method
63+
##### The `generate` method
6464

65-
Each exporter is expected to implement one method, `generate`, which is responsible for creating all of the required project files for the IDE or toolchain that the plugin targets.
65+
Each exporter is expected to implement one method, `generate`, which is responsible for creating all of the required project files for the IDE or toolchain that the plugin targets.
6666

6767
This method may use any of the attributes and APIs included by the common code.
6868

69-
#### The `TARGETS` class variable
69+
##### The `TARGETS` class variable
7070

7171
Each exporter reports its specific target support through a class varibale, `TARGETS`. This class variable is simply a list of targets to which you can export. Requesting an export to a target that's not on the list will generate an error.
7272

73-
#### The `TOOLCHAIN` class variable
73+
##### The `TOOLCHAIN` class variable
7474

7575
Each exporter reports its specific toolchain it will use to compile the source code through a class variable `TOOLCHAIN`.
7676

77-
#### The `NAME` class variable
77+
##### The `NAME` class variable
7878

7979
Each exporter reports the name of the exporter through the class variable `NAME`. This matches the key in the `tools/export/__init__.py` exporter map.
8080

81-
#### The `build` method
81+
##### The `build` method
8282

83-
A plugin that would like to be tested by CI may implement the `build` method.
83+
A plugin that would like to be tested by CI may implement the `build` method.
8484

8585
This method runs after `generate` on an object that inherits from `Exporter`. It is responsible for invoking the build tools that the IDE or toolchain needs when a user instructs it to compile. It must return `0` on success or `-1` on failure.
8686

87-
## Implementing an example plugin
87+
### Implementing an example plugin
8888

8989
In this section, we walk through implementing a simple exporter, `my_makefile`, which is a simplified Makefile using one template.
9090

9191
We will create two files and discuss their contents: `__init__.py` with the Python plugin code, and `Makefile.tmpl` with the template.
9292

9393
As this plugin is named `my_makefile`, all of the support code will be placed into `tools/export/my_makefile`.
9494

95-
### Python code for `__init__.py`
95+
#### Python code for `__init__.py`
9696

9797
First, we will make our class a subclass of Exporter:
9898
```python
@@ -126,7 +126,7 @@ TARGETS = [target for target, obj in TARGET_MAP.iteritems()
126126
if "GCC_ARM" in obj.supported_toolchains]
127127
```
128128

129-
#### Implementing the `generate` method
129+
##### Implementing the `generate` method
130130

131131
To generate our Makefile, we need a list of object files the executable will use. We can construct the list from the sources if we replace the extensions with `.o`.
132132

@@ -166,9 +166,9 @@ To render our template, we pass the template file name, the context and the dest
166166
self.gen_file('my_makefile/Makefile.tmpl', ctx, 'Makefile')
167167
```
168168

169-
### Template
169+
#### Template
170170

171-
Now that we have a context object, and we have passed off control to the Jinja2 template rendering engine, we can look at the template Makefile, `tools/export/my_makefile/Makefile.tmpl`.
171+
Now that we have a context object, and we have passed off control to the Jinja2 template rendering engine, we can look at the template Makefile, `tools/export/my_makefile/Makefile.tmpl`.
172172

173173
Find documentation on what is available within a Jinja2 template [here](http://jinja.pocoo.org/docs/dev/templates/).
174174

@@ -239,18 +239,18 @@ $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SCRIPT)
239239
@$(LD) -T $(filter %{{link_script_ext}}, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES)
240240
```
241241

242-
## Suggested implementation
242+
### Suggested implementation
243243

244244
There are several paths forward that can lead to an easily maintained exporter:
245245
- Specialize or alias the GNU ARM Eclipse exporter.
246246
- Specialize or alias the Eclipse + Make exporter.
247247
- Specialize the Make exporter.
248-
249-
### GNU ARM Eclipse
248+
249+
#### GNU ARM Eclipse
250250

251251
If your IDE uses Eclipse and uses the GNU ARM Eclipse plugin, then specialize or alias your exporter with the generic GNU ARM Eclipse.
252252

253-
#### Alias
253+
##### Alias
254254

255255
If you do not need any specialization of the export, then replace your exporters class in the `EXPORT_MAP` with the `GNUARMEclipse` class. For example, if KDS met all of these requirements, we could:
256256

@@ -265,13 +265,13 @@ EXPORTERS = {
265265
'sw4stm32' : sw4stm32.Sw4STM32,
266266
```
267267

268-
#### Specialization
268+
##### Specialization
269269

270270
If you need more specialization and are using an Eclipse based IDE and the GNU ARM Eclipse plugin, then your exporter class inherits from the `GNUARMEclipse` class. For example (with KDS again):
271271

272272
```python
273273
from tools.export.gnuarmeclipse import GNUARMEcilpse
274-
274+
275275
class KDS(GNUARMEcilpse):
276276
NAME = 'Kinetis Design Studio'
277277
TOOLCHAIN = 'GCC_ARM'
@@ -281,22 +281,22 @@ class KDS(GNUARMEcilpse):
281281
"""Generate eclipes project files, and some KDS specific files"""
282282
super(KDS, self).generate()
283283
...
284-
284+
285285
```
286286

287287
After inheriting from the `GNUARMEclipse` class, specialize the generate method
288288
in any way you need.
289289

290-
### Eclipse + Make
290+
#### Eclipse + Make
291291

292292
If your IDE uses Eclipse and does not use the GNU ARM Eclipse plugin, you
293-
can use the "Unmanaged makefile" Eclipse exporter classes, `EclipseGcc`,
294-
`EclipseArmc5` and `EclipseIar`. Much like the GNU ARM Eclipse section, you may
293+
can use the "Unmanaged makefile" Eclipse exporter classes, `EclipseGcc`,
294+
`EclipseArmc5` and `EclipseIar`. Much like the GNU ARM Eclipse section, you may
295295
decide to alias or specialize.
296296

297-
### Make
297+
#### Make
298298

299-
If your IDE is not Eclipse based but can still use a Makefile, then you can specialize the Makefile exporter. Specializing the Makefile is actually how ARM mbed implemented the Eclipse + Make exporter.
299+
If your IDE is not Eclipse based but can still use a Makefile, then you can specialize the Makefile exporter. Specializing the Makefile is actually how ARM mbed implemented the Eclipse + Make exporter.
300300

301301
Creating an exporter based on the Makefile exporter is a two step process: inherit from the appropriate Makefile class, and call its generate method. Taking Eclipse + Make using GCC_ARM as an example, your exporter will look like:
302302

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
2-
## Troubleshooting with mbed CLI
31

4-
### Unable to import Mercurial (mbed.org) programs or libraries.
5-
1. Check whether you have Mercurial installed in your system path by running `hg` in command prompt. If you're receiving "command not found" or a similar message, then you need to install Mercurial, and add it to your system path.
2+
### Troubleshooting with mbed CLI
63

7-
2. Try to clone a Mercurial repository directly. For example, `hg clone https://developer.mbed.org/teams/mbed/code/mbed_blinky/`. If you receive an error similar to `abort: error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.:590)`, then your system certificates are out of date. You need to update your system certificates and possibly add the host certificate fingerprint of `mbed.com` and `mbed.org`. Read more about Mercurial's certificate management [here](https://www.mercurial-scm.org/wiki/CACertificates).
4+
**Unable to import Mercurial (mbed.org) programs or libraries**
85

9-
### Various issues when running mbed CLI in Cygwin environment
10-
Currently mbed CLI is not compatible with Cygwin environment and cannot be executed inside it (https://github.com/ARMmbed/mbed-cli/issues/299).
6+
: 1. Check whether you have Mercurial installed in your system path by running `hg` in command prompt. If you're receiving "command not found" or a similar message, then you need to install Mercurial, and add it to your system path.
7+
8+
: 2. Try to clone a Mercurial repository directly. For example, `hg clone https://developer.mbed.org/teams/mbed/code/mbed_blinky/`. If you receive an error similar to `abort: error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.:590)`, then your system certificates are out of date. You need to update your system certificates and possibly add the host certificate fingerprint of `mbed.com` and `mbed.org`. Read more about Mercurial's certificate management [here](https://www.mercurial-scm.org/wiki/CACertificates).
9+
10+
**Various issues when running mbed CLI in Cygwin environment**
11+
12+
: Currently mbed CLI is not compatible with Cygwin environment and cannot be executed inside it (https://github.com/ARMmbed/mbed-cli/issues/299).

docs/getting_started/using_cli.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The directories of Git and Mercurial executables (`git` and `hg`) need to be in
2929
* Compilers: GCC ARM, ARM Compiler 5, IAR.
3030
* IDE: Keil uVision, DS-5, IAR Workbench.
3131

32-
#### Video tutorial for manual installation
32+
#### Video tutorial for manual installation
3333

3434
<span class="images">[![Video tutorial](http://img.youtube.com/vi/cM0dFoTuU14/0.jpg)](https://www.youtube.com/watch?v=cM0dFoTuU14)</span>
3535

@@ -73,7 +73,7 @@ To install mbed-cli bash tab completion navigate to the `tools/bash_completion`
7373

7474
[Full documentation here](tools/bash_completion/install.md)
7575

76-
## Quickstart video
76+
### Quickstart video
7777

7878
<span class="images">[![Video tutorial](http://img.youtube.com/vi/PI1Kq9RSN_Y/0.jpg)](https://www.youtube.com/watch?v=PI1Kq9RSN_Y)</span>
7979

@@ -97,7 +97,7 @@ mbed CLI can create and import programs based on both mbed OS 2 and mbed OS 5.
9797

9898
#### Creating a new program for mbed OS 5
9999

100-
When you create a new program, mbed CLI automatically imports the latest [mbed OS release](https://github.com/ARMmbed/mbed-os/). Each release includes all the components: code, build tools and IDE exporters.
100+
When you create a new program, mbed CLI automatically imports the latest [mbed OS release](https://github.com/ARMmbed/mbed-os/). Each release includes all the components: code, build tools and IDE exporters.
101101

102102
With this in mind, let's create a new program (we'll call it `mbed-os-program`):
103103

@@ -163,13 +163,13 @@ $ cd mbed-os-example-blinky
163163
```
164164

165165
You can use the "import" command without specifying a full URL; mbed CLI adds a prefix (https://github.com/ARMmbed) to the URL if one is not present. For example, this command:
166-
166+
167167
```
168168
$ mbed import mbed-os-example-blinky
169169
```
170170

171171
is equivalent to this command:
172-
172+
173173
```
174174
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky
175175
```
@@ -191,7 +191,7 @@ $ mbed new .
191191

192192
### Adding and removing libraries
193193

194-
While working on your code, you may need to add another library to your application or remove existing libraries.
194+
While working on your code, you may need to add another library to your application or remove existing libraries.
195195

196196
Adding a new library to your program is not the same as cloning the repository. Don't clone a library using `hg` or `git`; use `mbed add` to add the library. This ensures that all libraries and sublibraries are populated as well.
197197

0 commit comments

Comments
 (0)