# msger-native Builder

Unified build system for msger-native that uses JSON configuration to control which platforms to build.

## Usage

```bash
cd msger-native
npm run build
```

## Configuration

Edit `builder/build-config.json` to control which platforms are built:

```json
{
    "platforms": {
        "windows": true,    // Build Windows x64 binary
        "wsl": false,       // Build Linux x64 binary (via WSL)
        "pi": false,        // Build Raspberry Pi ARM64 binary (remote build on Pi)
        "arm64": false,     // Build Linux ARM64 binary (cross-compile via WSL)
        "mac": false        // Sync Mac binaries from OneDrive `mac/` staging into bin/ at publish time
    },
    "options": {
        "release": true,    // Use release mode (optimized)
        "verbose": false,   // Show detailed cargo output
        "piHost": "pi4c",   // Raspberry Pi hostname for SSH
        "piProjectPath": "/home/pi/dev/msger/msger-native"  // Project path on Pi
    }
}
```

## Build Targets

| Platform | Output | Method | Requirements |
|----------|--------|--------|--------------|
| `windows` | `bin/msgernative.exe` | Native build on Windows | Windows, Visual Studio Build Tools |
| `wsl` | `bin/msgernative` | Native build in WSL | WSL with Rust toolchain |
| `pi` | `bin/msgernative-linux-aarch64` | **Remote build on Pi** (slower, guaranteed compatible) | SSH access to Raspberry Pi |
| `arm64` | `bin/msgernative-linux-aarch64` | **Cross-compile on WSL** (faster, requires setup) | WSL with ARM64 cross-compilation toolchain |
| `mac` | `bin/msgernative-darwin-{arm64,x64}` | Sync from `mac/` (OneDrive staging) at publish time — Mac builds happen on the Mac via `mac/build-mac.sh` | A Mac (or stale OneDrive copy) |

**Pi vs ARM64:**
- **`pi`**: Builds on the actual Raspberry Pi via SSH - slower but guaranteed to work
- **`arm64`**: Cross-compiles locally using WSL - faster but requires cross-toolchain setup

## Features

- **JSON-driven configuration**: Simply edit JSON file to enable/disable platforms
- **Build summary**: Shows which builds succeeded/failed
- **Size reporting**: Displays binary size for each platform
- **TypeScript**: Uses Node's native TypeScript support (no compilation needed)
- **Conservative defaults**: Only builds Windows by default

## Legacy Scripts

The old individual build scripts are still available:
- `npm run build:legacy` - Original Windows build script
- `npm run build:wsl` - WSL Linux build
- `npm run build:pi` - Raspberry Pi build
- `npm run build:arm64` - ARM64 cross-compile

## Future Enhancements

Potential additions:
- Custom Cargo features/flags configuration
- Parallel builds
- Post-build verification/testing
- Binary signing/notarization
- Deployment automation
