Skip to content
Browse files

scripts: west sign: code style refactor

Let's leave self.args as the actual parsed argument namespace.
Pass the final computed build directory separately.

Signed-off-by: Marti Bolivar <>
  • Loading branch information...
mbolivar authored and nashif committed Jun 12, 2019
1 parent 3bd07a2 commit 06c9f8e9e61f671219b4dd6ed3194d73a73ba2e9
Showing with 12 additions and 12 deletions.
  1. +12 −12 scripts/west_commands/
@@ -127,23 +127,22 @@ def do_run(self, args, ignored):

# Provide the build directory if not given, and defer to the signer.
args.build_dir = find_build_dir(args.build_dir)
build_dir = find_build_dir(args.build_dir)

self.args = args # for check_force

'no such build directory {}'.format(args.build_dir))
'no such build directory {}'.format(build_dir))
"build directory {} doesn't look like a Zephyr build "

if args.tool == 'imgtool':
signer = ImgtoolSigner()
# (Add support for other signers here in elif blocks)
raise RuntimeError("can't happen")

signer.sign(self, build_dir)

class Signer(abc.ABC):
@@ -153,21 +152,22 @@ class Signer(abc.ABC):
it in the Sign.do_run() method.'''

def sign(self, command):
def sign(self, command, build_dir):
'''Abstract method to perform a signature; subclasses must implement.
:param command: the Sign instance
:param build_dir: the build directory

class ImgtoolSigner(Signer):

def sign(self, command):
def sign(self, command, build_dir):
args = command.args

cache = cmake.CMakeCache.from_build_dir(args.build_dir)
runner_config = cached_runner_config(args.build_dir, cache)
bcfg = BuildConfiguration(args.build_dir)
cache = cmake.CMakeCache.from_build_dir(build_dir)
runner_config = cached_runner_config(build_dir, cache)
bcfg = BuildConfiguration(build_dir)

# Build a signed .bin
if args.gen_bin and runner_config.bin_file:

0 comments on commit 06c9f8e

Please sign in to comment.
You can’t perform that action at this time.