C / C++ Beginner Reviewed syntax

Basic C Application

A foundational example demonstrating how to compile two C sources and link them into one executable. The point is the manifest language, not a rule loader.

Directory Structure

basic-c/
main.c
utils.c
utils.h
Netsukefile

This project consists of a single executable main.c that depends on a utility library defined by utils.c and utils.h.

Key Concept

Netsuke files are typically placed at the root of the package they define.

Keep the graph obvious: sources are file paths, build steps are rules or inline commands, and defaults name the artefacts to build.

Annotated Manifest

Netsukefile
netsuke_version: "1.0.0"

vars:
  cc: gcc
  cflags: "-Wall -O2"

rules:
  - name: compile
    command: "{{ cc }} {{ cflags }} -c {{ ins }} -o {{ outs }}"
    description: "Compiling an object file"

  - name: link
    command: "{{ cc }} {{ cflags }} {{ ins }} -o {{ outs }}"

targets:
  - name: main.o
    rule: compile
    sources: src/main.c

  - name: utils.o
    rule: compile
    sources: src/utils.c

  - name: app
    rule: link
    sources:
      - main.o
      - utils.o

actions:
  - name: run
    command: "./app"

  - name: clean
    command: "rm -f *.o app"

defaults:
  - app
1

Schema version

Every manifest starts with netsuke_version. The reviewed docs treat it as the contract for the file format.

2

Reusable rules

A rule holds the shared command template. Targets point at that rule instead of duplicating the command line.

3

Explicit graph edges

The executable target lists the object files it needs in sources. Netsuke turns that static graph into Ninja build statements.

Running the Build

Terminal
$ netsuke build app
[1/3] Compiling an object file
[2/3] Compiling an object file
[3/3] gcc -Wall -O2 main.o utils.o -o app
$ ./app
Hello from C!

Dependency Graph

app
utils.o
Binary
Library