Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Rust
uses: leynos/shared-actions/.github/actions/setup-rust@v1.1.0
- name: Show Ninja version
run: ninja --version
Comment thread
leynos marked this conversation as resolved.
- name: Format
run: make check-fmt
- name: Lint
Expand Down
78 changes: 77 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ anyhow = "1"
thiserror = "1"
sha2 = "0.10"
itoa = "1"
itertools = "0.12"

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
Expand Down Expand Up @@ -57,6 +58,8 @@ float_arithmetic = "deny"
rstest = "0.18.0"
cucumber = "0.20.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"], default-features = false }
insta = { version = "1", features = ["yaml"] }
tempfile = "3"

[[test]]
name = "cucumber"
Expand Down
50 changes: 50 additions & 0 deletions docs/netsuke-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,49 @@ pub struct BuildEdge {
}
```

```mermaid
classDiagram
class BuildGraph {
Comment thread
leynos marked this conversation as resolved.
+HashMap<String, Action> actions
+HashMap<PathBuf, BuildEdge> targets
+Vec<PathBuf> default_targets
}
class Action {
+Recipe recipe
+Option<String> description
+Option<String> depfile
+Option<String> deps_format
+Option<String> pool
+bool restat
}
class BuildEdge {
+String action_id
+Vec<PathBuf> inputs
+Vec<PathBuf> explicit_outputs
+Vec<PathBuf> implicit_outputs
+Vec<PathBuf> order_only_deps
+bool phony
+bool always
}
class Recipe {
<<enum>>
Command
Script
Rule
}
class ninja_gen {
+generate(graph: &BuildGraph) String
}
BuildGraph "1" o-- "many" Action : actions
BuildGraph "1" o-- "many" BuildEdge : targets
Action "1" o-- "1" Recipe
BuildEdge "1" --> "1" Action : action_id
ninja_gen ..> BuildGraph : uses
ninja_gen ..> Action : uses
ninja_gen ..> BuildEdge : uses
ninja_gen ..> Recipe : uses
```

### 5.3 The Transformation Process: AST to IR

The core logic of the validation stage is a function, `ir::from_manifest`, that
Expand Down Expand Up @@ -1071,6 +1114,13 @@ representation portable.
generator reports `IrGenError::MultipleRules` when encountered.
- Duplicate output files are rejected. Attempting to define the same output
path twice results in `IrGenError::DuplicateOutput`.
- The Ninja generator sorts actions and edges before output and deduplicates
edges based on their full set of explicit outputs. Sorting uses the joined
path strings to keep ordering stable across platforms, ensuring deterministic
`build.ninja` files. Small macros reduce formatting boilerplate when writing
optional key-value pairs or flags, keeping the generator easy to scan.
- Integration tests snapshot the generated Ninja file with `insta` and
execute the Ninja binary to validate structure and no-op behaviour.

## Section 6: Process Management and Secure Execution

Expand Down
8 changes: 4 additions & 4 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ compilation pipeline from parsing to execution.

- [ ] **Code Generation and Execution:**

- [ ] Implement the Ninja file synthesizer in
[src/ninja_gen.rs](src/ninja_gen.rs) to traverse the BuildGraph IR.
- [x] Implement the Ninja file synthesizer in
Comment thread
leynos marked this conversation as resolved.
[src/ninja_gen.rs](src/ninja_gen.rs) to traverse the BuildGraph IR. *(done)*

- [ ] Write logic to generate Ninja rule statements from ir::Action structs
and build statements from ir::BuildEdge structs.
- [x] Write logic to generate Ninja rule statements from ir::Action structs
Comment thread
leynos marked this conversation as resolved.
and build statements from ir::BuildEdge structs. *(done)*

- [ ] Implement the process management logic in `main.rs` to invoke the ninja
executable as a subprocess using `std::process::Command`.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ pub mod cli;
pub mod hasher;
pub mod ir;
pub mod manifest;
pub mod ninja_gen;
pub mod runner;
Loading