Skip to content

Commit 8fd5e20

Browse files
authored
Merge pull request #789 from theotherjimmy/merge-build-profiles
Merge build profile documents and link to them
2 parents 60edae0 + c567c97 commit 8fd5e20

File tree

12 files changed

+86
-108
lines changed

12 files changed

+86
-108
lines changed

docs.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,6 @@
861861
{
862862
"type": "markdown",
863863
"url": "https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/CLI/debug_builds_cli.md"
864-
},
865-
{
866-
"type": "markdown",
867-
"url": "https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/CLI/toolchain_profiles.md"
868864
}
869865
]
870866
}

docs/reference/configuration/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The Arm Mbed OS configuration system gathers and interprets the configuration de
1313

1414
<span class="notes">**Note:** In prior releases, the configuration system provided a method for adding custom targets. The Mbed OS tools now look for custom targets in a file named `custom_targets.json` in the root of an application and treat custom targets the same as [Mbed targets](/docs/development/tools/adding-and-configuring-targets.html).</span>
1515

16+
<span class="notes">**Note:** This document only deals with passing macros to part of the toolchain suite. For documentation about how to control other flags to the compiler see the [build profiles documentation](/docs/latest/tools/CLI/build_profiles.html).</span>
17+
1618
### Examining available configuration parameters
1719

1820
Mbed CLI includes a command for listing and explaining the compile time configuration, `mbed compile --config`. This command prints a summary of configuration parameters, such as:

docs/tools/CLI/build_profiles.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,74 @@ Arm Mbed OS 5 supports three primary build profiles: *develop*, *debug* and *rel
2525
- Chip goes to sleep when going idle:
2626
- Debugger is likely to drop connection.
2727
- Breaks the local file system on the [Mbed interface](/docs/development/introduction/index.html) on some boards.
28+
29+
### User defined profiles
30+
31+
A toolchain or build system profile is a set of flags that is guaranteed to be passed to the underlying compiler suite.
32+
33+
These flags are stored in a JSON file that may be merged with other JSON files of the same structure.
34+
35+
#### JSON toolchain profile format
36+
37+
The JSON object that represents a toolchain profile is a dictionary mapping from toolchains, such as `GCC_ARM`, to their flags, such as `-O3`.
38+
39+
The structure is as follows: each toolchain supported by a toolchain profile has a dictionary in the root dictionary. This dictionary contains a mapping from a flag type to a list of flags that should be passed to the corresponding part of the compiler suite.
40+
41+
The required flag types are:
42+
43+
| Key | Description |
44+
|:---------|:--------------------------------------|
45+
| `asm` | Flags for the Assembler |
46+
| `c` | Flags for the C Compiler |
47+
| `common` | Flags for both the C and C++ Compilers|
48+
| `cxx` | Flags for the C++ Compiler |
49+
| `ld` | Flags for the Linker |
50+
51+
#### Example
52+
53+
An example of a toolchain profile:
54+
55+
```json
56+
{
57+
"GCC_ARM": {
58+
"common": ["-c", "-Wall", "-Wextra",
59+
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
60+
"-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
61+
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
62+
"-MMD", "-fno-delete-null-pointer-checks",
63+
"-fomit-frame-pointer", "-Os"],
64+
"asm": ["-x", "assembler-with-cpp"],
65+
"c": ["-std=gnu99"],
66+
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
67+
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
68+
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r",
69+
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit"]
70+
},
71+
"ARM": {
72+
"common": ["-c", "--gnu", "-Otime", "--split_sections",
73+
"--apcs=interwork", "--brief_diagnostics", "--restrict",
74+
"--multibyte_chars", "-O3"],
75+
"asm": [],
76+
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
77+
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
78+
"ld": []
79+
},
80+
"IAR": {
81+
"common": [
82+
"--no_wrap_diagnostics", "non-native end of line sequence", "-e",
83+
"--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-Oh"],
84+
"asm": [],
85+
"c": ["--vla"],
86+
"cxx": ["--guard_calls", "--no_static_destruction"],
87+
"ld": ["--skip_dynamic_initialization", "--threaded_lib"]
88+
}
89+
}
90+
```
91+
92+
From this toolchain profile, we can tell that:
93+
94+
- `GCC_ARM`, `ARM` and `IAR` compiler suites are supported.
95+
- The `ARM` C and C++ compilers will be using optimization level `-O3`.
96+
- The `IAR` linker will skip dynamic initialization.
97+
98+
And so on.

