summaryrefslogtreecommitdiff
path: root/tools/build/v2/engine/command.h
blob: ba655771034228b3393ef4e24a7e80cf6543f191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright 1994 Christopher Seiwald.
 *
 * This file is part of Jam - see jam.c for Copyright information.
 */

/*
 * command.h - the CMD structure and routines to manipulate them
 *
 * Both ACTION and CMD contain a rule, targets, and sources.  An
 * ACTION describes a rule to be applied to the given targets and
 * sources; a CMD is what actually gets executed by the shell.  The
 * differences are due to:
 *
 *  ACTIONS must be combined if 'actions together' is given.
 *  ACTIONS must be split if 'actions piecemeal' is given.
 *  ACTIONS must have current sources omitted for 'actions updated'.
 *
 * The CMD datatype holds a single command that is to be executed
 * against a target, and they can chain together to represent the
 * full collection of commands used to update a target.
 *
 * Structures:
 *
 *  CMD - an action, ready to be formatted into a buffer and executed.
 *
 * External routines:
 *
 *  cmd_new() - return a new CMD or 0 if too many args.
 *  cmd_free() - delete CMD and its parts.
 *  cmd_next() - walk the CMD chain.
 *  cmd_release_targets_and_shell() - CMD forgets about its targets & shell.
 */


/*
 * CMD - an action, ready to be formatted into a buffer and executed.
 */

#ifndef COMMAND_SW20111118_H
#define COMMAND_SW20111118_H

#include "lists.h"
#include "rules.h"
#include "strings.h"


typedef struct _cmd CMD;
struct _cmd
{
    CMD  * next;
    RULE * rule;      /* rule->actions contains shell script */
    LIST * shell;     /* $(JAMSHELL) value */
    LOL    args;      /* LISTs for $(<), $(>) */
    string buf[ 1 ];  /* actual commands */
    int    noop;      /* no-op commands should be faked instead of executed */
};

CMD * cmd_new
(
    RULE * rule,     /* rule (referenced) */
    LIST * targets,  /* $(<) (ownership transferred) */
    LIST * sources,  /* $(>) (ownership transferred) */
    LIST * shell     /* $(JAMSHELL) (ownership transferred) */
);

void cmd_release_targets_and_shell( CMD * );

void cmd_free( CMD * );

#define cmd_next( c ) ((c)->next)

#endif