Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbedcli_run.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 os 00020 import shutil 00021 import subprocess 00022 from generate_mbedcli_files import generate_mbedcli_files 00023 00024 def call_and_copy_output(args): 00025 try: 00026 process = subprocess.Popen(args, stdout=None, stderr=subprocess.STDOUT) 00027 process.wait() 00028 if process.returncode != 0: 00029 print("Error - mbed compile!") 00030 exit(process.returncode) 00031 except (OSError, ValueError) as e: 00032 print("Error - Cannot do mbed compile") 00033 print(e.output) 00034 exit(1) 00035 00036 def mbedcli_run(daplink_dir, build_folder, project, toolchain, clean, verbosity): 00037 generate_mbedcli_files(os.path.join(daplink_dir, "projects.yaml"), project) 00038 project_dir=os.path.join(daplink_dir, build_folder, project.upper()) 00039 if clean is True and os.path.exists(project_dir): 00040 print("Deleting %s" % project_dir) 00041 shutil.rmtree(project_dir, ignore_errors=True) 00042 args = ["mbed", "compile", "-m", project, "-t", toolchain, "--profile", "custom_profile.json"] 00043 if verbosity is not None: 00044 args.append("-" + "v" * verbosity) 00045 call_and_copy_output(args) 00046 cli_name_out = os.path.basename(daplink_dir) 00047 build_dir = os.path.join(project_dir, toolchain+"-CUSTOM_PROFILE") 00048 for file in os.listdir(build_dir): 00049 if file.startswith(cli_name_out): 00050 rename_file = os.path.join(build_dir, file.replace(cli_name_out, project, 1)) 00051 if os.path.exists(rename_file): 00052 os.remove(rename_file) 00053 os.rename(os.path.join(build_dir, file), rename_file) 00054 cli_hex_output = os.path.join(build_dir, project + ".hex") 00055 crc_file_output = os.path.join(build_dir, project + "_crc") 00056 return (cli_hex_output,crc_file_output)
Generated on Tue Jul 12 2022 15:37:20 by
