Skip to content

Commit 8d1d836

Browse files
authored
Merge pull request #2164 from SeppoTakalo/master
Document the .mbedignore file
2 parents edd539b + a68eadd commit 8d1d836

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/ignoring_files_from_build.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Ignoring files from mbed build
2+
3+
The `.mbedignore` file allows you to ignore files and directories from being processed by `mbed build` command.
4+
5+
## Usage
6+
You can place the `.mbedignore` file in any directory where `mbed build` command is going to search for source files.
7+
8+
The most convenient place is the root directory of the library or application. However, this is not a requirement.
9+
10+
Avoid defining rules that would cross the library boundaries as those would lead to side effects or build problems that are hard to find.
11+
12+
## Syntax
13+
14+
Each line in the `.mbedignore` file is a file pattern used for matching files. Each matched file or directory is ignored from build.
15+
16+
The following wildcards are accepted:
17+
18+
|Pattern | Meaning|
19+
|--------|--------|
20+
| `*` | Matches everything. |
21+
| `?` | Matches any single character. |
22+
| `[seq]` | Matches any character in seq. |
23+
| `[!seq]` | Matches any character not in seq. |
24+
25+
File is parsed with Python's [fnmatch](https://docs.python.org/2/library/fnmatch.html) functionality so the syntax follows basic shell patterns with the following exceptions:
26+
27+
1. Each line is internally prefixed with the path of the `.mbedignore` file.
28+
2. Line cannot start with `.` or `/` (because of rule 1)
29+
30+
Globbing functionality is not used, so you cannot recursively match specific file pattern. You need to define rule per directory in that case.
31+
32+
Relative paths can be used, so you can match files deeper in the build tree. However, avoid crossing library boundaries.
33+
34+
### Example
35+
A file located in `source/obsolete/.mbedignore` with following content:
36+
37+
```
38+
*.c
39+
*.h
40+
second_level/*.c
41+
```
42+
43+
After applying the rule 1, actual patterns used internally for matching the source files are:
44+
45+
```
46+
source/obsolete/*.c
47+
source/obsolete/*.h
48+
source/obsolete/second_level/*.c
49+
```

0 commit comments

Comments
 (0)