Skip to content

HybridCompile: Exit after Arduino project SCons run#498

Merged
Jason2866 merged 1 commit into
developfrom
try_exit
May 25, 2026
Merged

HybridCompile: Exit after Arduino project SCons run#498
Jason2866 merged 1 commit into
developfrom
try_exit

Conversation

@Jason2866
Copy link
Copy Markdown

@Jason2866 Jason2866 commented May 25, 2026

Description:

Related issue (if applicable): fixes #496

Checklist:

  • The pull request is done against the latest develop branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR, more changes are allowed when changing boards.json
  • I accept the CLA

@Jason2866
Copy link
Copy Markdown
Author

@coderabbitai analyze if this PR fixes #496

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Tip

For best results, initiate chat on the files or code changes.

@Jason2866: Yes, PR #498 directly and completely addresses issue #496. Here's the breakdown:


Issue #496 — Root Cause Recap

When custom_sdkconfig triggers the Arduino hybrid-compile flow, espidf.py spawns a child pio run subprocess that performs the full Arduino build. After the child returns, the outer SCons process was continuing into its own build pipeline — but the outer env is only partially configured (missing FLASH_EXTRA_IMAGES entries like boot_app0.bin and user CPPDEFINES from build_flags). This caused:

  1. Post-action scripts (e.g., reading BUILD_FLAGS) to crash when invoked a second time in the broken outer env.
  2. firmware.factory.bin to be silently overwritten with an incomplete version (no boot_app0.bin).
  3. Doubled build time due to the outer env re-linking and re-running esptool steps.

What PR #498 Changes

# Before
env.Execute(
    env.VerboseAction(...)
)

# After
child_rc = env.Execute(        # ← capture child exit code
    env.VerboseAction(...)
)
# Added after the optional component_manager.restore_pioarduino_build_py():
env.Exit(child_rc if child_rc else 0)

Analysis

Issue impact Fixed by PR #498? How
Post-action scripts crash in outer env ✅ Yes env.Exit() stops outer SCons before it re-runs post-actions
firmware.factory.bin corrupted (missing boot_app0.bin) ✅ Yes Outer SCons never reaches the esptool step
Doubled build time ✅ Yes Outer SCons exits immediately after child completes

Key design points:

  • env.Exit(child_rc if child_rc else 0) correctly propagates failure: if the child pio run fails (non-zero), the outer process also exits with that code, so build failures are not swallowed.
  • The exit is placed after component_manager.restore_pioarduino_build_py(), so the cleanup step still executes before the outer process stops.
  • The fix is scoped only to the hybrid-compile path — it does not affect normal (non-hybrid) builds.

The implementation is exactly what the issue author suggested ("After env.Execute(...), call env.Exit(0) or sys.exit(child_rc)"), and covers all reported failure modes. ✅

@pioarduino pioarduino deleted a comment from coderabbitai Bot May 25, 2026
@Jason2866 Jason2866 merged commit fac5352 into develop May 25, 2026
1 check passed
@Jason2866 Jason2866 deleted the try_exit branch May 25, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant