Repository: google/OpenSK
File: deploy.py (Python)

Code before:
            metadata_address=0x5000,
            app_ldscript="nrf52840_layout_b.ld",
            app_address=0x80000,
        ),
    "nrf52840_dongle_opensk":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_dongle_opensk",),
    "nrf52840_dongle_dfu":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_dongle_dfu",
            kernel_address=0x1000,
            nordic_dfu=True,
        ),
    "nrf52840_mdk_dfu":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_mdk_dfu",
            kernel_address=0x1000,
            nordic_dfu=True,
        ),
}

# The following value must match the one used in the file
# `src/entry_point.rs`
APP_HEAP_SIZE = 90000

CARGO_TARGET_DIR = os.environ["CARGO_TARGET_DIR"] \
  if os.environ.get("CARGO_TARGET_DIR") else "target"


def get_supported_boards() -> Tuple[str]:
  """Returns a tuple all valid supported boards."""
  boards = []
  for name, props in SUPPORTED_BOARDS.items():
    if all((os.path.exists(os.path.join(props.path, "Cargo.toml")),
            (props.app_ldscript and os.path.exists(props.app_ldscript)))):
      boards.append(name)
  return tuple(set(boards))


def fatal(msg: str):
  print(f"{colorama.Fore.RED + colorama.Style.BRIGHT}fatal:"
        f"{colorama.Style.RESET_ALL} {msg}")
  sys.exit(1)


def error(msg: str):
  print(f"{colorama.Fore.RED}error:{colorama.Style.RESET_ALL} {msg}")


def info(msg: str):
  print(f"{colorama.Fore.GREEN + colorama.Style.BRIGHT}info:"

Review comment (suggestion):
`CARGO_TARGET_DIR = os.environ.get("CARGO_TARGET_DIR", "target")`

should also work? The second parameter is the default, if not present.

Code after:
            metadata_address=0x5000,
            app_ldscript="nrf52840_layout_b.ld",
            app_address=0x80000,
        ),
    "nrf52840_dongle_opensk":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_dongle_opensk",),
    "nrf52840_dongle_dfu":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_dongle_dfu",
            kernel_address=0x1000,
            nordic_dfu=True,
        ),
    "nrf52840_mdk_dfu":
        nrf52840dk_opensk_board._replace(
            path="third_party/tock/boards/nordic/nrf52840_mdk_dfu",
            kernel_address=0x1000,
            nordic_dfu=True,
        ),
}

# The following value must match the one used in the file
# `src/entry_point.rs`
APP_HEAP_SIZE = 90000

CARGO_TARGET_DIR = os.environ.get("CARGO_TARGET_DIR", "target")


def get_supported_boards() -> Tuple[str]:
  """Returns a tuple all valid supported boards."""
  boards = []
  for name, props in SUPPORTED_BOARDS.items():
    if all((os.path.exists(os.path.join(props.path, "Cargo.toml")),
            (props.app_ldscript and os.path.exists(props.app_ldscript)))):
      boards.append(name)
  return tuple(set(boards))


def fatal(msg: str):
  print(f"{colorama.Fore.RED + colorama.Style.BRIGHT}fatal:"
        f"{colorama.Style.RESET_ALL} {msg}")
  sys.exit(1)


def error(msg: str):
  print(f"{colorama.Fore.RED}error:{colorama.Style.RESET_ALL} {msg}")


def info(msg: str):
  print(f"{colorama.Fore.GREEN + colorama.Style.BRIGHT}info:"
        f"{colorama.Style.RESET_ALL} {msg}")