@calls

Only valid: inside @goal.

Syntax:

@calls goal1 [ goal2 [ goal3 [...] ] ]

Imperative (non-declarative) counterpart of @depends_on.

The need for @calls may be not obvious, but the use-case is presented here.

Differences to @depends_on:

  • @calls doesn't favor run-once semantics
  • @calls defers the @reached_if processing of a goal being called to the invocation time (@depens_on calculates all @reached_if conditions at start)

Operationally @calls desugars to a nested makesure invocation:

@goal a
  echo a
  
@goal b
@calls a

desugars to

@goal a
  echo a
  
@goal b
  ./makesure a # actual command passes other arguments (for --file, --define, etc.)

Example Makesurefile:

@goal a
  echo a
  
@goal b
@calls a
@calls a

Running ./makesure b will show

  goal 'b' ...
  goal 'a' ...
a
  goal 'a' ...
a

You can declare multiple @calls targets for a goal:

@goal a
@calls b c d

Circular dependency (both @depends_on and @calls considered) will cause an error:

@goal a
@depends_on b

@goal b
@calls c

@goal c
@calls a

Running ./makesure a will show

There is a loop in goal dependencies via a -> c

You can use @calls to invoke a parameterized goal:

@goal hello @params WHO
  echo "Hello $WHO!"

@goal a
@calls hello @args 'world'
@calls hello @args 'hacker'

Running ./makesure a will show

  goal 'a' ...
  goal 'hello@world' ...
Hello world!
  goal 'hello@hacker' ...
Hello hacker!

You can mix @calls and @depends_on but please note, that depended-on goal will be invoked before the called one. So this is valid:

@goal a
@calls b
@depends_on c

but you better write it as:

@goal a
@depends_on c
@calls b

You can find more information on how the directive interacts with the other directives in @calls.md.