MCPcopy Create free account
hub / github.com/ARMmbed/DAPLink / main

Function main

tools/mbedcli_compile.py:42–125  ·  view source on GitHub ↗

python -u tools/mbedcli_compile.py kl26z_microbit_if kl26z_bl --clean

()

Source from the content-addressed store, hash-verified

40VERSION_YAML = "version.yaml"
41
42def main():
43 """python -u tools/mbedcli_compile.py kl26z_microbit_if kl26z_bl --clean"""
44 #parse project yaml file for project list
45 project_list = []
46 with open(PROJECTS_YAML, 'r') as top_yaml:
47 try:
48 topdict = yaml.load(top_yaml)
49 for dict_key in topdict:
50 if dict_key == 'projects':
51 for project in topdict[dict_key]:
52 project_list.append(project)
53 break
54 except yaml.YAMLError as ex:
55 print("Found yaml parse error", ex)
56 #parse the arguments
57 projects = "List of supported projects\n\n" + ", ".join(project_list) #
58 parser = argparse.ArgumentParser(description='mbedcli compile support for DAPLink', epilog=projects, formatter_class=argparse.RawDescriptionHelpFormatter)
59 parser.add_argument('projects', help='Selectively compile only the firmware specified otherwise all projects',
60 nargs='*', type=str, default=[])
61 parser.add_argument("--board-id", type=str, help="board id to for the target in hex")
62 parser.add_argument("--family-id", type=str, help="family id to for the target in hex")
63 parser.add_argument("--bin-offset", type=str, help="binary offset in hex")
64 parser.add_argument('--release', dest='release', action='store_true', help='Create a release with the yaml version file')
65 parser.add_argument('--build-folder', type=str, default='BUILD', help='Release directory to grab files from')
66 parser.add_argument('--release-folder', type=str, default='firmware', help='Directory to create and place files in')
67 parser.add_argument('--toolchain', type=str, default='ARM', help='Toolchain directory if present')
68 parser.add_argument('--clean', dest='clean', action='store_true', help='Rebuild or delete build folder before compile')
69 parser.add_argument('-v', dest='verbosity', action='count', help='Pass verbosity level to mbed compile -vv for more')
70 parser.set_defaults(clean=False)
71 parser.set_defaults(release=False)
72 args = parser.parse_args()
73 self_path = os.path.abspath(__file__)
74 tools_dir = os.path.dirname(self_path)
75 daplink_dir = os.path.dirname(tools_dir)
76 if os.path.basename(tools_dir) != "tools":
77 print("Error - this script must be run from the tools directory")
78 exit(-1)
79 version_git_dir = os.path.join(daplink_dir, "source", "daplink")
80 error = generate_version_file(version_git_dir)
81 if error:
82 exit(-1)
83 if not args.projects == []:
84 for project in args.projects:
85 print("Compiling %s" % project)
86 (cli_hex_output,crc_file_output) = mbedcli_tools.mbedcli_run(daplink_dir, args.build_folder, project, args.toolchain, args.clean, args.verbosity)
87 print("Creating crc padded binaries %s" % os.path.basename(cli_hex_output))
88 post_build_script(cli_hex_output, crc_file_output, args.board_id, args.family_id, args.bin_offset)
89 else:
90 print("compiling all firmware")
91 #generate a dictionary of board ID, and family ID
92 id_map = {}
93 for board_id, family_id, firmware, bootloader, target in info.SUPPORTED_CONFIGURATIONS:
94 if firmware in id_map:
95 id_map[firmware].append((hex(board_id), hex(family_id)))
96 else:
97 id_map[firmware] = [(hex(board_id), hex(family_id))]
98 for project in project_list:
99 print("Compiling %s" % project)

Callers 1

mbedcli_compile.pyFile · 0.70

Calls 3

generate_version_fileFunction · 0.90
post_build_scriptFunction · 0.90
package_release_filesFunction · 0.90

Tested by

no test coverage detected