docs/tools/CLI/cli-compile.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The arguments for *compile* are:
4242
- `--source <SOURCE>` selects the source directory. The default is `.` (the current directory). You can specify multiple source locations, even outside the program tree. Find more details about the `--source` switch in the [build rules documentation](/docs/development/tools/build_rules.html).
4343
- `--build <BUILD>` selects the build directory. Default: `BUILD/` inside your program root.
4444
<span class="notes">**Note**: `mbed compile` ignores the current build directory; creating multiple build directories leads to errors.</span>
45-
- `--profile <PATH_TO_BUILD_PROFILE>` selects a path to a build profile configuration file. Example: `mbed-os/tools/profiles/debug.json`.
45+
- `--profile <PATH_TO_BUILD_PROFILE>` selects a path to a build profile configuration file. Example: `debug`. See the dedicated [build profile documentation](/docs/tools/CLI/build_profiles.html) for more detail.
4646
- `--library` compiles the code as a [static `.a/.ar` library](#compiling-static-libraries).
4747
- `--no-archive` suppresses the creation of `.a/.ar` files created by `--library`, producing many `.o` files instead.
4848
<span class="notes">**Note**: This option does nothing without `--library`.</span>
@@ -128,14 +128,12 @@ $ mbed compile -t GCC_ARM -m K64F -c -DUVISOR_PRESENT
128128

129129
##### Compile in debug mode
130130

131-
To compile in debug mode (as opposed to the default *develop* mode), use `--profile mbed-os/tools/profiles/debug.json` in the compile command-line:
131+
To compile in debug mode (as opposed to the default *develop* mode), use `--profile debug` in the compile command-line:
132132

133133
```
134-
$ mbed compile -t GCC_ARM -m K64F --profile mbed-os/tools/profiles/debug.json
134+
$ mbed compile -t GCC_ARM -m K64F --profile debug
135135
```
136136

137-
<span class="tips">**Tip:** If you have files that you want to compile only in debug mode, put them in a directory called `TARGET_DEBUG` at any level of your tree (then use `--profile` as explained above).
138-
</span>
139137

140138
#### Automate toolchain and target selection
141139

docs/tools/CLI/cli-test-debug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The arguments to `test` are:
1717
- `-n <TESTS_BY_NAME>`: to limit the tests built or run to a comma separated list, for example, `test1, test2, test3`.
1818
- `--source <SOURCE>`: to select the source directory. The default is `.` for the the current directory. You can specify multiple source locations, even outside the program tree. Find more details about the `--source` switch in the [build rules documentation](/docs/development/tools/build_rules.html).
1919
- `--build <BUILD>`: to select the build directory. The default is `BUILD/` inside your program.
20-
- `--profile <PATH_TO_BUILD_PROFILE>`: to select a path to a build profile configuration file, for example, `mbed-os/tools/profiles/debug.json`.
20+
- `--profile <PATH_TO_BUILD_PROFILE>`: to select a path to a build profile configuration file, for example, `mbed-os/tools/profiles/debug.json`. See the dedicated [build profile documentation](/docs/tools/CLI/build_profiles.html) for more detail.
2121
- `-c or --clean`: to clean the build directory before compiling.
2222
- `--test-spec <TEST_SPEC>`: to set the path for the test specification file used when building and running tests. The default path is the build directory.
2323
- `--build-data <BUILD_DATA>`: dumps build_data to this file.

docs/tools/CLI/debug_builds_cli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ $ mbed compile -o debug-info
2121
**Arm Mbed 2.0**
2222

2323
```
24-
$ mbed compile --profile .temp/tools/profiles/debug.json
24+
$ mbed compile --profile debug
2525
```
2626

2727
### Exporting with debug symbols
2828

2929
You can also enable debug symbols when [exporting your project](exporting.html) by using:
3030

3131
```
32-
$ mbed export -i uvision -m K64F --profile mbed-os/tools/profiles/debug.json
32+
$ mbed export -i uvision -m K64F --profile debug
3333
```
3434

3535
Make release builds by using:
3636

3737
```
38-
$ mbed export -i uvision -m K64F --profile mbed-os/tools/profiles/default.json
38+
$ mbed export -i uvision -m K64F --profile release
3939
```

docs/tools/CLI/toolchain_profiles.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

docs/tools/build_rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Mbed OS build rules
22

3-
The Mbed OS build tools scan your project for source files every time you compile. This document describes the rules that the build tools use to decide which source files to include in each build. The Mbed OS build tools use the [target configuration](adding-and-configuring-targets.html) found in `targets.json`, `mbed_app.json` and `mbed_lib.json` as input to these rules.
3+
The Mbed OS build tools scan your project for source files every time you compile. This document describes the rules that the build tools use to decide which source files to include in each build. The Mbed OS build tools use the [target configuration](adding-and-configuring-targets.html) found in `targets.json`, `mbed_app.json` and `mbed_lib.json` as input to these rules. If you are looking for how to pass options to the compilers, please see the [build profiles documentation](http://os.mbed.com/docs/latest/tools/CLI/build_profiles.html).
44

55
The build tools include every source file found in the project unless it is in a label directory, it is in a test directory or it matches a pattern in an `.mbedignore file`.
66

docs/tools/debug/debug_intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ In your project folder, run:
2424
# alternatively, use -i make_armc5 for ARMCC, or -i make_iar for IAR
2525
# replace K64F with your target board
2626
27-
$ mbed export -i make_gcc_arm -m K64F --profile mbed-os/tools/profiles/debug.json
27+
$ mbed export -i make_gcc_arm -m K64F
2828
```
2929

3030
##### Serial terminal

docs/tutorials/debug/eclipse_pyocd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ In your project folder, run:
4343
# Replace K64F with your target board
4444
# If you're not using GCC ARM, use -i eclipse_armc5 for ARMCC, or -i eclipse_iar for IAR
4545
46-
$ mbed export -i eclipse_gcc_arm -m K64F --profile mbed-os/tools/profiles/debug.json
46+
$ mbed export -i eclipse_gcc_arm -m K64F --profile debug
4747
```
4848

4949
### Importing the project in Eclipse
@@ -121,5 +121,5 @@ We build using Make, but you can also use Mbed CLI for building from Eclipse:
121121
1. Go to *Project > Properties > C/C++ Build*.
122122
1. Remove the check *Use default build command*.
123123
1. Set *Build command* to `mbed`.
124-
1. Under *Behavior* > *Build (Incremental build)*, select your Mbed CLI build options. For example: `compile -m K64F -t GCC_ARM --profile ${CWD}mbed-os/tools/profiles/debug.json`.
124+
1. Under *Behavior* > *Build (Incremental build)*, select your Mbed CLI build options. For example: `compile -m K64F -t GCC_ARM --profile debug`.
125125
1. Make sure to update the paths to the `.elf` file in your debug configuration.

docs/tutorials/debug/keil_uvision.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To export your project to uVision, you can use either the Online Compiler or Mbe
2323

2424
```
2525
# replace K64F with your target board
26-
$ mbed export -i uvision5 -m K64F --profile mbed-os/tools/profiles/debug.json
26+
$ mbed export -i uvision5 -m K64F
2727
```
2828
2929
### Starting a debug session

docs/tutorials/debug/vs_code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ In your project folder, run:
4040
# alternatively, use -i vscode_armc5 for ARMCC, or -i vscode_iar for IAR
4141
# replace K64F with your target board
4242
43-
$ mbed export -i vscode_gcc_arm -m K64F --profile mbed-os/tools/profiles/debug.json
43+
$ mbed export -i vscode_gcc_arm -m K64F --profile debug
4444
```
4545

4646
### Configuring the debugger

0 commit comments

Comments
 (0)