|
| 1 | +#!/usr/bin/env python |
| 2 | +# File Output Tool for Apollo3 Arduino Core |
| 3 | +# Allows users to export compiled executables in a variety of formats |
| 4 | + |
| 5 | +# *********************************************************************************** |
| 6 | +# |
| 7 | +# Imports |
| 8 | +# |
| 9 | +# *********************************************************************************** |
| 10 | + |
| 11 | +import argparse |
| 12 | +import shutil |
| 13 | +import sys |
| 14 | +from sys import exit |
| 15 | + |
| 16 | +# *********************************************************************************** |
| 17 | +# |
| 18 | +# Main function |
| 19 | +# |
| 20 | +# *********************************************************************************** |
| 21 | +def main(args): |
| 22 | + print("\n\nApollo3 Arduino Executable Exporter") |
| 23 | + |
| 24 | + if args.format == "axf": |
| 25 | + sourcepath = args.axfpath |
| 26 | + elif args.format == "bin": |
| 27 | + sourcepath = args.binpath |
| 28 | + else: |
| 29 | + print('"' + str(args.format) + '" is not a valid format - exit') |
| 30 | + exit() |
| 31 | + |
| 32 | + shutil.copy2(sourcepath, args.sketchpath) |
| 33 | + print("exported " + str(args.axfpath) + " to " + str(args.sketchpath)) |
| 34 | + |
| 35 | + exit() |
| 36 | + |
| 37 | + |
| 38 | +# ****************************************************************************** |
| 39 | +# |
| 40 | +# Main program flow |
| 41 | +# |
| 42 | +# ****************************************************************************** |
| 43 | +if __name__ == "__main__": |
| 44 | + |
| 45 | + parser = argparse.ArgumentParser(description="Apollo3 Executable Exporter") |
| 46 | + |
| 47 | + parser.add_argument( |
| 48 | + "-s", |
| 49 | + "--sketchpath", |
| 50 | + dest="sketchpath", |
| 51 | + help="path to sketch folder (file will be saved there)", |
| 52 | + ) |
| 53 | + parser.add_argument("-b", "--binpath", dest="binpath", help="path to .bin file") |
| 54 | + parser.add_argument("-a", "--axfpath", dest="axfpath", help="path to .axf file") |
| 55 | + parser.add_argument( |
| 56 | + "-f", |
| 57 | + "--format", |
| 58 | + dest="format", |
| 59 | + default="axf", |
| 60 | + help="which format to export (axf, bin)", |
| 61 | + ) |
| 62 | + |
| 63 | + args = parser.parse_args() |
| 64 | + |
| 65 | + main(args) |
0 commit comments