Targets define what to build or what action to perform.
-
name: Output file path(s). Can be a string or a list (StringOrList). -
recipe: How to build the target. Defined by one ofrule,command, orscript(mutually exclusive). -
sources: Input file path(s) (StringOrList). If a source matches another target'sname, an implicit dependency is created. -
deps(Optional): Explicit target dependencies (StringOrList). Changes trigger rebuilds. -
order_only_deps(Optional): Dependencies that must run first but whose changes don't trigger rebuilds (StringOrList). Maps to Ninja||. -
vars(Optional): Target-specific variables that override globalvars. -
phony(Optional, defaultfalse): Treat target as logical, not a file. Always out-of-date if requested. -
always(Optional, defaultfalse): Re-run the command every timenetsukeis invoked, regardless of dependency changes.
StringOrList: Fields like name, sources, deps, and order_only_deps
accept either a single string or a YAML list of strings for convenience.
targets: # Example 1: Building an object file using a rule - name: build/utils.o # Output file(s). Can be a string or list. rule: compile # Rule to use (mutually exclusive with command/script) sources: src/utils.c # Input file(s). String or list. deps: # Explicit dependencies (targets built before this one) - build/utils.h vars: # Target-local variables, override globals cflags: "-O0 -g" # Example 2: Linking an executable using an inline command - name: my_app command: "{{ cc }} build/main.o build/utils.o -o my_app" sources: # Implicit dependencies derived from command/rule usage - build/main.o - build/utils.o order_only_deps: # Dependencies built before, but changes don't trigger rebuild - build_directory # e.g., Ensure 'build/' exists # Example 3: A phony action (can also be in top-level 'actions:') - name: package phony: true # Doesn't represent a file, always considered out-of-date command: "tar czf package.tar.gz my_app" deps: my_app # Depends on the 'my_app' target # Example 4: A target that always runs - name: timestamp always: true # Runs every time, regardless of inputs/outputs command: "date > build/timestamp.txt"