aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/rules.h
blob: 3a04d0c73e8da2dcd04ed5fd80d906574f156082 (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
/*
 * blogc: A blog compiler.
 * Copyright (C) 2014-2017 Rafael G. Martins <rafael@rafaelmartins.eng.br>
 *
 * This program can be distributed under the terms of the BSD License.
 * See the file LICENSE.
 */

#ifndef _MAKE_RULES_H
#define _MAKE_RULES_H

#include <stdbool.h>
#include "ctx.h"
#include "../common/utils.h"

typedef bc_slist_t* (*bm_rule_outputlist_func_t) (bm_ctx_t *ctx);
typedef int (*bm_rule_exec_func_t) (bm_ctx_t *ctx, bc_slist_t *outputs,
    bc_trie_t *args, bool verbose);

typedef struct {
    const char *name;
    const char *help;
    bm_rule_outputlist_func_t outputlist_func;
    bm_rule_exec_func_t exec_func;
    bool generate_files;
} bm_rule_t;

bc_trie_t* bm_rule_parse_args(const char *sep);
int bm_rule_executor(bm_ctx_t *ctx, bc_slist_t *rule_list, bool verbose);
int bm_rule_execute(bm_ctx_t *ctx, const bm_rule_t *rule, bc_trie_t *args,
    bool verbose);
bool bm_rule_need_rebuild(bc_slist_t *sources, bm_filectx_t *settings,
    bm_filectx_t *template, bm_filectx_t *output, bool only_first_source);
bc_slist_t* bm_rule_list_built_files(bm_ctx_t *ctx);
void bm_rule_print_help(void);

#endif /* _MAKE_RULES_H */