---
id: TASK-9
title: Rebuild before running simulation binary; add --norebuild
status: Done
assignee: []
created_date: '2026-02-04 09:46'
updated_date: '2026-02-04 10:39'
labels: []
dependencies: []
references:
  - bin/zync
  - lua/zync/api/commands/commands.lua
  - lua/zync/api/manager.lua
  - spec/api_spec/manager_spec.lua
  - README.md
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Adjust `zync run` so that when it executes the Zephyr simulator binary directly, it first performs a build unless the user opts out. Add a new `--norebuild/-n` flag on `zync run` to skip the pre-run rebuild. Preserve existing behavior when `zync run` falls back to `ninja run` (no extra build step or argument changes).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 All subtasks are completed.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
Subtasks:
- TASK-9.1 (owner @codex): implement pre-run rebuild and --norebuild for simulation binary runs.
- TASK-9.2: add tests for pre-run rebuild/--norebuild behavior.
- TASK-9.3: update docs for pre-run rebuild/--norebuild behavior.
Sequencing: implement behavior (9.1) -> tests (9.2) -> docs (9.3).
<!-- SECTION:PLAN:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Summary:
- Added `--norebuild/-n` to `zync run` and updated run flow to build before executing the simulator binary when present (unless opted out), while keeping the `ninja run` fallback behavior unchanged.
- Added coverage in `manager_spec` for pre-run rebuild, `--norebuild`, and fallback behavior.
- Documented the new `zync run` rebuild behavior and `--norebuild/-n` option in README.

Tests:
- `busted spec/api_spec/manager_spec.lua`
<!-- SECTION:FINAL_SUMMARY:END -->
