Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
tools/mbedcli_tools/generate_mbedignore.py@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | # |
Pawel Zarembski |
0:01f31e923fe2 | 2 | # DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 3 | # Copyright (c) 2009-2018, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 4 | # SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 5 | # |
Pawel Zarembski |
0:01f31e923fe2 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 7 | # not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 8 | # You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 9 | # |
Pawel Zarembski |
0:01f31e923fe2 | 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 11 | # |
Pawel Zarembski |
0:01f31e923fe2 | 12 | # Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 15 | # See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 16 | # limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 17 | # |
Pawel Zarembski |
0:01f31e923fe2 | 18 | |
Pawel Zarembski |
0:01f31e923fe2 | 19 | import os |
Pawel Zarembski |
0:01f31e923fe2 | 20 | |
Pawel Zarembski |
0:01f31e923fe2 | 21 | def add_list_path(input_path_list, ouput_path_dict): |
Pawel Zarembski |
0:01f31e923fe2 | 22 | for path_list in input_path_list: |
Pawel Zarembski |
0:01f31e923fe2 | 23 | repath = os.path.normpath(path_list) |
Pawel Zarembski |
0:01f31e923fe2 | 24 | if os.path.isfile(repath): |
Pawel Zarembski |
0:01f31e923fe2 | 25 | dir_path = os.path.dirname(repath) |
Pawel Zarembski |
0:01f31e923fe2 | 26 | if dir_path in ouput_path_dict: |
Pawel Zarembski |
0:01f31e923fe2 | 27 | ouput_path_dict[dir_path].append(os.path.basename(repath)) |
Pawel Zarembski |
0:01f31e923fe2 | 28 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 29 | ouput_path_dict[dir_path]= [os.path.basename(repath)] |
Pawel Zarembski |
0:01f31e923fe2 | 30 | elif repath not in ouput_path_dict: #check if it's already in the folder filter list |
Pawel Zarembski |
0:01f31e923fe2 | 31 | ouput_path_dict[repath]=[] |
Pawel Zarembski |
0:01f31e923fe2 | 32 | |
Pawel Zarembski |
0:01f31e923fe2 | 33 | def generate_mbedignore(build_dicts, topsource = 'source', filename = '.mbedignore'): |
Pawel Zarembski |
0:01f31e923fe2 | 34 | sources_tag = ['sources', 'includes'] |
Pawel Zarembski |
0:01f31e923fe2 | 35 | sources_list = [] |
Pawel Zarembski |
0:01f31e923fe2 | 36 | src_folder_file_dict = {} |
Pawel Zarembski |
0:01f31e923fe2 | 37 | if 'common' in build_dicts: |
Pawel Zarembski |
0:01f31e923fe2 | 38 | #do sources first |
Pawel Zarembski |
0:01f31e923fe2 | 39 | for tag in sources_tag: |
Pawel Zarembski |
0:01f31e923fe2 | 40 | if tag in build_dicts['common']: |
Pawel Zarembski |
0:01f31e923fe2 | 41 | if type(build_dicts['common'][tag]) is dict: |
Pawel Zarembski |
0:01f31e923fe2 | 42 | for srd_dir in build_dicts['common'][tag]: |
Pawel Zarembski |
0:01f31e923fe2 | 43 | if type(build_dicts['common'][tag][srd_dir]) is list: |
Pawel Zarembski |
0:01f31e923fe2 | 44 | add_list_path(build_dicts['common'][tag][srd_dir], src_folder_file_dict) |
Pawel Zarembski |
0:01f31e923fe2 | 45 | elif type(build_dicts['common'][tag]) is list: |
Pawel Zarembski |
0:01f31e923fe2 | 46 | add_list_path(build_dicts['common'][tag], src_folder_file_dict) |
Pawel Zarembski |
0:01f31e923fe2 | 47 | ignore_list = [] |
Pawel Zarembski |
0:01f31e923fe2 | 48 | for file in os.listdir("./"): |
Pawel Zarembski |
0:01f31e923fe2 | 49 | if file != topsource: |
Pawel Zarembski |
0:01f31e923fe2 | 50 | ignore_list.append(file) |
Pawel Zarembski |
0:01f31e923fe2 | 51 | for root, dirs, files in os.walk(topsource): |
Pawel Zarembski |
0:01f31e923fe2 | 52 | if root in src_folder_file_dict: |
Pawel Zarembski |
0:01f31e923fe2 | 53 | if src_folder_file_dict[root] != []: |
Pawel Zarembski |
0:01f31e923fe2 | 54 | for filter_file in files: |
Pawel Zarembski |
0:01f31e923fe2 | 55 | if filter_file not in src_folder_file_dict[root] and not filter_file.endswith('.h'): |
Pawel Zarembski |
0:01f31e923fe2 | 56 | ignore_list.append(os.path.join(root, filter_file)) |
Pawel Zarembski |
0:01f31e923fe2 | 57 | continue |
Pawel Zarembski |
0:01f31e923fe2 | 58 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 59 | for src_folder in src_folder_file_dict: |
Pawel Zarembski |
0:01f31e923fe2 | 60 | if root in src_folder: |
Pawel Zarembski |
0:01f31e923fe2 | 61 | for filter_file in files: |
Pawel Zarembski |
0:01f31e923fe2 | 62 | ignore_list.append(os.path.join(root, filter_file)) |
Pawel Zarembski |
0:01f31e923fe2 | 63 | break |
Pawel Zarembski |
0:01f31e923fe2 | 64 | else: |
Pawel Zarembski |
0:01f31e923fe2 | 65 | ignore_list.append(root) |
Pawel Zarembski |
0:01f31e923fe2 | 66 | with open(filename, 'w') as ignore_file: |
Pawel Zarembski |
0:01f31e923fe2 | 67 | for ignore_path in ignore_list: |
Pawel Zarembski |
0:01f31e923fe2 | 68 | if os.path.isdir(ignore_path): |
Pawel Zarembski |
0:01f31e923fe2 | 69 | ignore_path = os.path.join(ignore_path, '*') |
Pawel Zarembski |
0:01f31e923fe2 | 70 | ignore_file.write(ignore_path+'\n') |