示例#1
0
struct context *context_new_defaults(struct clopts *o, void *context,
                                     struct makefile *mf,
                                     struct languagelist *ll,
                                     struct contextstack *s)
{
    struct context *c;

    c = talloc(context, struct context);
    c->type = CONTEXT_TYPE_DEFAULTS;
    c->parent = NULL;
    c->test_parent = NULL;
    c->bin_dir = talloc_strdup(c, "bin");
    c->lib_dir = talloc_strdup(c, "lib");
    c->hdr_dir = talloc_asprintf(c, "%sinclude", o->source_path);
    c->obj_dir = talloc_strdup(c, "obj");
    c->src_dir = talloc_asprintf(c, "%ssrc", o->source_path);
    c->chk_dir = talloc_strdup(c, "check");
    c->tst_dir = talloc_asprintf(c, "%stest", o->source_path);
    c->gen_dir = talloc_strdup(c, "obj/proc");
    c->prefix = talloc_strdup(c, DEFAULT_PREFIX);
    c->libexec_dir = talloc_strdup(c, "libexec");
    c->share_dir = talloc_strdup(c, "share");
    c->compile_opts = stringlist_new(c);
    c->link_opts = stringlist_new(c);
    c->shared_target = false;
    c->mf = talloc_reference(c, mf);
    c->ll = talloc_reference(c, ll);
    c->s = s;
    c->language = NULL;
    c->autodeps = true;

    return c;
}
示例#2
0
int language_init(struct language *l)
{
    if (l == NULL)
        return -1;

    l->name = NULL;
    l->link_name = NULL;

    l->compile_str = NULL;
    l->compile_cmd = NULL;
    l->link_str = NULL;
    l->link_cmd = NULL;

    l->so_ext = NULL;
    l->a_ext = NULL;
    l->so_ext_canon = NULL;
    l->a_ext_canon = NULL;

    l->compile_opts = stringlist_new(l);
    l->link_opts = stringlist_new(l);

    l->compiled = false;

    l->search = NULL;
    l->objname = NULL;
    l->deps = NULL;
    l->build = NULL;
    l->link = NULL;
    l->slib = NULL;
    l->extras = NULL;
    l->quirks = NULL;

    return 0;
}
示例#3
0
struct context *context_new_test(struct context *parent, void *context,
                                 const char *called_path)
{
    struct context *c;

    c = talloc(context, struct context);
    c->type = CONTEXT_TYPE_TEST;
    c->parent = c;
    c->test_parent = parent;
    c->bin_dir = talloc_reference(c, parent->chk_dir);
    c->lib_dir = talloc_reference(c, parent->lib_dir);
    c->hdr_dir = talloc_reference(c, parent->hdr_dir);
    c->obj_dir = talloc_reference(c, parent->obj_dir);
    c->src_dir = talloc_asprintf(c, "%s/%s", parent->tst_dir,
                                 parent->called_path);
    c->chk_dir = talloc_reference(c, parent->chk_dir);
    c->tst_dir = talloc_reference(c, parent->tst_dir);
    c->gen_dir = talloc_reference(c, parent->gen_dir);
    c->prefix = talloc_reference(c, parent->prefix);
    c->libexec_dir = talloc_reference(c, parent->libexec_dir);
    c->share_dir = talloc_reference(c, parent->share_dir);
    c->compile_opts = stringlist_copy(parent->compile_opts, c);
    c->link_opts = stringlist_copy(parent->link_opts, c);
    c->mf = talloc_reference(c, parent->mf);
    c->ll = talloc_reference(c, parent->ll);
    c->shared_target = false;
    c->s = parent->s;
    c->language = NULL;
    c->objects = stringlist_new(c);
    c->libraries = stringlist_new(c);
    c->testdeps = stringlist_copy(parent->testdeps, c);
    c->testdir = talloc_strdup(c, parent->testdir);
    c->src_dir = talloc_strdup(c, parent->testdir);
    c->autodeps = parent->autodeps;

    c->called_path = talloc_strdup(c, called_path);
    c->full_path = talloc_asprintf(c, "%s/%s/%s", c->bin_dir,
                                   parent->called_path, called_path);
    c->link_path = talloc_strdup(c, "");
    c->link_path_install = talloc_strdup(c, "");

    talloc_set_destructor(c, &context_test_destructor);

    return c;
}
示例#4
0
文件: makefile.c 项目: ppannuto/tek
struct makefile *makefile_new(struct clopts *o)
{
    struct makefile *m;

    m = talloc(o, struct makefile);
    talloc_set_destructor(m, &mf_destructor);
    m->file = fopen("Makefile", "w");
    m->targets_all = stringlist_new(m);
    m->targets_clean = stringlist_new(m);
    m->targets_cleancache = stringlist_new(m);
    m->targets_distclean = stringlist_new(m);
    m->every_target = stringlist_new(m);
    m->state = MAKEFILE_STATE_NONE;

    fprintf(m->file, "SHELL=/bin/bash\n");
    fprintf(m->file, ".PHONY: all tek__all clean cleancache distclean\n");
    fprintf(m->file, ".SUFFIXES:\n");
    fprintf(m->file, "all: tek__all\n");
    fprintf(m->file, "\n");

    return m;
}
示例#5
0
struct context *context_new_fullsrc(struct context *parent, void *context,
                                    const char *full_path)
{
    struct context *c;

    c = talloc(context, struct context);
    c->type = CONTEXT_TYPE_SOURCE;
    c->parent = parent->parent;
    c->test_parent = NULL;
    c->bin_dir = talloc_reference(c, parent->bin_dir);
    c->lib_dir = talloc_reference(c, parent->lib_dir);
    c->hdr_dir = talloc_reference(c, parent->hdr_dir);
    c->obj_dir = talloc_reference(c, parent->obj_dir);
    c->src_dir = talloc_reference(c, parent->src_dir);
    c->chk_dir = talloc_reference(c, parent->chk_dir);
    c->tst_dir = talloc_reference(c, parent->tst_dir);
    c->gen_dir = talloc_reference(c, parent->gen_dir);
    c->prefix = talloc_reference(c, parent->prefix);
    c->libexec_dir = talloc_reference(c, parent->libexec_dir);
    c->compile_opts = stringlist_copy(parent->compile_opts, c);
    c->link_opts = stringlist_copy(parent->link_opts, c);
    c->shared_target = parent->shared_target;
    c->mf = talloc_reference(c, parent->mf);
    c->ll = talloc_reference(c, parent->ll);
    c->s = parent->s;
    c->language = NULL;
    c->objects = stringlist_new(c);
    c->libraries = stringlist_new(c);
    c->testdeps = stringlist_new(c);

    c->full_path = talloc_strdup(c, full_path);
    c->link_path = talloc_strdup(c, "");
    c->link_path_install = talloc_strdup(c, "");

    talloc_set_destructor(c, &context_source_destructor);

    return c;
}
示例#6
0
文件: configuration.c 项目: bje/pk
CONFIGURATION *configuration_new(int argc, char **argv)
{
    CONFIGURATION *self = MALLOC(CONFIGURATION);
    self->delimiters = Strdup("\t ");
    self->allow_empty_tokens = false;
    self->backslash_escapes_delimiters = false;
    self->trim_non_alphanumeric = false;
    self->ignore_quoted_delimiters = false;
    self->empty_string = "NULL";
    self->fields = stringlist_new();
    self->file = NULL;
    self->excludes = make_excludes(getenv("PK_EXCLUDES"));
    self->separator = " ";
    self->quote_open = '"';
    self->quote_close = '"';
    struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 };
    argp_parse(&argp, argc, argv, 0, 0, self);
    return self;
}