-
Notifications
You must be signed in to change notification settings - Fork 1
fixed build system not returning docker command #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,17 +61,29 @@ def build(profile: str = typer.Option("release", "--profile", "-p", help="Specif | |||||||||||||||||||||||||||||||||
| if is_cmake: # Repo uses CMake, so execute CMake commands. | ||||||||||||||||||||||||||||||||||
| print("[#cccccc](ner build):[/#cccccc] [blue]CMake-based project detected.[/blue]") | ||||||||||||||||||||||||||||||||||
| if clean: | ||||||||||||||||||||||||||||||||||
| run_command_docker('cmake --build build --target clean ; find . -type d -name "build" -exec rm -rf {} +') | ||||||||||||||||||||||||||||||||||
| returncode = run_command_docker('cmake --build build --target clean ; find . -type d -name "build" -exec rm -rf {} +') | ||||||||||||||||||||||||||||||||||
| print("[#cccccc](ner build):[/#cccccc] [green]Ran build-cleaning command.[/green]") | ||||||||||||||||||||||||||||||||||
| if returncode != 0: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| run_command_docker(f"mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE={profile.capitalize()} -DCMAKE_TOOLCHAIN_FILE=cmake/gcc-arm-none-eabi.cmake .. && cmake --build .", stream_output=True) | ||||||||||||||||||||||||||||||||||
| run_command_docker('chmod 777 -R ./build/*') | ||||||||||||||||||||||||||||||||||
| returncode = run_command_docker(f"mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE={profile.capitalize()} -DCMAKE_TOOLCHAIN_FILE=cmake/gcc-arm-none-eabi.cmake .. && cmake --build .", stream_output=True) | ||||||||||||||||||||||||||||||||||
| if returncode != 0: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
| returncode = run_command_docker('chmod 777 -R ./build/*') | ||||||||||||||||||||||||||||||||||
| if returncode != 0: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+74
|
||||||||||||||||||||||||||||||||||
| else: # Repo uses Make, so execute Make commands. | ||||||||||||||||||||||||||||||||||
| print("[#cccccc](ner build):[/#cccccc] [blue]Makefile-based project detected.[/blue]") | ||||||||||||||||||||||||||||||||||
| if clean: | ||||||||||||||||||||||||||||||||||
| run_command_docker("make clean", stream_output=True) | ||||||||||||||||||||||||||||||||||
| returncode = run_command_docker("make clean", stream_output=True) | ||||||||||||||||||||||||||||||||||
| if returncode != 0: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| run_command_docker(f"make -j{os.cpu_count()}", stream_output=True) | ||||||||||||||||||||||||||||||||||
| returncode = run_command_docker(f"make -j{os.cpu_count()}", stream_output=True) | ||||||||||||||||||||||||||||||||||
| if returncode != 0: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if not clean and is_cmake: | ||||||||||||||||||||||||||||||||||
| fix_compile_commands() | ||||||||||||||||||||||||||||||||||
|
|
@@ -346,9 +358,9 @@ def usbip(connect: bool = typer.Option(False, "--connect", help="Connect to a US | |||||||||||||||||||||||||||||||||
| # Helper functions - not direct commands | ||||||||||||||||||||||||||||||||||
| # ============================================================================== | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def run_command(command, stream_output=False, exit_on_fail=False): | ||||||||||||||||||||||||||||||||||
| """Run a shell command. Optionally stream the output in real-time.""" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def run_command(command, stream_output=False, exit_on_fail=False) -> int: | ||||||||||||||||||||||||||||||||||
| # print("guess who isn't fucked rn") # REMOVEME | ||||||||||||||||||||||||||||||||||
| """Run a shell command. Optionally stream the output in real-time. Returns the returncode of the command called""" | ||||||||||||||||||||||||||||||||||
| if stream_output: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| process = subprocess.Popen(command, text=True) | ||||||||||||||||||||||||||||||||||
|
|
@@ -358,17 +370,24 @@ def run_command(command, stream_output=False, exit_on_fail=False): | |||||||||||||||||||||||||||||||||
| print(f"Error: Command exited with code {returncode}", file=sys.stderr) | ||||||||||||||||||||||||||||||||||
| if exit_on_fail: | ||||||||||||||||||||||||||||||||||
| sys.exit(returncode) | ||||||||||||||||||||||||||||||||||
| # return returncode | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| return returncode | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| result = subprocess.run(command, check=True, capture_output=True, text=True) | ||||||||||||||||||||||||||||||||||
| if result.stdout and result.stdout.strip(): # Only print if stdout is not empty or just whitespace | ||||||||||||||||||||||||||||||||||
| print(result.stdout) | ||||||||||||||||||||||||||||||||||
| return 0 # Code should be zero if it reaches this point | ||||||||||||||||||||||||||||||||||
|
Comment on lines
378
to
+383
|
||||||||||||||||||||||||||||||||||
| else: | |
| try: | |
| result = subprocess.run(command, check=True, capture_output=True, text=True) | |
| if result.stdout and result.stdout.strip(): # Only print if stdout is not empty or just whitespace | |
| print(result.stdout) | |
| return 0 # Code should be zero if it reaches this point | |
| # Successful execution with zero exit status | |
| return 0 | |
| else: | |
| try: | |
| result = subprocess.run(command, check=True, capture_output=True, text=True) | |
| if result.stdout and result.stdout.strip(): # Only print if stdout is not empty or just whitespace | |
| print(result.stdout) | |
| # Command succeeded (check=True did not raise), so return success code | |
| return 0 # Code should be zero if it reaches this point |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description mentions ner test returning the Docker command exit code, but only build() checks and exits based on run_command_docker()’s return value. Since Typer/Click ignores a command function’s return value, test() will still exit 0 unless it explicitly raises typer.Exit(code=...) / sys.exit(...) on non-zero return codes. Update test() accordingly (including the --clean path if desired).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clean command uses
;betweencmake --build ... cleanandfind ... rm -rf .... When run viash -c, the overall return code will be from the last command (find), which can mask a failingcmakeclean and defeat the goal of propagating build errors. Use&&(or otherwise preserve the first command’s exit code) so failures reliably propagate.