Skip to content

Builder

Delegates compilation to Platform.build() and returns structured build results.

builder

Build orchestration for gen_dsp projects.

Uses the platform registry to dynamically select the appropriate build system for each platform.

BuildResult dataclass

BuildResult(
    success: bool,
    platform: str,
    output_file: Optional[Path],
    stdout: str,
    stderr: str,
    return_code: int,
)

Result of a build operation.

Builder

Builder(project_dir: Path | str)

Build gen_dsp projects.

Initialize builder with project directory.

Parameters:

Name Type Description Default
project_dir Path | str

Path to the gen_dsp project directory.

required

detect_platform

detect_platform() -> Optional[str]

Return the platform recorded in this project's .gen-dsp.json.

The marker is written at project generation time, so a project knows its own target platform. Returns None if the marker is absent, unreadable, or names a platform not in the registry (e.g. a stale or hand-edited marker).

build

build(
    target_platform: Optional[str] = None,
    clean: bool = False,
    verbose: bool = False,
) -> BuildResult

Build the project for the specified platform.

Parameters:

Name Type Description Default
target_platform Optional[str]

Platform name (e.g., 'pd', 'max'). When None, the platform is auto-detected from the project's .gen-dsp.json marker, falling back to 'pd' if no marker is present.

None
clean bool

If True, clean before building.

False
verbose bool

If True, print build output in real-time.

False

Returns:

Type Description
BuildResult

BuildResult with build status and output file path.

Raises:

Type Description
BuildError

If build fails and cannot be recovered.

ValueError

If platform is not recognized.

clean

clean(target_platform: Optional[str] = None) -> None

Clean build artifacts.

Parameters:

Name Type Description Default
target_platform Optional[str]

Platform name (e.g., 'pd', 'max'). When None, the platform is auto-detected from the project's .gen-dsp.json marker, falling back to 'pd'.

None

get_lib_name

get_lib_name() -> Optional[str]

Get the lib.name from the project Makefile.

Returns:

Type Description
Optional[str]

The lib.name value or None if not found.