takashi kadono
/
Nucleo_446
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/tools/resources/ignore.py@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | # mbed SDK |
kadonotakashi | 0:8fdf9a60065b | 2 | # Copyright (c) 2011-2013 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 3 | # |
kadonotakashi | 0:8fdf9a60065b | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 5 | # you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 6 | # You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 7 | # |
kadonotakashi | 0:8fdf9a60065b | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 9 | # |
kadonotakashi | 0:8fdf9a60065b | 10 | # Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 13 | # See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 14 | # limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 15 | |
kadonotakashi | 0:8fdf9a60065b | 16 | import fnmatch |
kadonotakashi | 0:8fdf9a60065b | 17 | import re |
kadonotakashi | 0:8fdf9a60065b | 18 | from os.path import normcase, join |
kadonotakashi | 0:8fdf9a60065b | 19 | |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | IGNORE_FILENAME = ".mbedignore" |
kadonotakashi | 0:8fdf9a60065b | 22 | |
kadonotakashi | 0:8fdf9a60065b | 23 | |
kadonotakashi | 0:8fdf9a60065b | 24 | class MbedIgnoreSet(object): |
kadonotakashi | 0:8fdf9a60065b | 25 | """ |
kadonotakashi | 0:8fdf9a60065b | 26 | # The mbedignore rules as an object |
kadonotakashi | 0:8fdf9a60065b | 27 | |
kadonotakashi | 0:8fdf9a60065b | 28 | A project in Mbed OS contains metadata files that exclude files from a build. |
kadonotakashi | 0:8fdf9a60065b | 29 | These rules are stored as `fnmatch` patterns in text in a files named `.mbedignore`. |
kadonotakashi | 0:8fdf9a60065b | 30 | """ |
kadonotakashi | 0:8fdf9a60065b | 31 | |
kadonotakashi | 0:8fdf9a60065b | 32 | def __init__(self): |
kadonotakashi | 0:8fdf9a60065b | 33 | self._ignore_patterns = [] |
kadonotakashi | 0:8fdf9a60065b | 34 | self._ignore_regex = re.compile("$^") |
kadonotakashi | 0:8fdf9a60065b | 35 | |
kadonotakashi | 0:8fdf9a60065b | 36 | def is_ignored(self, file_path): |
kadonotakashi | 0:8fdf9a60065b | 37 | """Check if file path is ignored by any .mbedignore thus far""" |
kadonotakashi | 0:8fdf9a60065b | 38 | return self._ignore_regex.match(normcase(file_path)) |
kadonotakashi | 0:8fdf9a60065b | 39 | |
kadonotakashi | 0:8fdf9a60065b | 40 | def add_ignore_patterns(self, in_name, patterns): |
kadonotakashi | 0:8fdf9a60065b | 41 | """Ignore all files and directories matching the paterns in |
kadonotakashi | 0:8fdf9a60065b | 42 | directories named by in_name. |
kadonotakashi | 0:8fdf9a60065b | 43 | |
kadonotakashi | 0:8fdf9a60065b | 44 | Positional arguments: |
kadonotakashi | 0:8fdf9a60065b | 45 | in_name - the filename prefix that this ignore will apply to |
kadonotakashi | 0:8fdf9a60065b | 46 | patterns - the list of patterns we will ignore in the future |
kadonotakashi | 0:8fdf9a60065b | 47 | """ |
kadonotakashi | 0:8fdf9a60065b | 48 | if in_name == ".": |
kadonotakashi | 0:8fdf9a60065b | 49 | self._ignore_patterns.extend(normcase(p) for p in patterns) |
kadonotakashi | 0:8fdf9a60065b | 50 | else: |
kadonotakashi | 0:8fdf9a60065b | 51 | self._ignore_patterns.extend( |
kadonotakashi | 0:8fdf9a60065b | 52 | normcase(join(in_name, pat)) for pat in patterns) |
kadonotakashi | 0:8fdf9a60065b | 53 | if self._ignore_patterns: |
kadonotakashi | 0:8fdf9a60065b | 54 | self._ignore_regex = re.compile("|".join( |
kadonotakashi | 0:8fdf9a60065b | 55 | fnmatch.translate(p) for p in self._ignore_patterns)) |
kadonotakashi | 0:8fdf9a60065b | 56 | |
kadonotakashi | 0:8fdf9a60065b | 57 | def add_mbedignore(self, in_name, filepath): |
kadonotakashi | 0:8fdf9a60065b | 58 | """Add a series of patterns to the ignored paths |
kadonotakashi | 0:8fdf9a60065b | 59 | |
kadonotakashi | 0:8fdf9a60065b | 60 | Positional arguments: |
kadonotakashi | 0:8fdf9a60065b | 61 | in_name - the filename prefix that this ignore will apply to |
kadonotakashi | 0:8fdf9a60065b | 62 | patterns - the list of patterns we will ignore in the future |
kadonotakashi | 0:8fdf9a60065b | 63 | """ |
kadonotakashi | 0:8fdf9a60065b | 64 | with open (filepath) as f: |
kadonotakashi | 0:8fdf9a60065b | 65 | patterns = [l.strip() for l in f |
kadonotakashi | 0:8fdf9a60065b | 66 | if l.strip() != "" and not l.startswith("#")] |
kadonotakashi | 0:8fdf9a60065b | 67 | self.add_ignore_patterns(in_name, patterns) |
kadonotakashi | 0:8fdf9a60065b | 68 | |
kadonotakashi | 0:8fdf9a60065b | 69 |