Nitpick Build System (npkbld) Specification

The official build system for Nitpick is npkbld. It manages compilation orchestration and parallel building, integrating seamlessly with the npkc compiler. For dependency resolution and package management, use the standalone npkpkg package manager tool.

1. Core Commands

npkbld offers a standard suite of build commands similar to Cargo or Make.

2. Global Options and Flags

You can customize the build execution environment with several global flags:

3. Configuration Format (build.npk and build.abc)

npkbld natively supports execution-based build manifests using the Nitpick language itself (build.npk), providing programmatic control over build targets. It also supports static TOML-based configurations (build.abc) for legacy compatibility.

Programmatic build.npk Structure

When build.npk is present, npkbld compiles and executes it to emit the final build manifest. This utilizes the standard bld.npk API:

use "bld.npk".*;

pub func:main = int32() {
    Project:p;
    p.name = "my_project";
    p.version = "0.1.0";
    drop(emit_project(p));

    Target:main_tgt;
    main_tgt.name = "main";
    main_tgt.target_type = "binary";
    main_tgt.sources = raw str_array1("src/*.npk");
    main_tgt.flags = raw str_array2("-O2", "--verify");
    drop(emit_target(main_tgt));

    exit 0i32;
};

Static build.abc Structure

[project]
name = "my_project"
version = "0.1.0"

[target.main]
type = "binary"              # Can be "binary" or "library"
sources = ["src/*.npk"]      # Glob patterns supported
deps = []                    # Internal target dependencies
flags = ["-O2", "--verify"]  # Custom npkc flags

4. CMake Integration

For integration into larger C/C++ projects, Nitpick ships with FindNitpick.cmake. Downstream projects can easily import and build Nitpick sources natively within CMake:

find_package(Nitpick REQUIRED)

# Compiles Nitpick sources to objects and links with libnitpick_runtime.a
add_nitpick_executable(my_app src/main.npk)
add_nitpick_library(my_lib STATIC src/utils.npk)

Dependency Emission

npkbld deeply integrates with npkc’s --emit-deps flag. During a build, it triggers the compiler to emit JSON dependency manifests, which npkbld then consumes to build the parallelized internal build graph. You can visualize this graph using the npkbld deps > graph.dot command.