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

Code before:
      command.append("--verbose")
    self.checked_command(command, env=env)
    app_path = os.path.join("target", props.arch, "release")
    if is_example:
      app_path = os.path.join(app_path, "examples")
    app_path = os.path.join(app_path, self.args.application)
    # Create a TAB file
    self.create_tab_file({props.arch: app_path})

  def generate_crypto_materials(self, force_regenerate):
    has_error = subprocess.call([
        os.path.join("tools", "gen_key_materials.sh"),
        "Y" if force_regenerate else "N",
    ])
    if has_error:
      error(("Something went wrong while trying to generate ECC "
             "key and/or certificate for OpenSK"))

  def create_tab_file(self, binaries):
    assert binaries
    assert self.args.application
    info("Generating Tock TAB file for application/example {}".format(
        self.args.application))
    elf2tab_ver = self.checked_command_output(["elf2tab", "--version"]).split(
        "\n", maxsplit=1)[0]
    if elf2tab_ver != "elf2tab 0.5.0":
      fatal("Unsupported elf2tab version {!a}. Please use 0.5.0.".format(
          elf2tab_ver))
    os.makedirs(self.tab_folder, exist_ok=True)
    tab_filename = os.path.join(self.tab_folder,
                                "{}.tab".format(self.args.application))
    elf2tab_args = [
        "elf2tab", "--deterministic", "--package-name", self.args.application,
        "-o", tab_filename
    ]
    if self.args.verbose_build:
      elf2tab_args.append("--verbose")
    for arch, app_file in binaries.items():
      dest_file = os.path.join(self.tab_folder, "{}.elf".format(arch))
      shutil.copyfile(app_file, dest_file)
      elf2tab_args.append(dest_file)

    elf2tab_args.extend([
        "--stack={}".format(STACK_SIZE), "--app-heap={}".format(APP_HEAP_SIZE),
        "--kernel-heap=1024", "--protected-region-size=64"
    ])
    self.checked_command(elf2tab_args)

  def install_tab_file(self, tab_filename):
    assert self.args.application
    info("Installing Tock application {}".format(self.args.application))

Review comment (suggestion):
I would either:
* remove version check
* issue a fatal error if version is less than 0.5.0
* issue a warning if version is different/above 0.5.0

I don't see a reason to block people using 0.6.0-dev from Github.

Code after:
      command.append("--verbose")
    self.checked_command(command, env=env)
    app_path = os.path.join("target", props.arch, "release")
    if is_example:
      app_path = os.path.join(app_path, "examples")
    app_path = os.path.join(app_path, self.args.application)
    # Create a TAB file
    self.create_tab_file({props.arch: app_path})

  def generate_crypto_materials(self, force_regenerate):
    has_error = subprocess.call([
        os.path.join("tools", "gen_key_materials.sh"),
        "Y" if force_regenerate else "N",
    ])
    if has_error:
      error(("Something went wrong while trying to generate ECC "
             "key and/or certificate for OpenSK"))

  def create_tab_file(self, binaries):
    assert binaries
    assert self.args.application
    info("Generating Tock TAB file for application/example {}".format(
        self.args.application))
    elf2tab_ver = self.checked_command_output(["elf2tab", "--version"]).split(
        "\n", maxsplit=1)[0]
    if elf2tab_ver != "elf2tab 0.5.0":
      error(
          ("Detected unsupported elf2tab version {!a}. The following "
           "commands may fail. Please use 0.5.0 instead.").format(elf2tab_ver))
    os.makedirs(self.tab_folder, exist_ok=True)
    tab_filename = os.path.join(self.tab_folder,
                                "{}.tab".format(self.args.application))
    elf2tab_args = [
        "elf2tab", "--deterministic", "--package-name", self.args.application,
        "-o", tab_filename
    ]
    if self.args.verbose_build:
      elf2tab_args.append("--verbose")
    for arch, app_file in binaries.items():
      dest_file = os.path.join(self.tab_folder, "{}.elf".format(arch))
      shutil.copyfile(app_file, dest_file)
      elf2tab_args.append(dest_file)

    elf2tab_args.extend([
        "--stack={}".format(STACK_SIZE), "--app-heap={}".format(APP_HEAP_SIZE),
        "--kernel-heap=1024", "--protected-region-size=64"
    ])
    self.checked_command(elf2tab_args)

  def install_tab_file(self, tab_filename):
    assert self.args.application