ninjatracing

Crates.ioninjatracing
lib.rsninjatracing
version0.1.0
created_at2026-01-19 12:28:58.796712+00
updated_at2026-01-19 12:28:58.796712+00
descriptionRust port of ninjatracing: converts Ninja build logs to Chrome Tracing format
homepagehttps://github.com/BingHanLin/ninjatracing-rs
repositoryhttps://github.com/BingHanLin/ninjatracing-rs
max_upload_size
id2054515
size83,701
Bing Han Lin (BingHanLin)

documentation

https://docs.rs/ninjatracing

README

task list

ninjatracing-rs

Rust port of the ninjatracing Python script (originally from https://github.com/nico/ninjatracing). Converts Ninja build logs (.ninja_log) to Chrome Tracing format, enabling visualization of build performance in chrome://tracing or perfetto.dev.

Installation

As a CLI Tool

From crates.io (Recommended)

cargo install ninjatracing

From source

cargo install --path .

As a Library

Add this to your Cargo.toml:

[dependencies]
ninjatracing = "0.1"

Or with only the library (without CLI):

[dependencies]
ninjatracing = { version = "0.1", default-features = false }

CLI Usage

ninjatracing [OPTIONS] <LOG_FILES>... > trace.json

Arguments

Argument Description
<LOG_FILES>... One or more .ninja_log files to parse.
-a, --showall Report on last build step for all outputs. Default is to report just on the last (possibly incremental) build.
-g, --granularity <US> Minimum length time-trace event to embed in microseconds (default: 50000).
-e, --embed-time-trace Embed clang -ftime-trace json file found adjacent to a target file.

Examples

# Basic usage
ninjatracing .ninja_log > trace.json

# Show all incremental steps
ninjatracing --showall .ninja_log > trace.json

# Embed clang traces
ninjatracing --embed-time-trace .ninja_log > trace.json

Library Usage

use ninjatracing::{log_to_dicts, TracingOptions};
use std::fs::File;
use std::io::BufReader;

fn main() -> anyhow::Result<()> {
    let file = File::open(".ninja_log")?;
    let reader = BufReader::new(file);
    let options = TracingOptions {
        show_all: false,
        granularity: 50000,
        embed_time_trace: false,
    };
    
    let events = log_to_dicts(reader, None, 42, &options)?;
    println!("Found {} events", events.len());
    Ok(())
}
Commit count: 10

cargo fmt