Skip to content
Snippets Groups Projects
Commit 4903232c authored by Guillaume Endignoux's avatar Guillaume Endignoux
Browse files

Add a --verbose-build option to the deploy script.

parent b486ff44
No related branches found
No related tags found
No related merge requests found
...@@ -269,6 +269,19 @@ class OpenSKInstaller: ...@@ -269,6 +269,19 @@ class OpenSKInstaller:
port=None, port=None,
) )
def checked_command(self, cmd, env=None, cwd=None):
stdout = None if self.args.verbose_build else subprocess.DEVNULL
try:
subprocess.run(
cmd,
stdout=stdout,
timeout=None,
check=True,
env=env,
cwd=cwd)
except subprocess.CalledProcessError as e:
fatal("Failed to execute {}: {}".format(cmd[0], str(e)))
def checked_command_output(self, cmd, env=None, cwd=None): def checked_command_output(self, cmd, env=None, cwd=None):
cmd_output = "" cmd_output = ""
try: try:
...@@ -300,9 +313,9 @@ class OpenSKInstaller: ...@@ -300,9 +313,9 @@ class OpenSKInstaller:
target_toolchain[1] in current_version): target_toolchain[1] in current_version):
info("Updating rust toolchain to {}".format("-".join(target_toolchain))) info("Updating rust toolchain to {}".format("-".join(target_toolchain)))
# Need to update # Need to update
self.checked_command_output( self.checked_command(
["rustup", "install", target_toolchain_fullstring]) ["rustup", "install", target_toolchain_fullstring])
self.checked_command_output( self.checked_command(
["rustup", "target", "add", SUPPORTED_BOARDS[self.args.board].arch]) ["rustup", "target", "add", SUPPORTED_BOARDS[self.args.board].arch])
info("Rust toolchain up-to-date") info("Rust toolchain up-to-date")
...@@ -312,7 +325,11 @@ class OpenSKInstaller: ...@@ -312,7 +325,11 @@ class OpenSKInstaller:
out_directory = os.path.join("third_party", "tock", "target", props.arch, out_directory = os.path.join("third_party", "tock", "target", props.arch,
"release") "release")
os.makedirs(out_directory, exist_ok=True) os.makedirs(out_directory, exist_ok=True)
self.checked_command_output(["make"], cwd=props.path)
env = os.environ.copy()
if self.args.verbose_build:
env["V"] = "1"
self.checked_command(["make"], cwd=props.path, env=env)
def build_example(self): def build_example(self):
info("Building example {}".format(self.args.application)) info("Building example {}".format(self.args.application))
...@@ -347,7 +364,9 @@ class OpenSKInstaller: ...@@ -347,7 +364,9 @@ class OpenSKInstaller:
] ]
if is_example: if is_example:
command.extend(["--example", self.args.application]) command.extend(["--example", self.args.application])
self.checked_command_output(command, env=env) if self.args.verbose_build:
command.extend(["--verbose"])
self.checked_command(command, env=env)
app_path = os.path.join("target", props.arch, "release") app_path = os.path.join("target", props.arch, "release")
if is_example: if is_example:
app_path = os.path.join(app_path, "examples") app_path = os.path.join(app_path, "examples")
...@@ -383,6 +402,8 @@ class OpenSKInstaller: ...@@ -383,6 +402,8 @@ class OpenSKInstaller:
elf2tab_args = [ elf2tab_args = [
"elf2tab", package_parameter, self.args.application, "-o", tab_filename "elf2tab", package_parameter, self.args.application, "-o", tab_filename
] ]
if self.args.verbose_build:
elf2tab_args.extend(["--verbose"])
for arch, app_file in binaries.items(): for arch, app_file in binaries.items():
dest_file = os.path.join(self.tab_folder, "{}.elf".format(arch)) dest_file = os.path.join(self.tab_folder, "{}.elf".format(arch))
shutil.copyfile(app_file, dest_file) shutil.copyfile(app_file, dest_file)
...@@ -392,7 +413,7 @@ class OpenSKInstaller: ...@@ -392,7 +413,7 @@ class OpenSKInstaller:
"--stack={}".format(STACK_SIZE), "--app-heap={}".format(APP_HEAP_SIZE), "--stack={}".format(STACK_SIZE), "--app-heap={}".format(APP_HEAP_SIZE),
"--kernel-heap=1024", "--protected-region-size=64" "--kernel-heap=1024", "--protected-region-size=64"
]) ])
self.checked_command_output(elf2tab_args) self.checked_command(elf2tab_args)
def install_tab_file(self, tab_filename): def install_tab_file(self, tab_filename):
assert self.args.application assert self.args.application
...@@ -616,14 +637,14 @@ class OpenSKInstaller: ...@@ -616,14 +637,14 @@ class OpenSKInstaller:
if self.args.programmer == "pyocd": if self.args.programmer == "pyocd":
info("Flashing HEX file") info("Flashing HEX file")
self.checked_command_output([ self.checked_command([
"pyocd", "flash", "--target={}".format(board_props.pyocd_target), "pyocd", "flash", "--target={}".format(board_props.pyocd_target),
"--format=hex", "--erase=auto", dest_file "--format=hex", "--erase=auto", dest_file
]) ])
if self.args.programmer == "nordicdfu": if self.args.programmer == "nordicdfu":
info("Creating DFU package") info("Creating DFU package")
dfu_pkg_file = "target/{}_dfu.zip".format(self.args.board) dfu_pkg_file = "target/{}_dfu.zip".format(self.args.board)
self.checked_command_output([ self.checked_command([
"nrfutil", "pkg", "generate", "--hw-version=52", "--sd-req=0", "nrfutil", "pkg", "generate", "--hw-version=52", "--sd-req=0",
"--application-version=1", "--application={}".format(dest_file), "--application-version=1", "--application={}".format(dest_file),
dfu_pkg_file dfu_pkg_file
...@@ -711,6 +732,13 @@ if __name__ == "__main__": ...@@ -711,6 +732,13 @@ if __name__ == "__main__":
help=("Only compiles and flash the application/example. " help=("Only compiles and flash the application/example. "
"Otherwise TockOS will also be bundled and flashed."), "Otherwise TockOS will also be bundled and flashed."),
) )
main_parser.add_argument(
"--verbose-build",
action="store_true",
default=False,
dest="verbose_build",
help=("Build everything in verbose mode."),
)
main_parser.add_argument( main_parser.add_argument(
"--panic-console", "--panic-console",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment