# Build System

**Purpose**: Core build tools for compiling Rust components and bundling Nushell libraries.

## Tools

### Compilation

- **`compile-platform.nu`** - Compile Rust orchestrator, control-center, and MCP server
  - Multi-platform cross-compilation
  - Release/debug build modes
  - Feature flag management
  - Output to `dist/platform/`

### Bundling

- **`bundle-core.nu`** - Bundle Nushell core libraries and CLI
  - Package provisioning CLI wrapper
  - Core library bundling (lib_provisioning)
  - Configuration system packaging
  - Validation and syntax checking
  - Optional compression (gzip)
  - Output to `dist/core/`

### Validation

- **`check-system.nu`** - Validate build environment
  - Check required tools (Rust, Nushell, Nickel)
  - Verify dependencies
  - Validate configuration

## Build Process

Complete build pipeline:

```bash
just build-all                  # Platform + core
just build-platform             # Rust binaries only
just build-core                 # Nushell libraries only
```

Build with validation:

```bash
just build-core --validate      # Validate Nushell syntax
```

Debug build:

```bash
just build-debug                # Build with debug symbols
```

## Output

Build outputs go to `dist/`:

- `dist/platform/` - Compiled Rust binaries
- `dist/core/` - Nushell libraries and CLI
- `dist/config/` - Configuration files
- `dist/core/bundle-metadata.json` - Build metadata

## Architecture

Each build tool follows Nushell 0.109+ standards:

- Immutable variable patterns
- Explicit external command prefixes (`^`)
- Error handling via `do { } | complete` pattern
- Comprehensive logging

## Related Files

- `provisioning/justfiles/build.just` - Build recipe definitions
- `provisioning/tools/distribution/` - Distribution generation using build outputs
- `provisioning/tools/package/` - Packaging compiled binaries
