Skip to content

Commit

Permalink
rework args
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadh committed Apr 8, 2021
1 parent 12e3411 commit e75ff84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 46 deletions.
63 changes: 18 additions & 45 deletions apps/microtvm/reference-vm/base-box-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ def test_command(args):


def release_command(args):
vm_name = f"tlcpack/microtvm-{args.platform}"
if args.platform == "zephyr":
vm_name = f"{vm_name}-{args.zephyr_version}"
vm_name = f"tlcpack/microtvm-{args.platform}-{args.platform_version}"

if not args.skip_creating_release_version:
subprocess.check_call(
Expand Down Expand Up @@ -396,30 +394,11 @@ def release_command(args):
)


ALL_COMMANDS = {
"build": build_command,
"test": test_command,
"release": release_command,
}


def parse_args():
parser = argparse.ArgumentParser(
description="Automates building, testing, and releasing a base box"
)
subparsers = parser.add_subparsers(dest='commands',
help="Action or actions (comma-separated) to perform."
)
parser_build = subparsers.add_parser('build', help='Build a base box.')
parser_test = subparsers.add_parser('test', help='Test a base box before release.')
parser_release = subparsers.add_parser('release', help='Release base box to cloud.')

# parser.add_argument(
# "command",
# default=",".join(ALL_COMMANDS),
# choices=ALL_COMMANDS,
# help="Action or actions (comma-separated) to perform.",
# )
subparsers = parser.add_subparsers(help="Action to perform.")
parser.add_argument(
"platform",
help="Name of the platform VM to act on. Must be a sub-directory of this directory.",
Expand All @@ -428,16 +407,21 @@ def parse_args():
"--provider",
choices=ALL_PROVIDERS,
action="append",
default=[],
# required=True,
default=list(ALL_PROVIDERS),
help="Name of the provider or providers to act on; if not specified, act on all.",
)

parser_build = subparsers.add_parser("build", help="Build a base box.")
parser_build.set_defaults(func=build_command)
parser_test = subparsers.add_parser("test", help="Test a base box before release.")
parser_test.set_defaults(func=test_command)
parser_release = subparsers.add_parser("release", help="Release base box to cloud.")
parser_release.set_defaults(func=release_command)

parser_build.add_argument(
"--debug-packer",
action="store_true",
help=(
"Run packer in debug mode, and write log to the base-box directory."
),
help=("Run packer in debug mode, and write log to the base-box directory."),
)
parser_test.add_argument(
"--skip-build",
Expand Down Expand Up @@ -472,32 +456,21 @@ def parse_args():
help="Skip creating the version and just upload for this provider.",
)
parser_release.add_argument(
"--zephyr-version",
"--platform-version",
required=True,
help="Zephyr RTOS version to release, in the form 'x.y'.",
help="Platform version to release, in the form 'x.y'.",
)

return parser.parse_args(["build", "test", "release"])
return parser.parse_args()


def main():
args = parse_args()
print(args)
# if os.path.sep in args.platform or not os.path.isdir(os.path.join(THIS_DIR, args.platform)):
# sys.exit(f"<platform> must be a sub-direcotry of {THIS_DIR}; got {args.platform}")

# if not args.provider:
# args.provider = list(ALL_PROVIDERS)

# todo = []
# for phase in args.command.split(","):
# if phase not in ALL_COMMANDS:
# sys.exit(f"unknown command: {phase}")

# todo.append(ALL_COMMANDS[phase])
if os.path.sep in args.platform or not os.path.isdir(os.path.join(THIS_DIR, args.platform)):
sys.exit(f"<platform> must be a sub-direcotry of {THIS_DIR}; got {args.platform}")

# for phase in todo:
# phase(args)
args.func(args)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion apps/microtvm/zephyr/demo_runtime/boards/qemu_riscv32.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y

# Default 512, for operations with large floating point data.
# Default is 512, raised here for operations with large floating point data.
CONFIG_MAIN_STACK_SIZE=2048

# For floating point operations. It has exception on floating point operations
Expand Down

0 comments on commit e75ff84

Please sign in to comment.