# Building the RAW decoder helper

## Tested environment

The Film Buddy 0.7.0 (build 1) release helper was reproduced on:

- Apple silicon (`arm64`);
- macOS 26.5.1 (build 25F80);
- Xcode 26.6 (build 17F113);
- Apple clang 21.0.0 (`clang-2100.1.1.101`);
- CMake 4.3.4; and
- XZ Utils 5.8.3.

The scripts target macOS 13.0 by default. Newer compatible versions of the
tools may build working binaries without producing byte-identical output.
The repository's release verifier uses `-ffile-prefix-map` to reproduce the
absolute `__FILE__` assertion strings embedded in the shipped LLVM runtime;
that mapping is unnecessary for an ordinary functional build.

## Prerequisites

Install Xcode and its command-line tools. Ensure these commands are available:

```text
xcrun clang++ make cmake shasum tar xz codesign install_name_tool
```

The build does not require a network connection because the exact LLVM 22.1.8
source archive is included under `vendor-sources/`.

## Build

From the extracted archive root:

```bash
./build.sh
```

Outputs:

```text
build/libraw-decoder/filmbuddy-raw-decode-libraw
build/libraw-decoder/libomp.dylib
```

Both outputs receive local ad-hoc signatures. Distribution signatures are not
included in Corresponding Source and must be applied by the distributor.

## Verify

```bash
./verify.sh
```

The expected status payload contains:

```json
{"schema":"filmbuddy.native_raw_decode.status.v1","status":"ok","decoder":"LibRaw+librtprocess","libraw_version":"0.22.0-Release","normalization_policy":"libraw-amaze-linear-romm-scene-v3"}
```

Whitespace may differ. The helper also exposes these interfaces:

```text
filmbuddy-raw-decode-libraw probe <raw-file>
filmbuddy-raw-decode-libraw decode --input <raw> --output <tif> [--max-pixel-size N]
filmbuddy-raw-decode-libraw status
```

## Build settings

The defaults are:

```text
FILMBUDDY_BUILD_ARCH=arm64
FILMBUDDY_MACOS_DEPLOYMENT_TARGET=13.0
```

They may be overridden in the environment. The shipped 0.7.0 (build 1)
artifacts use the defaults. The build links LibRaw and librtprocess statically
into the helper and places the dynamically linked `libomp.dylib` beside it.
`install_name_tool` changes the OpenMP install name and helper dependency to
`@rpath/libomp.dylib`.
