---
id: TASK-1.3
title: Isolate build output per profile under project build directory
status: Done
assignee:
  - codex
created_date: '2026-01-29 15:38'
updated_date: '2026-01-29 17:12'
labels: []
dependencies: []
references:
  - lua/zync
  - spec
parent_task_id: TASK-1
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Update build directory resolution so each profile uses its own isolated subdirectory under the project's default build directory, preventing cross-profile build artifacts from colliding.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 When a profile is active, the build directory is namespaced under the project build directory (e.g., `<project>/build/<profile>/...`)
- [x] #2 Sysbuild/multi-image outputs are still organized correctly within the profile-specific build directory
- [x] #3 Existing behavior remains unchanged for projects without profiles
- [x] #4 Docs describe the profile-specific build directory layout
- [x] #5 Tests cover build dir resolution for profile and non-profile projects
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1) Locate build directory resolution in the manager/configurator code paths (where `build` is set/used) and identify how sysbuild output paths are derived.
2) Add profile-aware build dir resolution: when `config.profile` is set, use `<project>/build/<profile>` as the base build directory; otherwise keep current `<project>/build`.
3) Ensure sysbuild image selection and image list paths remain relative to the profile-specific build directory.
4) Update README to document the new build directory layout.
5) Add tests for build dir resolution with/without profiles (and sysbuild case if present).
6) Run `busted` and update task notes/acceptance criteria.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added profile-aware build dir support via `build_dir`/`project_dir` fields in config and manager (`lua/zync/api/configurator.lua`, `lua/zync/api/manager.lua`).

Manager now resolves build dir per profile and uses project root for CMake paths and cleaning logic; handles build/<profile> and build. Updated README build layout.

Updated tests/fixtures to cover build dir resolution and profile build dirs (`spec/api_spec/manager_spec.lua`, `spec/fixtures/manager_fix.lua`, `spec/fixtures/configurator_fix.lua`).

Ran `busted` (all 42 specs passing).
<!-- SECTION:NOTES:END -->
