Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers generate_custom_cli_files.py Source File

generate_custom_cli_files.py

00001 #
00002 # DAPLink Interface Firmware
00003 # Copyright (c) 2009-2018, ARM Limited, All Rights Reserved
00004 # SPDX-License-Identifier: Apache-2.0
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License"); you may
00007 # not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 # http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00014 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 #
00018 
00019 import json
00020 
00021 def generate_custom_profile(build_dicts, compiler='ARM', tool_search='make_armcc', filename = 'custom_profile.json'):
00022     profile_dict = {
00023         compiler: {
00024             "common": [],
00025             "asm": [], 
00026             "c": [], 
00027             "cxx": [], 
00028             "ld": []
00029         }
00030     }
00031     if 'tool_specific' in build_dicts:
00032         for entry in build_dicts['tool_specific']:
00033             if entry == tool_search:
00034                 if 'misc' in build_dicts['tool_specific'][entry]:
00035                     for flags in build_dicts['tool_specific'][entry]['misc']:
00036                         if flags.endswith('_flags'):
00037                             cli_entry = flags[:-len('_flags')]
00038                             if cli_entry in profile_dict[compiler]:
00039                                 profile_dict[compiler][cli_entry].extend(build_dicts['tool_specific'][entry]['misc'][flags])
00040                             else:
00041                                 profile_dict[compiler][cli_entry] = build_dicts['tool_specific'][entry]['misc'][flags]
00042 
00043     with open(filename, 'w') as custom_profile:
00044         json.dump(profile_dict, custom_profile, indent=4, separators=(',', ': '))
00045 
00046 def generate_custom_targets(target_name, build_dicts, out_ext='hex', filename = 'custom_targets.json'):
00047     target_dict = { 
00048         target_name : {
00049             "core": build_dicts['common']['core'][0],
00050             "supported_toolchains": ["ARM"],
00051             "inherits": ["Target"],
00052             "OUTPUT_EXT": out_ext,
00053             "macros" : []
00054         } 
00055     }
00056     if 'common' in build_dicts:
00057         for entry in build_dicts['common']:
00058             if entry == 'macros':
00059                 if entry in target_dict[target_name]:
00060                     target_dict[target_name][entry].extend(build_dicts['common'][entry])
00061                 else: 
00062                     target_dict[target_name][entry] = build_dicts['common'][entry]
00063 
00064     with open(filename, 'w') as custom_targets:
00065         json.dump(target_dict,custom_targets, indent=4, separators=(',', ': '))